git.iko.soy/typeable/xml-lens
on master help sign in
case-insensitive
commit94bf23ccccfe37a8a0017bc7dd51b4aad87ff3e6 authorFumiaki Kinoshita <fumiexcel@gmail.com> dateThu 26 Mar 2015, 14:09 (12 years ago) parentbcb67a5
2 files changed+17−13
Text/XML/Lens.hs+11−8 xml-lens.cabal+6−5
Text/XML/Lens.hs+11−8
@@ -3,13 +3,13 @@
33-----------------------------------------------------------------------------
44-- |
55-- Module : Text.XML.Lens
6−-- Copyright : (C) 2013 Fumiaki Kinoshita
6+-- Copyright : (C) 2015 Fumiaki Kinoshita
77-- License : BSD-style (see the file LICENSE)
88--
99-- Maintainer : Fumiaki Kinoshita <fumiexcel@gmail.com>
10−-- Stability : experimental
10+-- Stability : provisional
1111-- Portability : non-portable
12−-- Useful traversals inspired by XPath
12+--
1313----------------------------------------------------------------------------
1414module Text.XML.Lens (
1515 -- * Lenses, traversals for 'Element'
@@ -62,6 +62,7 @@ import Control.Lens
6262import Data.Text (Text)
6363import Data.Map (Map)
6464import Control.Applicative
65+import Data.CaseInsensitive as CI
6566
6667infixr 9 ./
6768
@@ -153,14 +154,15 @@ entire :: Traversal' Element Element
153154entire f e@(Element _ _ ns) = com <$> f e <*> traverse (_Element (entire f)) ns where
154155 com (Element n a _) = Element n a
155156
156−-- | Traverse elements which has the specified *local* name.
157−named :: Text -> Traversal' Element Element
157+-- | Traverse elements which has the specified *local* name (case-insensitive).
158+named :: CI.CI Text -> Traversal' Element Element
158159named n f s
159− | nameLocalName (elementName s) == n = f s
160+ | CI.mk (nameLocalName (elementName s)) == n = f s
160161 | otherwise = pure s
161162
163+-- | Old name for 'named'
162164ell :: Text -> Traversal' Element Element
163−ell = named
165+ell = named . CI.mk
164166
165167-- | Traverse elements which has the specified name.
166168el :: Name -> Traversal' Element Element
@@ -182,10 +184,11 @@ text = nodes . traverse . _Content
182184comment :: Traversal' Element Text
183185comment = nodes . traverse . _Comment
184186
187+-- | 'plate' traverses over its sub-elements.
185188instance Plated Element where
186189 plate = nodes . traverse . _Element
187190
188−-- | Combine two 'Traversal's just like XPath's slash.
191+-- | Combine two 'Traversal's just like XPath's slash. Identical to ('...').
189192--
190193-- @
191194-- l ./ m ≡ l . 'plate' . m
xml-lens.cabal+6−5
@@ -1,14 +1,15 @@
11name: xml-lens
2−version: 0.1.6.2
3−synopsis: Lenses, traversals, prisms for xml-conduit
2+version: 0.1.6.3
3+synopsis: Lenses, traversals, and prisms for xml-conduit
44description: Lens-based DOM selector
55homepage: https://github.com/fumieval/xml-lens
6+bug-reports: https://github.com/fumieval/xml-lens/issues
67license: BSD3
78license-file: LICENSE
89author: Fumiaki Kinoshita
910maintainer: Fumiaki Kinoshita <fumiexcel@gmail.com>
10−copyright: Copyright (C) 2013 Fumiaki Kinoshita
11−category: Control
11+copyright: Copyright (C) 2015 Fumiaki Kinoshita
12+category: XML
1213build-type: Simple
1314cabal-version: >=1.10
1415
@@ -20,4 +21,4 @@ library
2021 default-language: Haskell2010
2122 ghc-options: -Wall
2223 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