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

Portabilityportable
Stabilityexperimental
Maintainergithub.com/justinethier
Safe HaskellNone

Language.Scheme.Compiler.Types

Contents

Description

This module contains data types used by the compiler.

Synopsis

Data types

data CompOpts

A type to store options passed to compile. Eventually all of this might be able to be integrated into a Compile monad.

Constructors

CompileOptions 

Fields

coptsThisFunc :: String

Immediate name to use when creating a compiled function. Presumably there is other code that is expecting to call into it.

coptsThisFuncUseValue :: Bool

Whether to include the value parameter in the current function

coptsThisFuncUseArgs :: Bool

Whether to include the args parameter in the current function

coptsNextFunc :: Maybe String

The name to use for the next function after the current compiler recursion is finished. For example, after compiling a block of code, the control flow would be expected to go to this function.

data CompLibOpts

Options passed to the compiler library module

Constructors

CompileLibraryOptions 

Fields

compBlock :: String -> Maybe String -> Env -> [HaskAST] -> [LispVal] -> IOThrowsError [HaskAST]
 
compLisp :: Env -> String -> String -> Maybe String -> IOThrowsError [HaskAST]
 

defaultCompileOptions :: String -> CompOpts

The default compiler options

data HaskAST

A very basic type to store a Haskell AST.

Constructors

AstAssignM String HaskAST 
AstFunction 

Fields

astfName :: String
 
astfArgs :: String
 
astfCode :: [HaskAST]
 
AstValue String 
AstRef String 
AstContinuation 

Fields

astcNext :: String
 
astcArgs :: String
 

Instances

Show HaskAST 

Utility functions

ast2Str :: LispVal -> String

Convert abstract syntax tree to a string

asts2Str :: [LispVal] -> String

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

createAstFunc

Arguments

:: CompOpts

Compilation options

-> [HaskAST]

Body of the function

-> HaskAST

Complete function code

Create code for a function

createAstCont

Arguments

:: CompOpts

Compilation options

-> String

Value to send to the continuation

-> String

Extra leading indentation (or blank string if none)

-> HaskAST

Generated code

Create code for a continutation

joinL

Arguments

:: forall a .  
=> [[a]]

Original list-of-lists

-> [a]

Separator

-> [a]

Joined list

A utility function to join list members together

moduleRuntimeVar :: String

Runtime reference to module data structure

showValAST :: HaskAST -> String

Generate code based on the given Haskell AST

Headers appended to output file

header :: String -> Bool -> String -> [String]

Block of code used in the header of a Haskell program generated by the compiler.

headerComment :: [String]

Header comment used at the top of a Haskell program generated by the compiler

headerModule :: [String]

Main module used in a compiled Haskell program

headerImports :: [String]

Imports used for a compiled program