ExternalCore.lhs 1.42 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 9
%
\begin{code}

module ExternalCore where


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

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

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

data Vdefg 
  = Rec [Vdef]
  | Nonrec Vdef

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

data Exp 
  = Var (Qual Var)
  | Dcon (Qual Dcon)
  | Lit Lit
  | App Exp Exp
  | Appt Exp Ty
  | Lam Bind Exp 	  
  | Let Vdefg Exp
34
  | Case Exp Vbind Ty [Alt] {- non-empty list -}
35
  | Cast Exp Ty
apt's avatar
apt committed
36
  | Note String Exp
37 38 39
  | 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

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
62
  | Kunboxed
apt's avatar
apt committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  | Kopen
  | Karrow Kind Kind

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 = "base:GHC.Prim"
apt's avatar
apt committed
84 85

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

\end{code}