Control.Monad.Writer.Strict .... enough?

Ben Moseley ben_moseley at
Thu Jan 15 14:48:07 EST 2009


In most of the 'mtl' variants on Hackage (with the notable exception  
of 'monadLib'), the Control.Monad.Writer.Strict main instance is:

newtype Writer w a = Writer { runWriter :: (a, w) }

instance (Monoid w) => Monad (Writer w) where
     return a = Writer (a, mempty)
     m >>= k  = Writer $ case runWriter m of
                             (a, w) -> case runWriter (k a) of
                                 (b, w') -> (b, w `mappend` w') the `mappend` is hidden inside a lazy "(,)" constructor.

...shouldn't the bind really be strict in the written monoid?  (eg by  
replacing "(a,w)" with "(a,!w)" and using Bang Patterns).

...if so, is it worth submitting patch?


More information about the Libraries mailing list