Skip to content

Instantly share code, notes, and snippets.

@evanrinehart
Last active June 25, 2017 00:10
Show Gist options
  • Save evanrinehart/78a9170fba48521e3fe1c470a2e913da to your computer and use it in GitHub Desktop.
Save evanrinehart/78a9170fba48521e3fe1c470a2e913da to your computer and use it in GitHub Desktop.
data E = S | K | App E E
-- big step reduction, eager, may not terminate
reduce :: E -> E
reduce (App (App K x) y) = reduce x
reduce (App (App (App S x) y) z) =
let a = reduce x in
let b = reduce y in
let c = reduce z in
reduce (App (App a c) (App b c))
reduce (App x y) = reduce (App (reduce x) (reduce y))
reduce other = other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment