dmgolubovsky / yhc

Automatically exported from code.google.com/p/yhc
0 stars 0 forks source link

`seq` has wrong precedence #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Run this program:
$ cat Main.hs 
main = print $ 1 + 2 `seq` 4
$ yhc Main
Compiling Main             ( Main.hs )
$ yhi Main
5
$ 

What is the expected output? What do you see instead?

I would expect to see 4 instead of 5. Others agree:

$ runhugs Main
4
$ runghc Main
4
$ 

Please use labels and text to provide additional information.

The Haskell 98 report, chapter 8, Standard Prelude, page 104 says:

  infixr 0 $, $!, `seq`

so 1+2`seq`4 should be interpreted as (1+2)`seq`4, not 1+(2`seq`4).

Original issue reported on code.google.com by thorkiln...@gmail.com on 27 Jul 2007 at 7:08

GoogleCodeExporter commented 9 years ago
I forgot to add my thanks to Ian: 
http://www.haskell.org/pipermail/yhc/2007-July/
001032.html.

Original comment by thorkiln...@gmail.com on 28 Jul 2007 at 10:03