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
  [email protected]http://www.joachim-breitner.de/
  Jabber: [email protected]  • GPG-Key: 0xF0FBF51F
  Debian Developer: [email protected]

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
ghc-devs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to