[Haskell-cafe] A common pattern

Neil Mitchell ndmitchell at gmail.com
Mon May 5 04:11:23 EDT 2008


> 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.



More information about the Haskell-Cafe mailing list