Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

:sprint and `seq` together - missing evaluation?

I understand a `seq` b as "be strict on a and compute b", so undefined `seq` True throws and Exception.

I am playing around with :sprint and tried following test in ghci:

Prelude> x = [True, undefined]
Prelude> :sprint x
x = _

Okay, because x was not computed yet

Prelude> x `seq` True
True
Prelude> :sprint x
x = _

Why x = _ at this moment? I thought that seq will evaluate x at least to _:_ (or more possibly True:_), but its value still remains completely latent. It needs somehow check whether x is not undefined, so it needs to perform kind of evaluation, but why doesn't it keep the result?

I am using GHC 8.6.3

like image 914
radrow Avatar asked Nov 07 '22 22:11

radrow


1 Answers

Okay, I made a ticket on trac (link: https://ghc.haskell.org/trac/ghc/ticket/16089) and it seems to be a bug related to another one (https://ghc.haskell.org/trac/ghc/ticket/16096).

Problem was a result of how x = y and let x = y were treated in GHCi – the first one was interpreted as toplevel binding (with monomorphism restriction turned off by default) and the second one as let statement in do block. This issue implied some other unwanted behaviors like for example lack of shadowing warnings when -Wall was turned on. You may inspect fix for this at this thread: https://phabricator.haskell.org/D5473

like image 152
radrow Avatar answered Nov 15 '22 07:11

radrow