I'm following a guide on Wikipedia on how to deal with church literals. As per article there is a Haskell snippet:
Link to Wiki Here
type Church a = (a -> a) -> a -> a
church :: Integer -> Church Integer
church 0 = \f -> \x -> x
church n = \f -> \x -> f (church (n-1) f x)
unchurch :: Church Integer -> Integer
unchurch cn = cn (+ 1) 0
However when I try to run it through GHCI I get following error :
main.hs:3:15: error:
* Expecting one more argument to `Church'
Expected a type, but `Church' has kind `* -> *'
* In the first argument of `Show', namely `Church'
In the instance declaration for `Show Church'
|
3 | instance Show Church where
I've tried to use deriving show
on the type and also
instance Show Church Integer where
show = church
And unfortunately, both produced more errors. I'm not sure what does Church Integer
mean in the function declaration or if that is the part why I cannot derive show?
How can I make this function print?
instance Show (Church Integer) where
? – user253751