slight difference in strictness between -O0 and -O

Kirsten Chevalier catamorphism at
Tue Mar 13 06:02:31 EDT 2007

On 3/13/07, Kirsten Chevalier <catamorphism at> wrote:
> I noticed that compiling with -O -frules-off causes the test program
> here to correctly print out "x". So, I was looking at the "take" rule
> in GHC/List.lhs. Doesn't this rule change the strictness of take?
> "take"     [~1] forall n xs . take n xs = case n of I# n# -> build (\c
> nil -> foldr (takeFB c nil) (takeConst nil) xs n#)

I may be talking to myself here, but what I mean is:

> take 1 (1:undefined)
> build (\ c nil -> foldr (takeFB c nil) (takeConst nil) (1:undefined) 1#)
[1*** Exception: Prelude.undefined

(where takeFB and takeConst are defined as they are in GHC/List.lhs)

So that rule doesn't seem to be quite right.


Kirsten Chevalier* chevalier at *Often in error, never in doubt
"80% of success is showing up."--Woody Allen

More information about the Glasgow-haskell-users mailing list