[Haskell-beginners] different function implementations for different values of typevar - is it possible?

Stephen Tetley stephen.tetley at gmail.com
Sat Jan 23 17:11:50 EST 2010


Hi Sergey

Are you sure you always want return to write as well?

'return' for the standard'  MTL writer monad produces _a_  within the
monad, but does no "writing":

instance (Monoid w) => Monad (Writer w) where
    return a = Writer (a, mempty)
    m >>= k  = Writer $ let
        (a, w)  = runWriter m
        (b, w') = runWriter (k a)
        in (b, w `mappend` w')

Text.XHtml.Transitional has the noHtml function which would be the
analogue to mempty.

Best wishes

Stephen


More information about the Beginners mailing list