The internal workings of GHC

October 5th, 2007 by Graham

Andy Gill from Galois visited today, and talked about two of the key ideas in the Glasgow Haskell Compiler: the simple data type that is used to represent expressions (copied below), and the manner in which unboxed values are handled.

data Expr b = — “b” for the type of binders,
Var Id
| Lit Literal
| App (Expr b) (Arg b)
| Lam b (Expr b)
| Let (Bind b) (Expr b)
| Case (Expr b) b Type [Alt b]
| Cast (Expr b) Coercion
| Note Note (Expr b)
| Type Type

type Arg b = Expr b

type Alt b = (AltCon, [b], Expr b)

data AltCon =
DataAlt DataCon
| LitAlt Literal
deriving (Eq, Ord)

data Bind b =
NonRec b (Expr b)
| Rec [(b, (Expr b))]

Leave a Reply