bookhound 0.1.16.0 → 0.1.17.0
raw patch · 2 files changed
+24/−22 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bookhound.cabal +1/−1
- src/Bookhound/Parser.hs +23/−21
bookhound.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: bookhound-version: 0.1.16.0+version: 0.1.17.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
@@ -61,20 +61,20 @@ instance Applicative Parser where pure a = mkParser (`Result` a) liftA2 f (P p t e) mb@(P _ t' e') =- applyTransformsErrors [t, t'] [e, e'] combinedParser- where- combinedParser = mkParser \x ->- case p x of- Error pe -> Error $ fromMaybe pe e- Result i a -> parse ((f a) <$> mb) i+ applyTransformsErrors [t, t'] [e, e'] $ mkParser (\x ->+ case p x of+ Error pe -> Error $ fromMaybe pe e+ Result i a -> parse ((f a) <$> mb) i+ ) instance Monad Parser where- (>>=) (P p t e) f = mkParser \x ->+ (>>=) (P p t e) f = applyTransform t $ mkParser (\x -> case p x of Error pe -> Error $ fromMaybe pe e- Result i a -> parse (applyTransformsErrors [t', t] [e', e] p2) i+ Result i a -> parse (applyError e' p2) i where- p2@(P _ t' e') = f a+ p2@(P _ _ e') = f a+ ) runParser :: Parser a -> Input -> Either ParseError a runParser p@(P _ _ e) i = toEither $ parse (exactly p) i@@ -117,12 +117,13 @@ -> Parser a anyOfHelper [] _ _ = errorParser $ NoMatch "anyOf" anyOfHelper [p] _ _ = p-anyOfHelper ((P p t e) : rest) t' e' = applyTransformsErrors [t, t'] [e, e'] $- mkParser (\x ->- case p x of- result@(Result _ _) -> result- Error _ -> parse (anyOfHelper rest t e) x- )+anyOfHelper ((P p t e) : rest) t' e' =+ applyTransformsErrors [t, t'] [e, e'] $+ mkParser (\x ->+ case p x of+ result@(Result _ _) -> result+ Error _ -> parse (anyOfHelper rest t e) x+ ) @@ -132,12 +133,13 @@ -> Parser a allOfHelper [] _ _ = errorParser $ NoMatch "allOf" allOfHelper [p] _ _ = p-allOfHelper ((P p t e) : rest) t' e' = applyTransformsErrors [t, t'] [e, e'] $- mkParser (\x ->- case p x of- Result _ _ -> parse (allOfHelper rest t e) x- err@(Error _) -> err- )+allOfHelper ((P p t e) : rest) t' e' =+ applyTransformsErrors [t, t'] [e, e'] $+ mkParser (\x ->+ case p x of+ Result _ _ -> parse (allOfHelper rest t e) x+ err@(Error _) -> err+ )