[Haskell-beginners] A basic misunderstanding of how to program with IO

Ozgur Akgun ozgurakgun at gmail.com
Sat May 8 12:56:38 EDT 2010

On 8 May 2010 17:44, Thomas Davie <tom.davie at gmail.com> wrote:

> On 8 May 2010, at 17:09, Ozgur Akgun wrote:
> I might have misunderstood you, but what about using the existing interact
> function:
> http://haskell.org/ghc/docs/6.12.1/html/libraries/base-
> And for your interact, since it is not in the IO monad, you cannot write
> such a function. [ don't tell him about the unsafePerformIO :) ]
> Uh, interact absolutely *is* in the IO monad, and is totally implementable
> without unsafePerformIO, like this:
Upps now I need to clarify myself I guess.

I said "your interact is not in the IO monad", because the interact OP
defined had the type:

interact :: String -> Resp

Which obviously is not in the IO monad, if he is not hiding something in
Resp (looks unlikely to me)

> interact f = putStr =<< f <$> getContents
> Bob

And of course, interact is something implementable :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100508/4502557a/attachment.html

More information about the Beginners mailing list