git.iko.soy/typeable/attoparsec
on master help sign in
Better error reporting.
commit24b8394822f12f0b070888afae4807246fbd990b authorBryan O'Sullivan <bos@serpentine.com> dateTue 30 Dec 2008, 23:08 (18 years ago) parentebe88ee
1 file changed+6−6
src/Data/ParserCombinators/Attoparsec/Char8.hs+6−6
src/Data/ParserCombinators/Attoparsec/Char8.hs+6−6
@@ -166,21 +166,21 @@ skipSpace :: Parser ()
166166skipSpace = takeWhile isSpace >> return ()
167167{-# INLINE skipSpace #-}
168168
169−numeric :: (LB.ByteString -> Maybe (a,LB.ByteString)) -> Parser a
170−numeric f = do
169+numeric :: String -> (LB.ByteString -> Maybe (a,LB.ByteString)) -> Parser a
170+numeric desc f = do
171171 s <- getInput
172172 case f s of
173− Nothing -> fail "integer"
173+ Nothing -> fail desc
174174 Just (i,s') -> setInput s' >> return i
175175
176176-- | Parse an integer. The position counter is not updated.
177177int :: Parser Int
178−int = numeric LB.readInt
178+int = numeric "Int" LB.readInt
179179
180180-- | Parse an integer. The position counter is not updated.
181181integer :: Parser Integer
182−integer = numeric LB.readInteger
182+integer = numeric "Integer" LB.readInteger
183183
184184-- | Parse a Double. The position counter is not updated.
185185double :: Parser Double
186−double = numeric readDouble
186+double = numeric "Double" readDouble