git.iko.soy/typeable/xml-lens
on master help sign in
case-insensitive
94bf23cFumiaki Kinoshita
Text/XML/Lens.hs+11−8
@@ -3,13 +3,13 @@
3-----------------------------------------------------------------------------
3-----------------------------------------------------------------------------
4-- |
4-- |
5-- Module : Text.XML.Lens
5-- Module : Text.XML.Lens
6−-- Copyright : (C) 2013 Fumiaki Kinoshita
6+-- Copyright : (C) 2015 Fumiaki Kinoshita
7-- License : BSD-style (see the file LICENSE)
7-- License : BSD-style (see the file LICENSE)
8--
8--
9-- Maintainer : Fumiaki Kinoshita <fumiexcel@gmail.com>
9-- Maintainer : Fumiaki Kinoshita <fumiexcel@gmail.com>
10−-- Stability : experimental
10+-- Stability : provisional
11-- Portability : non-portable
11-- Portability : non-portable
12−-- Useful traversals inspired by XPath
12+--
13----------------------------------------------------------------------------
13----------------------------------------------------------------------------
14module Text.XML.Lens (
14module Text.XML.Lens (
15 -- * Lenses, traversals for 'Element'
15 -- * Lenses, traversals for 'Element'
@@ -62,6 +62,7 @@ import Control.Lens
62import Data.Text (Text)
62import Data.Text (Text)
63import Data.Map (Map)
63import Data.Map (Map)
64import Control.Applicative
64import Control.Applicative
65+import Data.CaseInsensitive as CI
65
66
66infixr 9 ./
67infixr 9 ./
67
68
@@ -153,14 +154,15 @@ entire :: Traversal' Element Element
153entire f e@(Element _ _ ns) = com <$> f e <*> traverse (_Element (entire f)) ns where
154entire f e@(Element _ _ ns) = com <$> f e <*> traverse (_Element (entire f)) ns where
154 com (Element n a _) = Element n a
155 com (Element n a _) = Element n a
155
156
156−-- | Traverse elements which has the specified *local* name.
157+-- | Traverse elements which has the specified *local* name (case-insensitive).
157−named :: Text -> Traversal' Element Element
158+named :: CI.CI Text -> Traversal' Element Element
158named n f s
159named n f s
159− | nameLocalName (elementName s) == n = f s
160+ | CI.mk (nameLocalName (elementName s)) == n = f s
160 | otherwise = pure s
161 | otherwise = pure s
161
162
163+-- | Old name for 'named'
162ell :: Text -> Traversal' Element Element
164ell :: Text -> Traversal' Element Element
163−ell = named
165+ell = named . CI.mk
164
166
165-- | Traverse elements which has the specified name.
167-- | Traverse elements which has the specified name.
166el :: Name -> Traversal' Element Element
168el :: Name -> Traversal' Element Element
@@ -182,10 +184,11 @@ text = nodes . traverse . _Content
182comment :: Traversal' Element Text
184comment :: Traversal' Element Text
183comment = nodes . traverse . _Comment
185comment = nodes . traverse . _Comment
184
186
187+-- | 'plate' traverses over its sub-elements.
185instance Plated Element where
188instance Plated Element where
186 plate = nodes . traverse . _Element
189 plate = nodes . traverse . _Element
187
190
188−-- | Combine two 'Traversal's just like XPath's slash.
191+-- | Combine two 'Traversal's just like XPath's slash. Identical to ('...').
189--
192--
190-- @
193-- @
191-- l ./ m ≡ l . 'plate' . m
194-- l ./ m ≡ l . 'plate' . m
xml-lens.cabal+6−5
@@ -1,14 +1,15 @@
1name: xml-lens
1name: xml-lens
2−version: 0.1.6.2
2+version: 0.1.6.3
3−synopsis: Lenses, traversals, prisms for xml-conduit
3+synopsis: Lenses, traversals, and prisms for xml-conduit
4description: Lens-based DOM selector
4description: Lens-based DOM selector
5homepage: https://github.com/fumieval/xml-lens
5homepage: https://github.com/fumieval/xml-lens
6+bug-reports: https://github.com/fumieval/xml-lens/issues
6license: BSD3
7license: BSD3
7license-file: LICENSE
8license-file: LICENSE
8author: Fumiaki Kinoshita
9author: Fumiaki Kinoshita
9maintainer: Fumiaki Kinoshita <fumiexcel@gmail.com>
10maintainer: Fumiaki Kinoshita <fumiexcel@gmail.com>
10−copyright: Copyright (C) 2013 Fumiaki Kinoshita
11+copyright: Copyright (C) 2015 Fumiaki Kinoshita
11−category: Control
12+category: XML
12build-type: Simple
13build-type: Simple
13cabal-version: >=1.10
14cabal-version: >=1.10
14
15
@@ -20,4 +21,4 @@ library
20 default-language: Haskell2010
21 default-language: Haskell2010
21 ghc-options: -Wall
22 ghc-options: -Wall
22 exposed-modules: Text.XML.Lens
23 exposed-modules: Text.XML.Lens
23− build-depends: base ==4.*, lens >= 4.0 && < 5, containers >= 0.4.0 && < 0.7, text >= 0.7 && <2, xml-conduit >= 1.1 && < 1.4
24+ build-depends: base ==4.*, lens >= 4.0 && < 5, containers >= 0.4.0 && < 0.7, text >= 0.7 && <2, xml-conduit >= 1.1 && < 1.4, case-insensitive