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)