husk-scheme-3.8: R5RS Scheme interpreter, compiler, and library.

Safe HaskellSafe-Inferred



This module contains an experimental Scheme to Haskell compiler.

The compiler performs the following transformations:

 Scheme AST (LispVal) => Haskell AST (HaskAST) => Compiled Code (String)

The GHC compiler is then used to create a native executable.

At present, the focus has just been on creating a compiler that will generate correct, working code. Many optimizations could and need to be made for time and space...



joinL :: forall a. [[a]] -> [a] -> [a]Source

ast2Str :: LispVal -> StringSource

Convert abstract syntax tree to a string

asts2Str :: [LispVal] -> StringSource

Convert a list of abstract syntax trees to a list of strings



:: Env

Current compile Environment

-> LispVal

Lisp code after macro expansion

-> CompOpts

Compiler options

-> (Env -> LispVal -> CompOpts -> IOThrowsError [HaskAST])

Continuation to call into after vars are diverted

-> IOThrowsError [HaskAST]

Code generated by the continuation, along with the code added to divert vars to the compiled program

Do the actual insertion of diverted variables back to the compiled program.

compileDivertedVars :: String -> Env -> [LispVal] -> CompOpts -> IOThrowsError HaskASTSource

Take a list of variables diverted into env at compile time, and divert them into the env at runtime

compileApply :: Env -> LispVal -> CompOpts -> IOThrowsError [HaskAST]Source

Compiles each argument to a function call, and then uses apply to call the function