-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | compile your own mini functional language with Core -- -- This package doubles as a compiler and as a module with which anyone -- can compile their own functional programming language by parsing into -- the CoreExpr datatype @package core-compiler @version 0.1.0.2 module Core.Grammar -- | A Core expression type CoreExpr = Expr Name -- | AST of the Core language data Expr a -- | a variable EVar :: Name -> Expr a -- | an Int ENum :: Int -> Expr a -- | a type declaration EConstr :: Int -> Int -> [Expr a] -> Expr a -- | function application EAp :: (Expr a) -> (Expr a) -> Expr a -- | let/letrec expression ELet :: Bool -> [(a, Expr a)] -> (Expr a) -> Expr a -- | case expression ECase :: (Expr a) -> [Alter a] -> Expr a -- | lambda expression (not yet implemented) ELam :: [a] -> (Expr a) -> Expr a type Name = String -- | a case alternative type CoreAlt = Alter Name -- | 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 list of super combinator definitions type CoreProgram = Program Name -- | a list of supercombinator definitions type Program a = [ScDefn a] -- | A supercombinator definition type CoreScDefn = ScDefn 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) instance GHC.Classes.Eq a => GHC.Classes.Eq (Core.Grammar.Expr a) instance GHC.Show.Show a => GHC.Show.Show (Core.Grammar.Expr a) module Core.Prelude -- | simple but important functions in Core preludeDefs :: CoreProgram -- | primitive operations primitives :: CoreProgram module Core.GMachine -- | executes the g-machine by executing each instruction each execution of -- an instruction is cons'ed to the list the last state in the list is -- the final instruction eval :: GmState -> [GmState] module Core.Pretty -- | pretty prints a core program pprint :: CoreProgram -> String -- | outputs each step the GMachine makes in compiling a program showResults :: Printer -- | outputs the final result of evaluating a program with the G machine showFinalResult :: Printer type Printer = [GmState] -> [Char] instance GHC.Classes.Eq Core.Pretty.Iseq instance GHC.Show.Show Core.Pretty.Iseq module Core.Compiler -- | sets initial state, binds the supercombinators to the environment, and -- generates the initial G code compile :: CoreProgram -> GmState