Remove CPP from nativeGen/RegAlloc/Graph/TrivColorable.hs
[ghc-hetmet.git] / compiler / coreSyn / ExternalCore.lhs
1 %
2 % (c) The University of Glasgow 2001-2006
3 %
4 \begin{code}
5 module ExternalCore where
6
7 data Module 
8  = Module Mname [Tdef] [Vdefg]
9
10 data Tdef 
11   = Data (Qual Tcon) [Tbind] [Cdef]
12   | Newtype (Qual Tcon) (Qual Tcon) [Tbind] Ty
13
14 data Cdef 
15   = Constr (Qual Dcon) [Tbind] [Ty]
16   | GadtConstr (Qual Dcon) Ty
17
18 data Vdefg 
19   = Rec [Vdef]
20   | Nonrec Vdef
21
22 -- Top-level bindings are qualified, so that the printer doesn't have to pass
23 -- around the module name.
24 type Vdef = (Bool,Qual Var,Ty,Exp)
25
26 data Exp 
27   = Var (Qual Var)
28   | Dcon (Qual Dcon)
29   | Lit Lit
30   | App Exp Exp
31   | Appt Exp Ty
32   | Lam Bind Exp          
33   | Let Vdefg Exp
34   | Case Exp Vbind Ty [Alt] {- non-empty list -}
35   | Cast Exp Ty
36   | Note String Exp
37   | External String String Ty {- target name, convention, and type -} 
38   | DynExternal String Ty {- convention and type (incl. Addr# of target as first arg) -} 
39   | Label String
40
41 data Bind 
42   = Vb Vbind
43   | Tb Tbind
44
45 data Alt 
46   = Acon (Qual Dcon) [Tbind] [Vbind] Exp
47   | Alit Lit Exp
48   | Adefault Exp
49
50 type Vbind = (Var,Ty)
51 type Tbind = (Tvar,Kind)
52
53 -- Internally, we represent types and coercions separately; but for
54 -- the purposes of external core (at least for now) it's still
55 -- convenient to collapse them into a single type.
56 data Ty 
57   = Tvar Tvar
58   | Tcon (Qual Tcon)
59   | Tapp Ty Ty
60   | Tforall Tbind Ty 
61 -- We distinguish primitive coercions because External Core treats
62 -- them specially, so we have to print them out with special syntax.
63   | TransCoercion Ty Ty
64   | SymCoercion Ty
65   | UnsafeCoercion Ty Ty
66   | InstCoercion Ty Ty
67   | NthCoercion Int Ty
68
69 data Kind 
70   = Klifted
71   | Kunlifted
72   | Kunboxed
73   | Kopen
74   | Karrow Kind Kind
75   | Keq Ty Ty
76
77 data Lit 
78   = Lint Integer Ty
79   | Lrational Rational Ty
80   | Lchar Char Ty
81   | Lstring String Ty
82   
83
84 type Mname = Id
85 type Var = Id
86 type Tvar = Id
87 type Tcon = Id
88 type Dcon = Id
89
90 type Qual t = (Mname,t)
91
92 type Id = String
93
94 primMname :: Mname
95 -- For truly horrible reasons, this must be z-encoded.
96 -- With any hope, the z-encoding will die soon.
97 primMname = "ghczmprim:GHCziPrim"
98
99 tcArrow :: Qual Tcon
100 tcArrow = (primMname, "(->)")
101
102 \end{code}
103
104
105
106