Skip to content

Instantly share code, notes, and snippets.

@nitrix
Forked from Solonarv/SKI.hs
Created October 31, 2018 20:55
Show Gist options
  • Save nitrix/d63fca1e94a3fd4bfff3019d0cb29241 to your computer and use it in GitHub Desktop.
Save nitrix/d63fca1e94a3fd4bfff3019d0cb29241 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