logo       

Strictness problem: msg#00033

lang.haskell.glasgow.bugs

Subject: Strictness problem

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

> module Main where

> f x = case x of
> x@True -> \y -> x && y
> x@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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise