Strictness problem

Nils Anders Danielsson nad at cs.chalmers.se
Thu Nov 13 12:05:08 EST 2003


The following program should, if I'm not completely mistaken, output
something involving Correct:

> module Main where

> f x = case x of
>   x at True -> \y -> x && y
>   x at False -> \y -> x && y

> main = putStrLn $ f (error "Correct") `seq` "Error"

However, whether it does so is a complicated function of the GHC version
and optimisation settings:

GHC version  -O2?  Correct?
---------------------------
4.08.1       No    Yes
4.08.1       Yes   No
5.04.2       No    No
5.04.2       Yes   Yes
6.0.1        _     No
Recent CVS   No    No
Recent CVS   Yes   Yes

(Hugs              Yes)

All tests were run on a Solaris system, except for the CVS one (which I
don't have access to, so I don't know the exact date of checkout).

Different fs give different behaviour, at least for 6.0.1. Try e.g.

> f x = case x of
>   True -> id
>   False -> id

with and without -O2.

/NAD


More information about the Glasgow-haskell-bugs mailing list