ExternalCore.lhs 1.45 KB
Newer Older
apt's avatar
apt committed
1
%
Simon Marlow's avatar
Simon Marlow committed
2
% (c) The University of Glasgow 2001-2006
apt's avatar
apt committed
3
4
5
6
7
8
%
\begin{code}
module ExternalCore where


data Module 
apt's avatar
apt committed
9
 = Module Mname [Tdef] [Vdefg]
apt's avatar
apt committed
10
11

data Tdef 
apt's avatar
apt committed
12
13
  = Data (Qual Tcon) [Tbind] [Cdef]
  | Newtype (Qual Tcon) [Tbind] (Maybe Ty)
apt's avatar
apt committed
14
15

data Cdef 
16
  = Constr Dcon [Tbind] [Ty]
17
  | GadtConstr Dcon Ty
apt's avatar
apt committed
18
19
20
21
22

data Vdefg 
  = Rec [Vdef]
  | Nonrec Vdef

23
type Vdef = (Bool,Var,Ty,Exp) 	-- Top level bindings are unqualified now
apt's avatar
apt committed
24
25
26
27
28
29
30
31
32

data Exp 
  = Var (Qual Var)
  | Dcon (Qual Dcon)
  | Lit Lit
  | App Exp Exp
  | Appt Exp Ty
  | Lam Bind Exp 	  
  | Let Vdefg Exp
33
  | Case Exp Vbind Ty [Alt] {- non-empty list -}
34
  | Cast Exp Ty
apt's avatar
apt committed
35
  | Note String Exp
36
37
38
  | External String String Ty {- target name, convention, and type -} 
  | DynExternal String Ty {- convention and type (incl. Addr# of target as first arg) -} 
  | Label String
apt's avatar
apt committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

data Bind 
  = Vb Vbind
  | Tb Tbind

data Alt 
  = Acon (Qual Dcon) [Tbind] [Vbind] Exp
  | Alit Lit Exp
  | Adefault Exp

type Vbind = (Var,Ty)
type Tbind = (Tvar,Kind)

data Ty 
  = Tvar Tvar
  | Tcon (Qual Tcon)
  | Tapp Ty Ty
  | Tforall Tbind Ty 

data Kind 
  = Klifted
  | Kunlifted
Simon Marlow's avatar
Simon Marlow committed
61
  | Kunboxed
apt's avatar
apt committed
62
63
  | Kopen
  | Karrow Kind Kind
64
  | Keq Ty Ty
apt's avatar
apt committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

data Lit 
  = Lint Integer Ty
  | Lrational Rational Ty
  | Lchar Char Ty
  | Lstring String Ty
  

type Mname = Id
type Var = Id
type Tvar = Id
type Tcon = Id
type Dcon = Id

type Qual t = (Mname,t)

type Id = String

83
primMname :: Mname
84
primMname = "base:GHC.Prim"
apt's avatar
apt committed
85
86

tcArrow :: Qual Tcon
87
tcArrow = (primMname, "(->)")
apt's avatar
apt committed
88
89
90
91
92
93

\end{code}