A function with absent demand on syntactically used argument?

Joachim Breitner mail at joachim-breitner.de
Wed Aug 3 11:54:46 UTC 2016

Am Mittwoch, den 03.08.2016, 10:10 +0000 schrieb Ömer Sinan Ağacan:
> I'm reading the code in WwLib that generates worker functions and I'm confused
> about absent lets. Can anyone give an example function that has absent demand
> >  its argument even though the argument is syntactically used in the body?

here is a simple example:

printFst :: (a,b) -> IO () -- <U(U,A)>
printFst (a,b) = print a

callPrintFirst :: b -> IO () -- <A>
callPrintFirst b = printFst ("see it?", b)

> > I think we should add some examples to `Note [Absent errors]` in WwLib.hs.

*shrug* Not sure if it is worth it.

> One example came to my mind was something like
>     f x = ... undefined x ...
> I'm guessing that if we were to generate a worker for this, we'd need to
> generate an absent let for x in the worker function. But "undefined" has a
> weird (polymorphic over both function and non-function types) type and I don't
> know what's the demand signature of it (maybe we should document this too), so
> I'm not sure.

undefined as signature "b", indicating „even if given no arguments, I
will bottom out“. The demand analyzer treats that as „<L,U>b“ if
necessary, i.e. if undefined is applied to an argument.


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/20160803/e341f42f/attachment.sig>

More information about the ghc-devs mailing list