epic

Epic.Language

Synopsis

- data CompileOptions
  - = KeepC
  - | Trace
  - | ShowBytecode
  - | ShowParseTree
  - | MakeHeader FilePath
  - | GCCOpt String
  - | Debug
  - | Checking Int
  - | ExternalMain
  - | MainInc FilePath
  - | LinkObj FilePath
- data Type
  - = TyInt
  - | TyChar
  - | TyBool
  - | TyFloat
  - | TyBigInt
  - | TyBigFloat
  - | TyString
  - | TyPtr
  - | TyUnit
  - | TyAny
  - | TyData
  - | TyCType String
  - | TyFun
  - | TyLin Type
  - | TyEval Type
- data Const
  - = MkInt Int
  - | MkBigInt Integer
  - | MkChar Char
  - | MkFloat Double
  - | MkBigFloat Double
  - | MkString String
  - | MkBool Bool
  - | MkUnit
  - | MkUnused
- data Name
  - = UN String
  - | MN String Int
- type Context = [(Name, ([Type], Type))]
- type Tag = Int
- type HFun = Expr -> Expr
- data Expr
  - = V Int
  - | R Name
  - | App Expr [Expr]
  - | Lazy Expr
  - | Effect Expr
  - | Par Expr
  - | Con Tag [Expr]
  - | Const Const
  - | Proj Expr Int
  - | Case Expr [CaseAlt]
  - | If Expr Expr Expr
  - | While Expr Expr
  - | WhileAcc Expr Expr Expr
  - | Op Op Expr Expr
  - | Let Name Type Expr Expr
  - | LetM Name Expr Expr
  - | HLet Name Type Expr HFun
  - | Update Int Expr Expr
  - | Lam Name Type Expr
  - | HLam Name Type HFun
  - | Error String
  - | Impossible
  - | WithMem Allocator Expr Expr
  - | ForeignCall Type String [(Expr, Type)]
  - | LazyForeignCall Type String [(Expr, Type)]
- data CaseAlt
  - = Alt {
    - alt_tag :: Tag
    - alt_args :: [(Name, Type)]
    - alt_expr :: Expr
    }
  - | HAlt {
    - alt_tag :: Tag
    - alt_numargs :: Int
    - alt_binds :: HRHS
    }
  - | ConstAlt {
    - alt_const :: Int
    - alt_expr :: Expr
    }
  - | DefaultCase {
    - alt_expr :: Expr
    }
- data HRHS
  - = HExp Expr
  - | HBind Name Type (Expr -> HRHS)
- data Allocator
  - = FixedPool
  - | GrowablePool
- data Op
  - = Plus
  - | Minus
  - | Times
  - | Divide
  - | Modulo
  - | OpEQ
  - | OpLT
  - | OpLE
  - | OpGT
  - | OpGE
  - | FPlus
  - | FMinus
  - | FTimes
  - | FDivide
  - | OpFEQ
  - | OpFLT
  - | OpFLE
  - | OpFGT
  - | OpFGE
  - | ShL
  - | ShR
- data Func = Bind {
  - fun_args :: [(Name, Type)]
  - locals :: Int
  - defn :: Expr
  - flags :: [CGFlag]
  }
- data Decl
  - = Decl {
    - fname :: Name
    - frettype :: Type
    - fdef :: Func
    - fexport :: Maybe String
    - fcompflags :: [CGFlag]
    }
  - | Extern {
    - fname :: Name
    - frettype :: Type
    - fargs :: [Type]
    }
  - | Include String
  - | Link String
  - | CType String
- data EvalDecl
  - = EDecl {
    - ename :: Name
    - edef :: Expr
    }
  - | EDirective
- class SubstV x where
  - subst :: Int -> Expr -> x -> x
- class HOAS a b | a -> b where
  - hoas :: Int -> a -> b
  - mkHOAS :: a -> b
- data CGFlag
  - = Inline
  - | Strict
- data Result r
  - = Success r
  - | Failure String String Int
- appForm :: Expr -> Bool
- checkLevel :: [CompileOptions] -> Int
- tempfile :: IO (FilePath, Handle)
- environment :: String -> IO (Maybe String)

# Documentation

data CompileOptions

(Debugging) options to give to compiler

Constructors

KeepC | Keep intermediate C file
Trace | Generate trace at run-time (debug)
ShowBytecode | Show generated code
ShowParseTree | Show parse tree
MakeHeader FilePath | Output a .h file too
GCCOpt String | Extra GCC option
Debug | Generate debug info
Checking Int | Checking level (0 none)
ExternalMain | main is defined externally (in C)
MainInc FilePath | File to #include in main program
LinkObj FilePath | .o file to link with

Instances

Eq CompileOptions |

data Type

Constructors

