Question about BangPatterns semantics/documentation
Joachim Breitner
mail at joachim-breitner.de
Sun Aug 3 14:41:13 UTC 2014
Hi Herbert,
Am Sonntag, den 03.08.2014, 11:31 +0200 schrieb Herbert Valerio Riedel:
> However, the following two functions are not equivalent after
> compilation to Core:
>
> g, h :: (Int -> Int) -> Int -> ()
> g f x = let !y = f x in ()
> h f x = case f x of y -> ()
>
> In fact, compilation results in
>
> g = \ (f_asi :: Int -> Int)
> (x_asj :: Int) ->
> case f_asi x_asj of _ [Occ=Dead] { I# ipv_sKS -> () }
>
> h = \ _ [Occ=Dead] _ [Occ=Dead] -> ()
>
> Is the documentation inaccurate/incomplete/I-missed-something or is the
> implementation to blame?
I think that in Haskell (which is not Core!), a "case" does not imply
evaluation – only if the patterns require it. So the example in the docs
is correct (case e of [x,y] -> b requires evaluation of e), but your
example is simply optimized away.
haskell.org is down, so I can’t check if the report has anything to say
about that.
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/20140803/739ae12b/attachment.sig>
More information about the ghc-devs
mailing list