core-compiler-0.1.0.2: src/Core/Grammar.hs
module Core.Grammar (CoreExpr(..),
Expr(..),
Name,
CoreAlt(..),
Alter(..),
CoreProgram(..),
Program(..),
CoreScDefn(..),
ScDefn(..)) where
-- | AST of the Core language
data Expr a = EVar Name -- ^ a variable
| ENum Int -- ^ an Int
| EConstr Int Int [Expr a] -- ^ a type declaration
| EAp (Expr a) (Expr a) -- ^ function application
| ELet Bool [(a, Expr a)] (Expr a) -- ^ let/letrec expression
| ECase (Expr a) [Alter a] -- ^ case expression
| ELam [a] (Expr a) -- ^ lambda expression (not yet implemented)
deriving (Show, Eq)
-- | A Core expression
type CoreExpr = Expr Name
type Name = String
-- | a case alternative for a given datatype
-- contains the datatype id
-- a list of local variable names
-- the expression that the case evaluates to
type Alter a = (Int
,[a]
, Expr a
)
-- | a case alternative
type CoreAlt = Alter Name
-- | a list of supercombinator definitions
type Program a = [ScDefn a]
-- | A list of super combinator definitions
type CoreProgram = Program Name
-- | contains the name of the function/global
-- the list of local variable names
-- the expression the supercombinator evaluates to
type ScDefn a = (Name
,[a]
, Expr a
)
-- | A supercombinator definition
type CoreScDefn = ScDefn Name