[Haskell-cafe] Re: Comments on reading two ints off Bytestring

Paulo J. Matos pocm at soton.ac.uk
Mon Dec 24 06:58:37 EST 2007


On Dec 24, 2007 11:55 AM, Paulo J. Matos <pocm at soton.ac.uk> wrote:
> On Dec 23, 2007 12:44 PM, Isaac Dupree <isaacdupree at charter.net> wrote:
> >
> > -- this should work too
> > parseHeader3 :: BS.ByteString -> Maybe (Int, Int)
> > --note accurate type signature, which helps us use Maybe failure-monad,
> > --although losing your separate error messages
>
> Oh gee, I just noticed that my type sig is in fact not correct. How
> come GHC doesn't complain?
>
> > parseHeader3 bs = do
> >    (x, rest) <- BS.readInt $ BS.dropWhile (not . isDigit) bs
> >    (y, _) <- BS.readInt $ BS.dropWhile (not . isDigit) rest
> >    return (x, y)
>
> What happens then if the first BS.readInt return Nothing???
>

Ok, got it, I'm not returning a maybe. That's it then.
Still, the first question remains... what happens to (x, rest) if
BS.readInt returns Nothing.

-- 
Paulo Jorge Matos - pocm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm
PhD Student @ ECS
University of Southampton, UK


More information about the Haskell-Cafe mailing list