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