FoldrW/buildW issues
Joachim Breitner
mail at joachim-breitner.de
Wed Sep 24 20:56:30 UTC 2014
Hi,
Am Mittwoch, den 24.09.2014, 16:37 -0400 schrieb David Feuer:
> 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?
I guess it is used in various places, and I woudn’t know all of them.
The one that I was aiming for was is this one
case x of
True -> z
False -> \s(one-shot). e
to
\s(one-shot) . case x of
True -> z s
False -> e
explained in Note [Combining case branches] at
https://github.com/ghc/ghc/blob/master/compiler/coreSyn/CoreArity.lhs#L671
The implementation is attached to my previous mail.
> It would be nice if the compiler could figure this out for itself,
Well, that’s what I thought, and CallArity is what I came up with :-)
Greetings,
Joachim
--
Joachim “nomeata” Breitner
mail at joachim-breitner.de • http://www.joachim-breitner.de/
Jabber: nomeata at joachim-breitner.de • GPG-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140924/9c68570e/attachment.sig>
More information about the ghc-devs
mailing list