An experimental language with algebraic effects
- To build this project you will need
stack- haskell package manager - Build and install with
stack install- it should copy executable to~/.local/bin - Run tests with
stack test
- To eval source files
filesrunaleph-exe eval <files> - To only check types run
aleph-exe check <files>
toplevel ::= let <identifier> = <value>
| run <expression>
| eff <type-lit> = <operations>
operations ::= { <identifier> : type-lit => type-lit ; }+
type-lit ::= Unit | Int | Bool | List // List is a monomorphic list of ints
value ::= fn <identifier> -> <expression>
| <literal>
| <variable>
literal ::= <int> | true | false | ()
expression ::= <expression> <expressiom>
| <value>
| handle <type-lit> in <expression> with {<handlers>}*
| lift <type-lit> in ( expression )
| <variable> <- <expression> , <expression>
| if <expression> then <expression> else <expression> end
handlers ::= { <identifier> <identifier> , <identifier> -> expression ;}*
| { return <identifier> -> expression ; }
add : Int -> a Int -> b Intsub : Int -> a Int -> b Intmul : Int -> a Int -> b Intdiv : Int -> a Int -> b IntisZero : Int -> a Bool
cons : Int -> a List -> b Listnil : Listhead : List -> a Inttail : List -> a Listnull : List -> a Bool- these operations are not safe, but one could define effect
EXand wrap them
IOprint : Int -> [IO | a] Unit
- operation and effect names must be unique
- operations have functional type with effect to which they belong
- operation's behaviour is defined by its handler, handlers are deep
- This module defines syntax, parser and lexer of the language, all important functionality is exported from
src/Syntax.hs
- This module implements type inference for the program, file
src/Inference.hsexports function wich deducts typing environment for a program (list of toplevel clauses) - file
src/Inference/Infer.hscontains functions wich generate typing constraints - file
src/Inference/Solve.hscontains functions which solve these constraints by unification
- This module implements evaluation of program, file 'src/Evaluation.hs
exports functioneval` which evaluates program - Evaluation uses a stack of continuations contained in
Ctx