Last active
October 26, 2017 21:33
-
-
Save stelleg/3900592354b5dea0606b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Expr | |
import Data.Vect | |
import Data.Fin | |
data Expr : Nat -> Type where | |
Var : Fin n -> Expr n | |
Lam : Expr (S n) -> Expr n | |
App : Expr n -> Expr n -> Expr n | |
data Closure : Type where | |
Close : Expr n -> Vect n Closure -> Closure | |
k : Expr 0 -> Closure | |
k e = k' (Close e Nil, []) where | |
k' : (Closure, List Closure) -> Closure | |
k' (Close e env, s) = case e of | |
Var i => k' (index i env, s) | |
App m n => k' (Close m env, Close n env::s) | |
Lam b => case s of | |
[] => Close e env | |
(arg::s') => k' (Close b (arg::env), s') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's embarrassing! Thanks for catching that.