以下代码旨在将布尔值的 Church 编码打印为 Haskell's Bool
:
{-#LANGUAGE FlexibleInstances #-}
instance Show (t -> t -> t) where
show b = show $ b True False
这导致了这个错误:
<interactive>:4:21: error:
• Couldn't match expected type ‘t’ with actual type ‘Bool’
‘t’ is a rigid type variable bound by
the instance declaration at <interactive>:3:10-27
• In the first argument of ‘b’, namely ‘True’
In the second argument of ‘($)’, namely ‘b True False’
In the expression: show $ b True False
• Relevant bindings include
b :: t -> t -> t (bound at <interactive>:4:8)
show :: (t -> t -> t) -> String (bound at <interactive>:4:3)
如何让它发挥作用?