TyInt |
TyChar |
TyBool |
TyFloat |
TyBigInt |
TyBigFloat |
TyString |
TyPtr |
TyUnit |
TyAny |
TyData |
TyCType String |
TyFun |
TyLin Type |
TyEval Type |

Instances

Eq Type |
Show Type |
SubstV (Expr, Type) |
RtoV a => RtoV (a, Type) |
Quote a => Quote (a, Type) |
HOAS a a => HOAS (a, Type) (a, Type) |

data Const

Constructors

MkInt Int |
MkBigInt Integer |
MkChar Char |
MkFloat Double |
MkBigFloat Double |
MkString String |
MkBool Bool |
MkUnit |
MkUnused |

Instances

Eq Const |
Show Const |

data Name

Constructors

UN String |
MN String Int |

Instances

Eq Name |
Show Name |

type Context = [(Name, ([Type], Type))]

type Tag = Int

type HFun = Expr -> Expr

data Expr

Constructors

V Int |
R Name |
App Expr [Expr] |
Lazy Expr |
Effect Expr |
Par Expr |
Con Tag [Expr] |
Const Const |
Proj Expr Int |
Case Expr [CaseAlt] |
If Expr Expr Expr |
While Expr Expr |
WhileAcc Expr Expr Expr |
Op Op Expr Expr |
Let Name Type Expr Expr |
LetM Name Expr Expr |
HLet Name Type Expr HFun |
Update Int Expr Expr |
Lam Name Type Expr |
HLam Name Type HFun |
Error String |
Impossible |
WithMem Allocator Expr Expr |
ForeignCall Type String [(Expr, Type)] |
LazyForeignCall Type String [(Expr, Type)] |

Instances

Eq Expr |
Show Expr |
SubstV Expr |
RtoV Expr |
Quote Expr |
HOAS Func Expr |
HOAS Expr Expr |
Eq (Expr -> HRHS) |
Eq (Expr -> Expr) |
SubstV (Expr, Type) |

data CaseAlt

Constructors

Alt |

Fields

alt_tag :: Tag
alt_args :: [(Name, Type)]
alt_expr :: Expr

HAlt |

Fields

alt_tag :: Tag
alt_numargs :: Int
alt_binds :: HRHS

ConstAlt |

Fields

alt_const :: Int
alt_expr :: Expr

DefaultCase |

Fields

alt_expr :: Expr

Instances

Eq CaseAlt |
Ord CaseAlt |
Show CaseAlt |
SubstV CaseAlt |
RtoV CaseAlt |
Quote CaseAlt |
HOAS CaseAlt CaseAlt |

data HRHS

Constructors

HExp Expr |
HBind Name Type (Expr -> HRHS) |

Instances

Eq HRHS |
Eq (Expr -> HRHS) |

data Allocator

Constructors

FixedPool |
GrowablePool |

Instances

Eq Allocator |
Show Allocator |

data Op

Constructors

Plus |
Minus |
Times |
Divide |
Modulo |
OpEQ |
OpLT |
OpLE |
OpGT |
OpGE |
FPlus |
FMinus |
FTimes |
FDivide |
OpFEQ |
OpFLT |
OpFLE |
OpFGT |
OpFGE |
ShL |
ShR |

Instances

Eq Op |
Show Op |

data Func

Constructors

Bind |

Fields

fun_args :: [(Name, Type)]
locals :: Int
defn :: Expr
flags :: [CGFlag]

Instances

Show Func |
RtoV Func |
HOAS Func Expr |

data Decl

Constructors

Decl |

Fields

fname :: Name
frettype :: Type
fdef :: Func
fexport :: Maybe String
fcompflags :: [CGFlag]

Extern |

Fields

fname :: Name
frettype :: Type
fargs :: [Type]

Include String |
Link String |
CType String |

Instances

Show Decl |

data EvalDecl

Constructors

EDecl |

Fields

ename :: Name
edef :: Expr

EDirective |

class SubstV x where

Methods

subst :: Int -> Expr -> x -> x

Instances

SubstV CaseAlt |
SubstV Expr |
SubstV a => SubstV [a] |
SubstV (Expr, Type) |

class HOAS a b | a -> b where

Methods

hoas :: Int -> a -> b

mkHOAS :: a -> b

Instances

HOAS Func Expr |
HOAS CaseAlt CaseAlt |
HOAS Expr Expr |
HOAS a a => HOAS [a] [a] |
HOAS a a => HOAS (a, Type) (a, Type) |

data CGFlag

Constructors

Inline |
Strict |

Instances

Eq CGFlag |
Show CGFlag |

data Result r

Constructors

Success r |
Failure String String Int |

Instances

Monad Result |
MonadPlus Result |
Eq r => Eq (Result r) |
Show r => Show (Result r) |

appForm :: Expr -> Bool

checkLevel :: [CompileOptions] -> Int

tempfile :: IO (FilePath, Handle)

environment :: String -> IO (Maybe String)