abnf 0.4.0.0 → 0.4.1.0
raw patch · 3 files changed
+18/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.ABNF.Document: getContent :: Monoid a => Document a -> a
+ Text.ABNF.Document: lookupDocument' :: forall a. Text -> Document a -> [Document a]
+ Text.ABNF.Document.Operations: lookupDocument' :: forall a. Text -> Document a -> [Document a]
Files
- abnf.cabal +1/−1
- src/Text/ABNF/Document.hs +4/−0
- src/Text/ABNF/Document/Operations.hs +13/−0
abnf.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: abnf-version: 0.4.0.0+version: 0.4.1.0 synopsis: Parse ABNF and generate parsers for the specified document description: You can use this library to parse an ABNF document and generate a parser from that ABNF to read a document
src/Text/ABNF/Document.hs view
@@ -26,6 +26,8 @@ , squashDocument , squashDocumentOn , lookupDocument+ , lookupDocument'+ , getContent -- * Parsing documents -- | Re-exported from "Text.ABNF.Document.Parser" , generateParser@@ -38,7 +40,9 @@ import Text.ABNF.Document.Operations ( filterDocument , squashDocument , squashDocumentOn+ , getContent , lookupDocument+ , lookupDocument' ) import Text.ABNF.Document.Parser ( generateParser
src/Text/ABNF/Document/Operations.hs view
@@ -57,3 +57,16 @@ lookupDocument ident doc@(Document ident2 conts) | ident2 == ident = [doc] | otherwise = join $ lookupDocument ident <$> conts++-- | Similar to 'lookupDocument', 'lookupDocument'' will find a 'Document' with+-- a particular identifier. This, however, will only find immediate children and+-- will not recurse.+lookupDocument' :: forall a. Text.Text -- ^ Identifier to search for+ -> Document a -- ^ 'Document' to search in+ -> [Document a]+lookupDocument' _ (Terminal _) = []+lookupDocument' ident (Document _ conts) = catMaybes $ go ident <$> conts+ where+ go _ (Terminal _) = Nothing+ go ident doc@(Document ident2 _) | ident == ident2 = Just doc+ | otherwise = Nothing