packages feed

bookhound 0.1.15.0 → 0.1.16.0

raw patch · 2 files changed

+11/−16 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Bookhound.Parser: withErrorFrom :: (a -> String) -> Parser a -> Parser a

Files

bookhound.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           bookhound-version:        0.1.15.0+version:        0.1.16.0 synopsis:       Simple Parser Combinators description:    Please see the README on GitHub at <https://github.com/albertprz/bookhound#readme> category:       Parser Combinators
src/Bookhound/Parser.hs view
@@ -1,6 +1,6 @@ module Bookhound.Parser (Parser, ParseResult, ParseError(..), runParser, errorParser,                andThen, exactly, isMatch, check, anyOf, allOf, char,-               withTransform, withError, withErrorFrom, except) where+               withTransform, withError, except) where  import Bookhound.Utils.Foldable (findJust) import Control.Applicative      (liftA2)@@ -65,22 +65,22 @@     where       combinedParser = mkParser \x ->         case p x of+          Error pe   -> Error $ fromMaybe pe e           Result i a -> parse ((f a) <$> mb) i-          Error pe   -> Error pe  instance Monad Parser where-  (>>=) (P p t e) f = applyTransformError t e combinedParser-    where-      combinedParser = mkParser \x ->-        case p x of-          Result i a -> parse (f a) i-          Error pe   -> Error pe+  (>>=) (P p t e) f = mkParser \x ->+      case p x of+        Error pe   -> Error $ fromMaybe pe e+        Result i a -> parse (applyTransformsErrors [t', t] [e', e] p2) i+          where+            p2@(P _ t' e') = f a  runParser :: Parser a -> Input -> Either ParseError a-runParser p@(P _ _ err) i = toEither $ parse (exactly p) i+runParser p@(P _ _ e) i = toEither $ parse (exactly p) i   where     toEither = \case-      Error pe   -> Left $ fromMaybe pe err+      Error pe   -> Left $ fromMaybe pe e       Result _ a -> Right a  errorParser :: ParseError -> Parser a@@ -165,11 +165,6 @@  withError :: String -> Parser a -> Parser a withError = applyError . pure . ErrorAt--withErrorFrom :: (a -> String) -> Parser a -> Parser a-withErrorFrom errFn p =-  do val <- p-     withError (errFn val) p  withTransform :: (forall b. Parser b -> Parser b) -> Parser a -> Parser a withTransform t = applyTransform $ Just t