bookhound 0.1.7.0 → 0.1.8.0
raw patch · 4 files changed
+21/−15 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- ParserCombinators: anySeparatedBy :: Parser a -> Parser b -> Parser [b]
- ParserCombinators: manySeparatedBy :: Parser a -> Parser b -> Parser [b]
- ParserCombinators: someSeparatedBy :: Parser a -> Parser b -> Parser [b]
+ ParserCombinators: anySepBy :: Parser a -> Parser b -> Parser [b]
+ ParserCombinators: manySepBy :: Parser a -> Parser b -> Parser [b]
+ ParserCombinators: sepByOp :: Parser a -> Parser b -> Parser (a, [b])
+ ParserCombinators: someSepBy :: Parser a -> Parser b -> Parser [b]
Files
- bookhound.cabal +1/−1
- src/ParserCombinators.hs +16/−10
- src/Parsers/Collections.hs +3/−3
- src/Parsers/Json.hs +1/−1
bookhound.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: bookhound-version: 0.1.7.0+version: 0.1.8.0 synopsis: Simple Parser Combinators & Parsers description: Please see the README on GitHub at <https://github.com/albertprz/bookhound#readme> category: Parsers
src/ParserCombinators.hs view
@@ -3,7 +3,7 @@ module ParserCombinators (IsMatch(..), satisfies, contains, notContains, times, maybeTimes, anyTimes, someTimes, manyTimes, within, maybeWithin, withinBoth, maybeWithinBoth,- anySeparatedBy, someSeparatedBy, manySeparatedBy,+ anySepBy, someSepBy, manySepBy, sepByOp, (<|>), (<&>), (<#>), (>>>), (|?), (|*), (|+), (|++)) where import Parser (Parser, char, isMatch, check, anyOf, allOf, except)@@ -87,19 +87,25 @@ -- Separated by combinators-separatedBy :: (Parser b -> Parser (Maybe b)) -> (Parser b -> Parser [b])+sepBy :: (Parser b -> Parser (Maybe b)) -> (Parser b -> Parser [b]) -> Parser a -> Parser b -> Parser [b]-separatedBy freq1 freq2 sep p = (++) <$> (Foldable.toList <$> freq1 p)- <*> freq2 (sep *> p)+sepBy freq1 freq2 sep p = (++) <$> (Foldable.toList <$> freq1 p)+ <*> freq2 (sep *> p) -anySeparatedBy :: Parser a -> Parser b -> Parser [b]-anySeparatedBy = separatedBy (|?) (|*)+anySepBy :: Parser a -> Parser b -> Parser [b]+anySepBy = sepBy (|?) (|*) -someSeparatedBy :: Parser a -> Parser b -> Parser [b]-someSeparatedBy = separatedBy (fmap Just) (|*)+someSepBy :: Parser a -> Parser b -> Parser [b]+someSepBy = sepBy (fmap Just) (|*) -manySeparatedBy :: Parser a -> Parser b -> Parser [b]-manySeparatedBy = separatedBy (fmap Just) (|+)+manySepBy :: Parser a -> Parser b -> Parser [b]+manySepBy = sepBy (fmap Just) (|+)++sepByOp :: Parser a -> Parser b -> Parser (a, [b])+sepByOp sep p = do x1 <- p+ op <- sep+ xs <- someSepBy sep p+ pure $ (op, x1 : xs) -- Parser Binary Operators infixl 3 <|>
src/Parsers/Collections.hs view
@@ -1,7 +1,7 @@ module Parsers.Collections (collOf, listOf, tupleOf, mapOf) where import Parser (Parser)-import ParserCombinators (maybeWithin, anySeparatedBy)+import ParserCombinators (maybeWithin, anySepBy, satisfies) import Parsers.Char (comma, openSquare, closeSquare, openParens, closeParens, openCurly, closeCurly) import Parsers.String(spacing)@@ -13,13 +13,13 @@ collOf :: Parser a -> Parser b -> Parser c -> Parser d -> Parser [d] collOf start end sep elemParser = start *> elemsParser <* end where - elemsParser = anySeparatedBy sep $ maybeWithin spacing elemParser+ elemsParser = anySepBy sep $ maybeWithin spacing elemParser listOf :: Parser a -> Parser [a] listOf = collOf openSquare closeSquare comma tupleOf :: Parser a -> Parser [a]-tupleOf = collOf openParens closeParens comma+tupleOf = satisfies ((>= 2) . length) . collOf openParens closeParens comma mapOf :: Ord b => Parser a -> Parser b -> Parser c -> Parser (Map b c) mapOf sep p1 p2 = Map.fromList <$> collOf openCurly closeCurly comma mapEntry where
src/Parsers/Json.hs view
@@ -41,7 +41,7 @@ element :: Parser JsExpression-element = exactly (number <|> bool <|> nil <|> string)+element = number <|> bool <|> nil <|> string container :: Parser JsExpression container = array <|> object