Skip to content

Instantly share code, notes, and snippets.

@stelleg
Last active October 26, 2017 21:33
Show Gist options
  • Save stelleg/3900592354b5dea0606b to your computer and use it in GitHub Desktop.
Save stelleg/3900592354b5dea0606b to your computer and use it in GitHub Desktop.
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')
@stelleg
Copy link
Author

stelleg commented Mar 25, 2015

That's embarrassing! Thanks for catching that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment