File: Issue70.chs

package info (click to toggle)
c2hs 0.28.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,788 kB
  • sloc: haskell: 6,882; ansic: 1,857; xml: 1,411; makefile: 111
file content (23 lines) | stat: -rwxr-xr-x 723 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
module Foo where

#include "issue70.h"

class Flux a where
  data FluxCode a
  gigawattsNeeded :: a -> Double
  gigawattsNeeded _ = 1.21

data Capacitor = Capacitor Int

instance Flux Capacitor where
  -- associated data type decl
  data FluxCode Capacitor = Bar | Baz | Qux | Xyzzy

-- Note: must be able to define longer names here, I've used single quotes.
-- underscoreToCase still works, it aliases the C identifiers for the instance.
-- XYZZY_THUD is manually aliased.
-- nocode suppresses emitting a data declaration.
{# enum Foo as 'FluxCode Capacitor' nocode { underscoreToCase,
                                             XYZZY_THUD as Xyzzy } #}