[Haskell-cafe] Re: Where do I put the seq?
leimy2k at gmail.com
Thu Aug 20 10:37:51 EDT 2009
> and since the input that the user gives depends on the output on the screen
> (it represents the user <-> machine dialog loop), we must make sure that
> laziness does not go wild and strictness is needed to respect this
> dependency. But as Ryan showed, seq is not really needed (but pattern
> matching is), and his code is super elegant and simple. I
I'm pretty certain that forcing a pattern match via case is what disallows
the laziness to get out of hand. The case statement, when evaluated, must
choose a matched pattern branch, even if it's the only possibility, which
ends up boiling down to "seq" anyway doesn't it?
Or is it that case doesn't have to go through as deep an evaluation as seq
does in some cases? Does that even make any sense? :-)
> On Thu, Aug 20, 2009 at 11:52 AM, Jules Bean <jules at jellybean.co.uk>wrote:
>> Peter Verswyvelen wrote:
>>> Not at all, use it for whatever you want to :-)
>>> I'm writing this code because I'm preparing to write a bunch of tutorials
>>> on FRP, and I first wanted to start with simple console based FRP, e.g.
>>> making a little text adventure game, where the input/choices of the user
>>> might be parsed ala parsec, using monadic style, applicative style, and
>>> arrows, and then doing the same with FRP frameworks like
>> This is a really bad place to start a FRP tutorial IMO.
>> The interface for 'interact' does not make any promises about the relative
>> evaluation order of the input list / production order of the output list.
>> That's why you are having to play horrible tricks with seq to try to force
>> the order to be what you want.
>> I don't think this is the basis of a robust system or a sensible tutorial.
>> Just my 2c.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe