xml-html-conduit-lens 0.3.2.2 → 0.3.2.3
raw patch · 3 files changed
+69/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- example/namespaces.hs +50/−0
- example/namespaces.xml +14/−0
- xml-html-conduit-lens.cabal +5/−3
+ example/namespaces.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE OverloadedStrings #-}+module Namespaces where++import Control.Lens -- lens+import Data.String (IsString(..)) -- base+import Data.Text (Text) -- text+import Text.Printf (printf) -- base+import Text.Xml.Lens -- xml-html-conduit-lens++-- $setup+-- >>> :set -XOverloadedStrings+-- >>> import Text.Xml.Lens+-- >>> import qualified Data.Text.Lazy.IO as Text+-- >>> doc <- Text.readFile "example/namespaces.xml"++-- | Fire pokemons+--+-- >>> toListOf fire doc+-- ["charmander","vulpix"]+fire :: AsXmlDocument t => Traversal' t Text+fire =+ xml.node (pokemon "list")+ .plate+ .attributed (ix (pokemon "type").only "fire")+ .attr (pokemon "name")+ .traverse++-- | Soviet communists+--+-- >>> toListOf soviet doc+-- ["Alexandra Kollantai","Nadezhda Krupskaya"]+soviet :: AsXmlDocument t => Traversal' t Text+soviet =+ xml.node (communist "list")+ .plate+ .attributed (ix (communist "nationality").only "Soviet")+ .attr (communist "name")+ .traverse++pokemon :: IsString str => String -> str+pokemon =+ ns "http://pokemon.example.com"++communist :: IsString str => String -> str+communist =+ ns "http://communist.example.com"++ns :: IsString str => String -> String -> str+ns url =+ fromString . printf "{%s}%s" url
+ example/namespaces.xml view
@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="UTF-8"?>+<lists xmlns:pokemon="http://pokemon.example.com"+ xmlns:communist="http://communist.example.com">+ <pokemon:list>+ <pokemon:seed pokemon:type="grass poison" pokemon:name="bulbasaur" />+ <pokemon:lizard pokemon:type="fire" pokemon:name="charmander" />+ <pokemon:fox pokemon:type="fire" pokemon:name="vulpix" />+ </pokemon:list>+ <communist:list>+ <communist:person communist:nationality="German" communist:name="Rosa Luxembourg" />+ <communist:person communist:nationality="Soviet" communist:name="Alexandra Kollantai" />+ <communist:person communist:nationality="Soviet" communist:name="Nadezhda Krupskaya" />+ </communist:list>+</lists>
xml-html-conduit-lens.cabal view
@@ -1,5 +1,5 @@ name: xml-html-conduit-lens-version: 0.3.2.2+version: 0.3.2.3 synopsis: Optics for xml-conduit and html-conduit description: Optics for xml-conduit and html-conduit homepage: https://github.com/supki/xml-html-conduit-lens#readme@@ -16,6 +16,8 @@ CHANGELOG.md example/books.hs example/books.xml+ example/namespaces.hs+ example/namespaces.xml example/ridna-mova.hs example/yandex-weather.hs @@ -25,7 +27,7 @@ source-repository this type: git- tag: 0.3.2.2+ tag: 0.3.2.3 location: https://github.com/supki/xml-html-conduit-lens library@@ -66,7 +68,7 @@ , hspec , hspec-expectations-lens >= 0.3 , lens >= 4.0- , xml-conduit >= 1.1 && < 1.4+ , xml-conduit >= 1.1 && < 1.5 , xml-html-conduit-lens other-modules: Text.Xml.LensSpec