[Haskell-beginners] Various style at instance of a typeclass

Haisheng Wu freizl at gmail.com
Wed Jun 29 16:05:29 CEST 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110629/9dd09295/attachment.htm>


More information about the Beginners mailing list