[Haskell-cafe] A common pattern

Andrew Coppin andrewcoppin at btinternet.com
Mon May 5 03:59:59 EDT 2008

I've found myself writing code like this several times now. Is there a 
better way?

  read_args h = do
    line <- hGetLine h

    case line of
      "." -> return []
      ('#':y) -> do
        ys <- read_args h
        return (y:ys)

More information about the Haskell-Cafe mailing list