State monads don't respect the monad laws in Haskell

Iavor S. Diatchki diatchki@cse.ogi.edu
Tue, 14 May 2002 15:20:04 -0700


hello,

this is misleading. seq only evaluates to whnf, i.e.
the outermost lazy constructor (or lambda) and that only if the
"seq ..." expression is actually evaluated, which is often tricky to 
ensure.  furthermore, for non-functions one can get the same behaviour,
by using a case with a pattern.

here is why i think the example does not illustrate what is seq good for:

 >>main::IO()
 >>main=do
 >>     time1 <- getCPUTime
 >>     w     <- return $! map undefined [1..]
 >>     time2 <- getCPUTime
 >      ....

the above computation does not take very long.

bye
iavor


Jorge Adriano wrote:
>>One may ask the question: what is seq useful for not in conjunction with
>>unsafePerformIO, other than efficiency.  That, I don't know the answer to.
> 
> 
> Here is an example.
> 
> 
>>main::IO()
>>main=do
>>     time1 <- getCPUTime
>>     w     <- return $! calcSomething
>>     time2 <- getCPUTime
> 
> ...
> 
> J.A.
> 
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
> 



-- 
==================================================
| Iavor S. Diatchki, Ph.D. student               |
| Department of Computer Science and Engineering |
| School of OGI at OHSU                          |
| http://www.cse.ogi.edu/~diatchki               |
==================================================