Proposal: merge either into transformers

Michael Snoyman michael at snoyman.com
Mon Apr 28 16:00:25 UTC 2014


On Mon, Apr 28, 2014 at 4:15 PM, Ross Paterson <R.Paterson at city.ac.uk>wrote:

> On Sun, Apr 27, 2014 at 10:47:56AM +0300, Michael Snoyman wrote:
> > On Sat, Apr 26, 2014 at 9:57 PM, Ross Paterson <R.Paterson at city.ac.uk>
> wrote:
> > > would be incompatible with the lazy WriterT in subtle ways
> >
> > That would be troubling, but I'm not sure in which ways it's
> incompatible. Do
> > you have any examples?
>
> The Applicative and Alternative instances would have different contexts,
> and
> there would be no instances for Foldable, Traversable, Eq, Ord, Read or
> Show.
>
>
If we have deprecation of the module in its entirety on the table, I think
it's acceptable to consider dropping some instances. However, I don't see
Eq, Ord, Read, or Show instances for strict WriterT in transformers 0.3.
Applicative seems like it should be identical in behavior to what we have
right now. I'm not completely certain, but it seems the same is true for
Alternative.


> > The advantage of having WriterT implemented in terms of strict StateT
> > is that many people will automatically get the fix when upgrading
> > to transformers 0.4.  Also, the writer API itself is very convenient
> > for many common use cases, so it would be nice if there was a version
> > available that didn't leak memory.
>
> Invisibly increasing strictness cuts both ways: some people get space
> savings, while others get non-termination.  (Although one might say
> they're not using it properly, that seems a harsh punishment.)  But I'm
> more concerned about the complication.  Currently the transformers are
> transparent, and people can think about the type structure of the monad
> they're building.  This very transformer is already there; it seems
> simpler to direct people to it instead of having another copy.  The API
> point is an issue, though.
>
>
Here's the question I'd ask, which I honestly don't know the answer to. We
have three proposed WriterT implementations: lazy, current-strict, and
state-strict. We have two conflicting desires: program termination and
space savings. We know there are cases where lazy allows termination where
state-strict does not. We know there are cases where state-strict allows
space savings where neither lazy nor current-strict do.

The question is: are there cases where current-strict:

1. Gives space savings that lazy does not?
2. Gives termination where state-strict does not?

I *think* the answers to these questions are "no" and "yes", meaning that
current-strict in its current form can *always* be replaced by lazy,
without losing anything. If that's the case, I'd say this is a very simple
transition in 0.4.

Note that we've been discussing all of this in terms of WriterT, but the
same exact discussion should apply to RWST.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140428/e926282e/attachment.html>


More information about the Libraries mailing list