[Haskell-cafe] Re: Where do I put the seq?

Peter Verswyvelen bugfact at gmail.com
Thu Aug 20 18:57:48 EDT 2009

On Thu, Aug 20, 2009 at 11:23 PM, David Menendez <dave at zednenem.com> wrote:

> The important things to note are (1) getChar# depends on the token
> returned by putChar#, thus guaranteeing that putChar# gets executed
> first, and (2) putChar# and getChar# are impure and cannot normally be
> defined in Haskell.

Ok, that I understand. But if getChar# and putChar# would be pure functions
that just generate some output string / consume some input string, then this
realworld token passing would not work when used with interact, since
neither the output or input string really depends on the dummy token, unless
using a seq again (or strictness annotation, which was explained to be just
syntactic sugar for seq)? But how would we then make a pure monad that can
be used as in my example together with interact? I see no reason why to put
everything in IO when it just comes to converting a stream of inputs to a
stream of outputs? So interact really is useless, unless you just fmap
something over the input or when the output is independent from the input?

As Ryan said, I could use his MonadPrompt for this, but that's a different
approach (and maybe the only correct one)

I'm still curious to see how an FRP solution would look for simple console
based IO though :-) Probably a good exercise to do.

> --
> Dave Menendez <dave at zednenem.com>
> <http://www.eyrie.org/~zednenem/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090820/2e536b33/attachment.html

More information about the Haskell-Cafe mailing list