never executed always true always false
1 module HelVM.HelMA.Automata.LazyK.Reducer
2 ( apply
3 , flippedApply
4 , reduce
5 ) where
6
7 import HelVM.HelMA.Automata.LazyK.Lambda
8
9 reduce ∷ Lambda → Lambda
10 reduce (App x y) = reduce x `apply` reduce y
11 reduce x = x
12
13 flippedApply ∷ Lambda → Lambda → Lambda
14 flippedApply = flip apply
15
16 apply ∷ Lambda → Lambda → Lambda
17 apply (S `App` x `App` y) z = apply x z `apply` apply y z
18 apply (App K x) _ = x
19 apply I x = x
20 apply Succ (Number x) = Number $! x + 1
21 apply Succ x = error $ "attempted to apply inc to a non-number " <> show x
22 apply f x = App f x