Bryan O'Sullivan avatar Bryan O'Sullivan committed 21811a1

Better error reporting.

Comments (0)

Files changed (1)

src/Data/ParserCombinators/Attoparsec/Char8.hs

 skipSpace = takeWhile isSpace >> return ()
 {-# INLINE skipSpace #-}
 
-numeric :: (LB.ByteString -> Maybe (a,LB.ByteString)) -> Parser a
-numeric f = do
+numeric :: String -> (LB.ByteString -> Maybe (a,LB.ByteString)) -> Parser a
+numeric desc f = do
   s <- getInput
   case f s of
-    Nothing -> fail "integer"
+    Nothing -> fail desc
     Just (i,s') -> setInput s' >> return i
                    
 -- | Parse an integer.  The position counter is not updated.
 int :: Parser Int
-int = numeric LB.readInt
+int = numeric "Int" LB.readInt
 
 -- | Parse an integer.  The position counter is not updated.
 integer :: Parser Integer
-integer = numeric LB.readInteger
+integer = numeric "Integer" LB.readInteger
 
 -- | Parse a Double.  The position counter is not updated.
 double :: Parser Double
-double = numeric readDouble
+double = numeric "Double" readDouble
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.