diff --git a/Data/JsonStream/CLexer.hs b/Data/JsonStream/CLexer.hs
--- a/Data/JsonStream/CLexer.hs
+++ b/Data/JsonStream/CLexer.hs
@@ -224,7 +224,7 @@
 
 -- | Estimate number of elements in a chunk
 estResultLimit :: BS.ByteString -> CInt
-estResultLimit dta = fromIntegral $ 20 + BS.length dta `div` 5
+estResultLimit dta = fromIntegral $ 20 + BS.length dta `quot` 5
 
 getNextResult :: TempData -> TokenResult
 getNextResult tmp@(TempData {..})
diff --git a/Data/JsonStream/Parser.hs b/Data/JsonStream/Parser.hs
--- a/Data/JsonStream/Parser.hs
+++ b/Data/JsonStream/Parser.hs
@@ -67,6 +67,7 @@
   , filterI
   , takeI
   , toList
+  , mapWithFailure
     -- * SAX-like parsers
   , arrayFound
   , objectFound
@@ -239,12 +240,12 @@
     parseAndAppend (MoreData (Parser np, ntp)) = MoreData (Parser (parseAndAppend . np), ntp)
     parseAndAppend (Done ctx ntp) = Yield end (Done ctx ntp)
 
--- | Generate start/end values when an array is found, in between run a parser.
+-- | Generate start/end values when an object is found, in between run a parser.
 -- The inner parser is not run if an array is not found.
 objectFound :: a -> a -> Parser a -> Parser a
 objectFound = elemFound ObjectBegin
 
--- | Generate start/end values when an object is found, in between run a parser.
+-- | Generate start/end values when an array is found, in between run a parser.
 -- The inner parser is not run if an array is not found.
 --
 -- > >>> let test = "[[1,2,3],true,[],false,{\"key\":1}]" :: ByteString
@@ -541,6 +542,22 @@
     loop (Yield v np)
       | cond v = Yield v (loop np)
       | otherwise = loop np
+
+-- | A back-door for lifting of possibly failing actions.
+-- If an action fails with Left value, convert it into failure
+-- of parsing
+mapWithFailure :: (a -> Either String b) -> Parser a -> Parser b
+mapWithFailure mapping =
+  updateParser
+  where
+    updateParser (Parser run) = Parser $ updateParseResult . run
+    updateParseResult x = case x of
+      MoreData (parser, continuation) -> MoreData (updateParser parser, continuation)
+      Failed message -> Failed message
+      Done a b -> Done a b
+      Yield value parseResult -> case mapping value of
+        Left message -> Failed message
+        Right value' -> Yield value' (updateParseResult parseResult)
 
 --- Convenience operators
 
diff --git a/json-stream.cabal b/json-stream.cabal
--- a/json-stream.cabal
+++ b/json-stream.cabal
@@ -1,5 +1,5 @@
 name:                json-stream
-version:             0.3.0.4
+version:             0.3.1.0
 synopsis:            Incremental applicative JSON parser
 description:         Easy to use JSON parser fully supporting incremental parsing.
                      Parsing grammar in applicative form.
@@ -33,7 +33,7 @@
   c-sources:           c_lib/lexer.c
   includes:            c_lib/lexer.h
   include-dirs:        c_lib
-  build-depends:         base >=4.7 && <4.8
+  build-depends:         base >=4.7 && <4.9
                        , bytestring
                        , text
                        , aeson
@@ -51,7 +51,7 @@
   type:                exitcode-stdio-1.0
   hs-source-dirs:      test, .
   default-language:    Haskell2010
-  build-depends:         base >=4.7 && <4.8
+  build-depends:         base >=4.7 && <4.9
                        , bytestring
                        , text
                        , aeson
