hexpat-lens 0.0.3 → 0.0.4
raw patch · 3 files changed
+22/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.XML.Expat.Lens.Unqualified: instance Plated (UNode a)
+ Text.XML.Expat.Lens.Unqualified: parameterized :: (Choice p, Applicative f, Eq t, GenericXMLString t) => t -> t -> Overloaded' p f (UNode t) (UNode t)
Files
- hexpat-lens.cabal +1/−1
- src/Text/XML/Expat/Lens.hs +0/−1
- src/Text/XML/Expat/Lens/Unqualified.hs +21/−3
hexpat-lens.cabal view
@@ -1,5 +1,5 @@ name: hexpat-lens-version: 0.0.3+version: 0.0.4 synopsis: Lenses for Hexpat. license: MIT license-file: LICENSE
src/Text/XML/Expat/Lens.hs view
@@ -19,6 +19,5 @@ ) where -import Text.XML.Expat.Tree import Text.XML.Expat.Lens.Unqualified import Text.XML.Expat.Lens.Parse
src/Text/XML/Expat/Lens/Unqualified.hs view
@@ -64,12 +64,16 @@ instance (GenericXMLString a, Applicative f) => Ixed f (UNode a) where ix = ixAt- + instance ( GenericXMLString a , Applicative f , Contravariant f ) => Contains f (UNode a) where contains = containsAt +instance Plated (UNode a) where+ plate = children . traverse+ {-# INLINE plate #-}+ -- | Traverses the children of an 'Element'. This is as -- an "Affine", or 0-or-1 target, 'Traversal'. In regex terms, you -- can think of it like the @?@ suffix modifier.@@ -96,10 +100,12 @@ -- We can use plated/uniplate lenses to traverse all of the elements of -- the tree in a bottom up fashion. --- | Produces a list of all 'UNode's in a XML tree.+-- | Produces a list of all 'UNode's in a XML tree. Synonym for+-- 'universe'. allNodes :: UNode t -> [UNode t]-allNodes = universeOf (children . traverse)+allNodes = universe+{-# INLINE allNodes #-} -- And if we build one sort-of @Traversal@ then we'll have replicated -- almost all of the functionality of @NodeClass@ in lenses. This uses@@ -109,3 +115,15 @@ named :: (Choice p, Applicative f, Eq t) => t -> Overloaded' p f (UNode t) (UNode t) named n = filtered (isNamed n)++-- | @parameterized k v@ traverses 'Element's which match the value+-- @v@ at the key @k@ in their attributes.++parameterized :: (Choice p, Applicative f, Eq t, GenericXMLString t) =>+ t -> t -> Overloaded' p f (UNode t) (UNode t)+parameterized k v = filtered check where+ check u = case u ^? ix k . to (==v) of+ Just True -> True+ _ -> False+ {-# INLINE check #-}+{-# INLINE parameterized #-}