Another round of External Core fixes
[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
8 data Module 
9  = Module Mname [Tdef] [Vdefg]
10
11 data Tdef 
12   = Data (Qual Tcon) [Tbind] [Cdef]
13   | Newtype (Qual Tcon) [Tbind] Axiom (Maybe Ty)
14
15 data Cdef 
16   = Constr (Qual Dcon) [Tbind] [Ty]
17   | GadtConstr (Qual Dcon) Ty
18
19 -- Newtype coercion
20 type Axiom = (Qual Tcon, [Tbind], Kind)
21
22 data Vdefg 
23   = Rec [Vdef]
24   | Nonrec Vdef
25
26 -- Top-level bindings are qualified, so that the printer doesn't have to pass
27 -- around the module name.
28 type Vdef = (Bool,Qual Var,Ty,Exp)
29
30 data Exp 
31   = Var (Qual Var)
32   | Dcon (Qual Dcon)
33   | Lit Lit
34   | App Exp Exp
35   | Appt Exp Ty
36   | Lam Bind Exp          
37   | Let Vdefg Exp
38   | Case Exp Vbind Ty [Alt] {- non-empty list -}
39   | Cast Exp Ty
40   | Note String Exp
41   | External String String Ty {- target name, convention, and type -} 
42   | DynExternal String Ty {- convention and type (incl. Addr# of target as first arg) -} 
43   | Label String
44
45 data Bind 
46   = Vb Vbind
47   | Tb Tbind
48
49 data Alt 
50   = Acon (Qual Dcon) [Tbind] [Vbind] Exp
51   | Alit Lit Exp
52   | Adefault Exp
53
54 type Vbind = (Var,Ty)
55 type Tbind = (Tvar,Kind)
56
57 data Ty 
58   = Tvar Tvar
59   | Tcon (Qual Tcon)
60   | Tapp Ty Ty
61   | Tforall Tbind Ty 
62
63 data Kind 
64   = Klifted
65   | Kunlifted
66   | Kunboxed
67   | Kopen
68   | Karrow Kind Kind
69   | Keq Ty Ty
70
71 data Lit 
72   = Lint Integer Ty
73   | Lrational Rational Ty
74   | Lchar Char Ty
75   | Lstring String Ty
76   
77
78 type Mname = Id
79 type Var = Id
80 type Tvar = Id
81 type Tcon = Id
82 type Dcon = Id
83
84 type Qual t = (Mname,t)
85
86 type Id = String
87
88 primMname :: Mname
89 -- For truly horrible reasons, this must be z-encoded.
90 -- With any hope, the z-encoding will die soon.
91 primMname = "ghczmprim:GHCziPrim"
92
93 tcArrow :: Qual Tcon
94 tcArrow = (primMname, "(->)")
95
96 \end{code}
97
98
99
100