Proposal: merge either into transformers

Roman Cheplyaka roma at ro-che.info
Sat Apr 26 20:29:01 UTC 2014


* Ross Paterson <R.Paterson at city.ac.uk> [2014-04-26 19:57:54+0100]
> On Sat, Apr 26, 2014 at 09:12:12PM +0300, Michael Snoyman wrote:
> > I think it's worth resurrecting Gabriel's proposed modification to have the
> > strict writer transformer exposed as an abstract type, built on top of StateT
> > (or using the same implementation as StateT). I've been bitten by the laziness
> > of strict Writer in the past, and thanks to Gabriel's email, I knew how to
> > solve the problem. But I think many people will be misled by the name,
> > documentation improvements notwithstanding.
> 
> Indeed it's a trap.  But an abstract type would be less transparent than
> the other transformers, and would be incompatible with the lazy WriterT
> in subtle ways.
> 
> How about just deprecating strict WriterT in favour of strict StateT?

I don't understand the issue here. Why does it have to be abstract or
based on StateT?

We could simply make a new module with the same WriterT type and the instance

  instance (Monoid w, Monad m) => Monad (WriterT w m) where
    m >>= k  = WriterT $ do
      (a, w)  <- runWriterT m
      (b, w') <- runWriterT (k a)
      let w'' = w `mappend` w'
      w'' `seq` return (b, w'')

I'll leave it up to others to bikeshed the name of such a module (or maybe we
should simply replace the current Writer.Strict?)

Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140426/ac9263c6/attachment.sig>


More information about the Libraries mailing list