On Thu, 21 Sep 2006 11:20:33 -0300, Henning Thielemann <[EMAIL PROTECTED]> wrote:


On Thu, 21 Sep 2006, Bruno Martínez wrote:

>     getList :: IO [Char]
>     getList = take5 `fmap` getContents -- a thin IO "skin"
>
>     take5 :: [Char] -> [Char]
>     take5 = take 5 . filter (`elem` ['a'..'e']) -- the actual worker

The problem is that getContents 'eats' stdin, which can't be used again.

You can process the result of getContents as many times as you want.

But I cannot process input again without getContents. This function's use of getContents forces me to use only getContents everywhere. For example, I can't use hWaitForInput in another IO action.

I'm forced to change all my IO code to the getContents way, which is not
possible.

If your program contains so much IO code you should seriously consider
refactoring.

I try to minimize the amount of IO I do, but there's a point I don't know how to strip my functions of their remaining IOness. That's why I ask :)

Bruno

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to