Skip to content

Instantly share code, notes, and snippets.

@Solonarv
Last active October 31, 2018 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Solonarv/2dd9edc4a496d439bab44d1a06d0a42b to your computer and use it in GitHub Desktop.
Save Solonarv/2dd9edc4a496d439bab44d1a06d0a42b to your computer and use it in GitHub Desktop.
module SKI where
data SKI = S | K | I | A SKI SKI
deriving (Eq, Show)
reduce :: SKI -> SKI
reduce (A (A (A S x) y) z) = reduce (A (A x z) (A y z))
reduce (A (A K x) y) = reduce y
reduce (A I x) = reduce x
reduce a@(A f x) = let f' = reduce f in if f==f' then a else reduce (A f' x)
reduce a = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment