I might have misunderstood you, but what about using the existing interact function: http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Prelude.html#v:interact
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 :) ]
I am sure you'll get better answers.
Best,
Sorry for such a beginner-y question, but is there a way to make a function like:
interact :: String -> Resp
interact txt =
putStrLn txt
rsp <- getLine
return parseResp rsp
parseResp :: String -> Resp
Or is that simply a wrong way of programming in Haskell with IO?
Thanks (and apologies),
-- kov_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners