关于monad的Haskell类型推断

时间:2016-03-12 02:07:22

标签: haskell types monads

如何从Control.Monad.liftM notControl.Monad.liftM not id的类型进行类型推断?

(Control.Monad.liftM not) :: Monad m => m Bool -> m Bool

(Control.Monad.liftM not id) :: Bool -> Bool

1 个答案:

答案 0 :(得分:4)

liftM not    :: Monad m =>                 m Bool -> m Bool
id           ::                            a -> a
liftM not id :: (Monad m, m ~ ((->) a), a ~ Bool) => m Bool
           {- therefore -}                           Bool -> Bool