07a1dfbd8ee1b8bcc7f48a41d2be7ba071425d1d
[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] 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 -- We distinguish primitive coercions
60 -- (represented in GHC by wired-in names), because
61 -- External Core treats them specially, so we have
62 -- to print them out with special syntax.
63   | TransCoercion Ty Ty
64   | SymCoercion Ty
65   | UnsafeCoercion Ty Ty
66   | InstCoercion Ty Ty
67   | LeftCoercion Ty
68   | RightCoercion Ty
69
70 data Kind 
71   = Klifted
72   | Kunlifted
73   | Kunboxed
74   | Kopen
75   | Karrow Kind Kind
76   | Keq Ty Ty
77
78 data Lit 
79   = Lint Integer Ty
80   | Lrational Rational Ty
81   | Lchar Char Ty
82   | Lstring String Ty
83   
84
85 type Mname = Id
86 type Var = Id
87 type Tvar = Id
88 type Tcon = Id
89 type Dcon = Id
90
91 type Qual t = (Mname,t)
92
93 type Id = String
94
95 primMname :: Mname
96 -- For truly horrible reasons, this must be z-encoded.
97 -- With any hope, the z-encoding will die soon.
98 primMname = "ghczmprim:GHCziPrim"
99
100 tcArrow :: Qual Tcon
101 tcArrow = (primMname, "(->)")
102
103 \end{code}
104
105
106
107