git.iko.soy/typeable/xml-lens
on master help sign in
add ell
d1790effumieval
Text/XML/Lens.hs+11−1
@@ -16,6 +16,7 @@ module Text.XML.Lens (
16 -- ** Names
16 -- ** Names
17 , name
17 , name
18 , el
18 , el
19+ , ell
19 -- ** Attributes
20 -- ** Attributes
20 , attributeIs
21 , attributeIs
21 , attributeSatisfies
22 , attributeSatisfies
@@ -45,6 +46,9 @@ module Text.XML.Lens (
45 -- * Lenses for 'Instruction'
46 -- * Lenses for 'Instruction'
46 , _instructionTarget
47 , _instructionTarget
47 , _instructionData
48 , _instructionData
49+ -- * Reexports
50+ , module Control.Lens
51+ , module Text.XML
48 ) where
52 ) where
49import Text.XML
53import Text.XML
50import Control.Lens
54import Control.Lens
@@ -136,7 +140,7 @@ attribute n = attrs . at n
136-- | Traverse itself with its all children.
140-- | Traverse itself with its all children.
137entire :: Traversal' Element Element
141entire :: Traversal' Element Element
138entire f e@(Element _ _ ns) = com <$> f e <*> traverse (_Element (entire f)) ns where
142entire f e@(Element _ _ ns) = com <$> f e <*> traverse (_Element (entire f)) ns where
139− com (Element n a _) ns = Element n a ns
143+ com (Element n a _) = Element n a
140
144
141-- | Traverse elements which has the specified name.
145-- | Traverse elements which has the specified name.
142el :: Name -> Traversal' Element Element
146el :: Name -> Traversal' Element Element
@@ -144,6 +148,12 @@ el n f s
144 | elementName s == n = f s
148 | elementName s == n = f s
145 | otherwise = pure s
149 | otherwise = pure s
146
150
151+-- | Traverse elements which has the specified *local* name.
152+ell :: Text -> Traversal' Element Element
153+ell n f s
154+ | nameLocalName (elementName s) == n = f s
155+ | otherwise = pure s
156+
147attributeSatisfies :: Name -> (Text -> Bool) -> Traversal' Element Element
157attributeSatisfies :: Name -> (Text -> Bool) -> Traversal' Element Element
148attributeSatisfies n p = filtered (maybe False p . preview (attrs . ix n))
158attributeSatisfies n p = filtered (maybe False p . preview (attrs . ix n))
149
159
xml-lens.cabal+3−4
@@ -1,7 +1,7 @@
1name: xml-lens
1name: xml-lens
2−version: 0.1.2
2+version: 0.1.3
3synopsis: Lenses, traversals, prisms for xml-conduit
3synopsis: Lenses, traversals, prisms for xml-conduit
4−description:
4+description: Lens-based DOM selector
5homepage: https://github.com/fumieval/xml-lens
5homepage: https://github.com/fumieval/xml-lens
6license: BSD3
6license: BSD3
7license-file: LICENSE
7license-file: LICENSE
@@ -20,5 +20,4 @@ library
20 default-language: Haskell2010
20 default-language: Haskell2010
21 ghc-options: -Wall
21 ghc-options: -Wall
22 exposed-modules: Text.XML.Lens
22 exposed-modules: Text.XML.Lens
23− -- other-modules:
24− build-depends: base ==4.*, lens >= 3.8 && < 4.2, containers >= 0.4.0 && < 0.6, text == 0.11.*, xml-conduit >= 1.1
23+ build-depends: base ==4.*, lens >= 3.8 && < 4.2, containers >= 0.4.0 && < 0.6, text == 0.11.*, xml-conduit >= 1.1 && < 1.3