
29 Jun
2011
29 Jun
'11
10:05 a.m.
The Control.Monad.Writer module exports the Writer w a type along with its Monad instance newtype Writer w a = Writer { runWriter :: (a, w) } instance (Monoid w) => Monad (Writer w) where return x = Writer (x, mempty) (Writer (x,v)) >>= f = let (Writer (y, v')) = f x in Writer (y, v `mappend` v') My question is Why the signature is "Monad (Write w)" but neither "Monad Write" nor "Monad (Write w a)"? Any difference among those three styles? Thanks a lot! -Haisheng