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