Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Programs That Eat Programs

Programs That Eat Programs

Software GR Feb 24, 2015

Michael Bernstein

February 24, 2015
Tweet

More Decks by Michael Bernstein

Other Decks in Technology

Transcript

  1. Programs That Eat Programs Michael R. Bernstein February 24th, 2015

    Software GR, Grand Rapids, MI w michaelrbernste.in t @mrb_bk
  2. type Σ = (Exp,Env,Store,Kont) type Env = Var :-> Addr

    data Storable = Clo (Lambda, Env) type Store = Addr :-> Storable data Kont = Mt | Ar (Exp,Env,Kont) | Fn (Lambda,Env,Kont) type Addr = Int
  3. step :: Σ -> Σ step (Ref x, ρ, σ,

    κ) = (Lam lam, ρ', σ, κ) where Clo (lam, ρ') = σ!(ρ!x) step (f :@ e, ρ, σ, κ) = (f, ρ, σ, Ar(e, ρ, κ)) step (Lam lam,ρ,σ,Ar(e, ρ', κ)) = (e, ρ', σ, Fn(lam, ρ, κ)) step (Lam lam,ρ,σ,Fn(x :=> e, ρ', κ)) = (e, ρ' // [x ==> a'], σ // [a' ==> Clo (lam, ρ)], κ) where a' = alloc(σ)