Neil Mitchell wrote:
Hi
I've found myself writing code like this several times now. Is there a
better way?
hGetContents might be a different way to write a similar thing:
read_args h = do
src <- hGetContents h
let (has,rest) = span ("#" `isPrefixOf`) $ lines src
return (map tail has)
Of course, depending on exactly the kind of IO control you need to do,
it may not work.
Yeah, I was thinking about that. I'm not sure if I could get it to work.
It's reading from a network socket, not a file, and I think I might need
to be able to explicitly close it. (What happens if the other end
closes? Do I get an exception or just the end of the string?) I might
possibly be able to just use hGetContents and run a parser lazily over
the result, we'll see.
I know there's a few monad-related functions that I don't know about. I
was curios to see if any of them help in this instance...
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe