FoldrW/buildW issues

David Feuer david.feuer at
Sun Sep 14 17:03:06 UTC 2014

Joachim Breitner wrote:

> Am Samstag, den 13.09.2014, 00:01 -0400 schrieb David Feuer:
> > On Sep 12, 2014 2:35 PM, "Joachim Breitner" <mail at>
> > wrote:
> > > Interesting. I assumed that some wrap.unwrap=id law would hold, or
> > at
> > > least some moral approximation (e.g. disregarding bottoms in an
> > > acceptable manner). But if the wrappers have to do arbitrary stuff
> > that
> > > can arbitrarily interact with how the producer calls them, this
> > becomes
> > > a bit less appealing.
> >
> > No, nothing pleasant like that, I'm afraid. isoSimple is like that of
> > course, but once it gets to foldl, the fusion rule is handing the
> > builder a wrap/unwrap pair that isn't even close to that.
> and parametricity doesn't help here? Note that due to the forall in the
> type of buildW, you can probably reason about what kind of values buildW
> can produce, as it can only use whatever the consumer handed to it.
> Maybe there is an invariant for that type, and the worker/wrapper pair
> is the identity for values that fulfill that invariant.

That seems reasonable, and I suspect without any proof that Takano Akio's
wrapper for foldl and Dan Doel's wrapper for reverse probably satisfy it.
Scans seem to be more of a challenge. It appears to me that Dan's scanl
wrapper probably does *not* satisfy that requirement, and I don't know
enough to have much chance of finding one that does.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list