
21 Sep
2006
21 Sep
'06
10:20 a.m.
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.
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.