Generalising the demand analysis to sum types

Joachim Breitner mail at joachim-breitner.de
Sun Feb 21 23:26:13 UTC 2016


Hi,

Am Samstag, den 20.02.2016, 18:01 -0500 schrieb José Manuel Calderón
Trilla:
> The way I see it, the information would allow us to automatically
> unbox the arguments to constructors in sum types.

Well, unboxed sums asides, how can you unbox the argument to Just?
"Just" necessary takes a boxed argument...

Can you show some example code of a function that is strict in the way
you envision, and show how the worker and the wrapper look like?

> Combining this with the unboxed sums work, the idea is to be able to
> not only unbox the sum, but the fields of a constructor when possible,
> removing as many indirections as possible.

Yes, with unboxed sums there might be something to gain, i.e. replacing
"Maybe Int" with "(# Int# | (##) #)" or whatever.

But even then it is not clear: The function likely scrutinizes the
argument, i.e. we have a branch, both before and after the
transformation. But the wrapper _also_ needs to case-analyze the
argument, to create the unboxed sum variant... and I worry that the
wrapper will be optimized away very often.

But a good example might convince me :-)


Greetings,
Joachim
-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttps://www.joachim-breitner.de/
  XMPP: nomeata at joachim-breitner.de • OpenPGP-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://mail.haskell.org/pipermail/ghc-devs/attachments/20160222/ebb81e6a/attachment.sig>


More information about the ghc-devs mailing list