An implementation of System F in Haskell
systemf
is an implementation of System F presented by Benjamin C. Pierce in his Types and Programming Languages. I transliterated the original source code written in OCaml into Haskell except for the parser which I rewrote in Parsec.
- Variables:
x
- Applications:
x x
- Lambda abstractions:
\x.x
- Type abstractions:
/\X.X
- Conditional:
if x then y else z
- Booleans:
true
,false
- Universal quantification:
All X.X->X
- Existential quantification :
{*All Y.Y, \x:(All Y.Y). x} as {Some X,X->X}
- The representation of a variable is a number - its De Brujin index
- Evaluation performs substitution
systemfi
is a REPL where you can input a lambda calculus term.
% \x:Bool.x
(\x:Bool.x)
$ {*All Y.Y, \x:(All Y.Y). x} as {Some X,X->X}
(\x:(All X.(X->X)).x)