FoldrW/buildW issues

David Feuer david.feuer at gmail.com
Wed Sep 24 20:37:59 UTC 2014


On Sep 12, 2014 2:35 PM, "Joachim Breitner" <mail at joachim-breitner.de>
wrote:
> I once experimented with a magic "oneShot :: (a -> b) -> (a -> b)"
> function, semantically the identity, but tell the compiler not to share
> the result of the computation. Using that in the definition of
> foldl-as-foldr, one can get the same effect as Call Arity, but a bit
> more reliable. I need to investigate if that solves the sumConcatInits
> problem.

One nice thing about this idea (which sounds like it must be related to the
"state hack", but is more explicit) is that it presumably applies also to
similar situations in the State and ST monads, when a state transformer is
only used once. Could you explain, perhaps, what compiler transformation
this enables, and how you implemented it? It would be nice if the compiler
could figure this out for itself, but I'm sure that's much too big a
project for 7.10, whereas making sure foldl, scanl, mapAccumL, foldM, sum,
etc., work really reliably seems important. And yes, I do think such a
thing would probably work for scanl and such, assuming GHC's analysis can
use the information properly—they're just state-transforming list producers.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140924/3fb1fa0c/attachment.html>


More information about the ghc-devs mailing list