type Func a = a -> a
type ChurchNum a = Func a -> Func a
churchZero :: ChurchNum a
churchZero = \x -> id
churchSucc :: ChurchNum a -> ChurchNum a
churchSucc n = \f -> f . (n f)
--怎么写?
--churchPred :: ChurchNum a -> ChurchNum a
--churchPred n f x = n (\g h -> h (g f)) (const x) id
church_10 = foldl (\x y -> y x) churchZero $replicate 10 churchSucc
main = print $(church_10 (+1)) 0 -- 10
--print $((churchPred church_10) (+1)) 0 -- 9
type ChurchNum a = Func a -> Func a
churchZero :: ChurchNum a
churchZero = \x -> id
churchSucc :: ChurchNum a -> ChurchNum a
churchSucc n = \f -> f . (n f)
--怎么写?
--churchPred :: ChurchNum a -> ChurchNum a
--churchPred n f x = n (\g h -> h (g f)) (const x) id
church_10 = foldl (\x y -> y x) churchZero $replicate 10 churchSucc
main = print $(church_10 (+1)) 0 -- 10
--print $((churchPred church_10) (+1)) 0 -- 9