I'm playing with some lambda calculus stuff in Haskell, specifically church numerals. I have the following defined:
let zero = (\f z -> z)
let one = (\f z -> f z)
let two = (\f z -> f (f z))
let iszero = (\n -> n (\x -> (\x y -> y)) (\x y -> x))
let mult = (\m n -> (\s z -> m (\x -> n s x) z))
This works:
:t (\n -> (iszero n) one (mult one one))
This fails with an occurs check:
:t (\n -> (iszero n) one (mult n one))
I have played with iszero
and mult
with my constants and they seem to be correct. Is there some way to make this typeable? I didn't think what I was doing was too crazy, but maybe I'm doing something wrong?