[Haskell-cafe] Re: strict Haskell dialect

Chris Kuklewicz haskell at list.mightyreason.com
Sat Feb 4 06:25:21 EST 2006


What I wanted to make was a Deep / DeepCon Monad which called deepSeq or some
strategy.  But I could not make it type check.

Ben Rudiak-Gould wrote:
> Chris Kuklewicz wrote:
>> Weak uses seq to achieve WHNF for it's argument
>>
>>> newtype Weak a = WeakCon {runWeak :: a}
>>> mkWeak x = seq x (WeakCon x)
>>> unsafeMkWeak x = WeakCon x
> 
> This doesn't actually do what you think it does. mkWeak and unsafeMkWeak
> are the same function.
> 
>     mkWeak 123 = seq 123 (WeakCon 123) = WeakCon 123
>     unsafeMkWeak 123 = WeakCon 123
>     mkWeak _|_ = seq _|_ (WeakCon _|_) = _|_
>     unsafeMkWeak _|_ = WeakCon _|_ = _|_
> 
> To quote John Meacham:
> 
> | A quick note,
> | x `seq` x
> | is always exactly equivalant to x. the reason being that your seq
> | would never be called to force x unless x was needed anyway.
> |
> | I only mention it because for some reason this realization did not hit
> | me for a long time and once it did a zen-like understanding of seq
> | (relative to the random placement and guessing method I had used
> | previously) suddenly was bestowed upon me.
> 
> I remember this anecdote because when I first read it, a zen-like
> understanding of seq suddenly was bestowed upon /me/. Maybe it should be
> in the docs. :-)
> 
> -- Ben
> 

Yeah, that was silly.  Falling back to `seq` was useless.


More information about the Haskell-Cafe mailing list