X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=code%2Fski_evaluator.hs;h=26f1c0e640da32ae8df729f60b897e91d0303056;hp=845d6dad8bd17ac613d13b2b30b50bce8ecc81a6;hb=ff5b3f5a76fb744b332bc5d0fb3ef5632ce02879;hpb=73f8e125d9910c93213d357c2779cc743fa22e8b diff --git a/code/ski_evaluator.hs b/code/ski_evaluator.hs index 845d6dad..26f1c0e6 100644 --- a/code/ski_evaluator.hs +++ b/code/ski_evaluator.hs @@ -1,13 +1,13 @@ -data Term = I | S | K | FA Term Term deriving (Eq, Show) +data Term = I | S | K | App Term Term deriving (Eq, Show) -skomega = (FA (FA (FA S I) I) (FA (FA S I) I)) -test = (FA (FA K I) skomega) +skomega = (App (App (App S I) I) (App (App S I) I)) +test = (App (App K I) skomega) reduce_one_step :: Term -> Term reduce_one_step t = case t of - FA I a -> a - FA (FA K a) b -> a - FA (FA (FA S a) b) c -> FA (FA a c) (FA b c) + App I a -> a + App (App K a) b -> a + App (App (App S a) b) c -> App (App a c) (App b c) _ -> t is_redex :: Term -> Bool @@ -18,7 +18,7 @@ reduce t = case t of I -> I K -> K S -> S - FA a b -> - let t' = FA (reduce a) (reduce b) in + App a b -> + let t' = App (reduce a) (reduce b) in if (is_redex t') then reduce (reduce_one_step t') else t'