[Haskell-beginners] Seq question

Tim Perry tim.v2.0 at gmail.com
Thu Apr 19 23:13:48 CEST 2012


Henk-Jan van Tuly is correct. Oops! Sorry I was mis-informed. By the way,
there is an excellent post about this topic on StackOverflow.com. It
covers, seq, weak-head-normal-form, normal form, and thunks. See here:
http://stackoverflow.com/questions/6872898/haskell-what-is-weak-head-normal-form/6889335#6889335


Hope that makes up for my earlier comment.

Tim


On Thu, Apr 19, 2012 at 2:31 AM, Henk-Jan van Tuyl <hjgtuyl at chello.nl>wrote:

> On Wed, 18 Apr 2012 16:45:05 +0200, Brent Yorgey <byorgey at seas.upenn.edu>
> wrote:
>
>  On Tue, Apr 17, 2012 at 02:41:15PM -0700, Tim Perry wrote:
>>
>>> seq evaluates to Weak Head Normal Form (WHNF). WHNF is the first
>>> contructor. So your use of seq only evaluates the first number and the
>>> cons. I.E., it evaluates to:
>>> s:(Thunk)
>>>
>>
>> Actually, it doesn't even force the first number.  You just get
>>
>> Thunk : Thunk
>>
>>
> A nice way to demonstrate this, is the following GHCi session:
>  Prelude> undefined `seq` print "OK"
>  *** Exception: Prelude.undefined
>  Prelude> [undefined] `seq` print "OK"
>  "OK"
>
>
> Regards,
> Henk-Jan van Tuyl
>
>
> --
> http://Van.Tuyl.eu/
> http://members.chello.nl/**hjgtuyl/tourdemonad.html<http://members.chello.nl/hjgtuyl/tourdemonad.html>
> Haskell programming
> --
>
>
> ______________________________**_________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120419/7747d7bd/attachment.htm>


More information about the Beginners mailing list