2007/12/24, Paulo J. Matos <[EMAIL PROTECTED]>: > On Dec 24, 2007 11:55 AM, Paulo J. Matos <[EMAIL PROTECTED]> wrote: > > On Dec 23, 2007 12:44 PM, Isaac Dupree <[EMAIL PROTECTED]> 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? > >
Your type is correct. > > > 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. > Your function return a Maybe (Int,Int), (x,y) is of type (Int,Int). If readInt return a nothing, the whole funtion will return a Nothing per (>>=) instance definition. -- Jedaï _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
