git.iko.soy/typeable/dom-parser
on master help sign in
.travis.yml+7−5
since splitsnapshots
unifiedsplit
@@ -4,6 +4,12 @@ sudo: false
4# Do not choose a language; we provide our own build tools.
4# Do not choose a language; we provide our own build tools.
5language: generic
5language: generic
6
6
7+env:
8+ - STACK_YAML=stack.yaml
9+ - STACK_YAML=ghc-802.yaml
10+ - STACK_YAML=ghc-822.yaml
11+ - STACK_YAML=ghc-841.yaml
12+
7# Caching so the next build will be fast too.
13# Caching so the next build will be fast too.
8cache:
14cache:
9 directories:
15 directories:
@@ -21,10 +27,6 @@ before_install:
21- export PATH=$HOME/.local/bin:$PATH
27- export PATH=$HOME/.local/bin:$PATH
22- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
28- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
23
29
24−install:
25−# Build dependencies
26−- stack --no-terminal --install-ghc build --only-dependencies
27−
28script:
30script:
29# Build the package, its tests, and its docs and run the tests
31# Build the package, its tests, and its docs and run the tests
30−- stack --no-terminal test --haddock --no-haddock-deps
32+- stack --no-terminal --install-ghc test --haddock --no-haddock-deps
CHANGELOG.md+28
@@ -1,5 +1,33 @@
1# CHANGELOG
1# CHANGELOG
2
2
3+## HEAD
4+
5+## 3.2.0
6+
7+### Added
8+
9+* Text.XML.Soap module with XmlEnvelope stuff in it.
10+* GHC 9 compatibility.
11+
12+### Removed
13+
14+* Old stackage files.
15+
16+## 3.1.0
17+
18+### Added
19+
20+* Additional builds with GHC 8.0.2 and 8.2.1
21+* Compatibility with GHC 8.4.1
22+
23+## 3.0.0
24+
25+* GHC 8 compatible release
26+
27+### Removed
28+
29+* `open-union` dependency
30+
3## 2.0.0
31## 2.0.0
4
32
5### Added
33### Added
README.mdnew file+5
@@ -0,0 +1,5 @@
1+# dom-parser
2+
3+[![Build Status](https://travis-ci.org/typeable/dom-parser.svg?branch=master)](https://travis-ci.org/typeable/dom-parser)
4+
5+Simple monadic DOM parser
dom-parser.cabal+10−10
@@ -1,5 +1,5 @@
1name: dom-parser
1name: dom-parser
2−version: 2.0.0
2+version: 3.2.0
3synopsis: Simple monadic DOM parser
3synopsis: Simple monadic DOM parser
4license: MIT
4license: MIT
5license-file: LICENSE
5license-file: LICENSE
@@ -7,12 +7,13 @@ author: Typeable.io contributors
7maintainer: makeit@typeable.io
7maintainer: makeit@typeable.io
8category: XML
8category: XML
9build-type: Simple
9build-type: Simple
10−extra-source-files: CHANGELOG.md
11cabal-version: >=1.10
10cabal-version: >=1.10
12−
13−extra-source-files: CHANGELOG.md
14−
15homepage: https://github.com/typeable/dom-parser
11homepage: https://github.com/typeable/dom-parser
12+tested-with: GHC == 9.2.7
13+ , GHC == 9.4.8
14+ , GHC == 9.6.3
15+extra-source-files: CHANGELOG.md
16+ , README.md
16
17
17source-repository head
18source-repository head
18 type: git
19 type: git
@@ -43,18 +44,16 @@ library
43 , TypeFamilies
44 , TypeFamilies
44 , TypeOperators
45 , TypeOperators
45 , UndecidableInstances
46 , UndecidableInstances
46− build-depends: base >= 4.7 && < 5
47+ build-depends: base >= 4.11 && < 5
47 , case-insensitive
48 , case-insensitive
48 , containers
49 , containers
49 , lens
50 , lens
50− , mtl
51+ , mtl < 2.3 || > 2.3
51− , open-union >= 0.2
52 , scientific
52 , scientific
53− , semigroups
54 , text
53 , text
55 , transformers
54 , transformers
56− , type-fun
57 , xml-conduit
55 , xml-conduit
56+ , xml-conduit-writer
58 , xml-lens
57 , xml-lens
59 exposed-modules: Text.XML.DOM.Parser
58 exposed-modules: Text.XML.DOM.Parser
60 , Text.XML.DOM.Parser.Attributes
59 , Text.XML.DOM.Parser.Attributes
@@ -64,6 +63,7 @@ library
64 , Text.XML.DOM.Parser.FromAttribute
63 , Text.XML.DOM.Parser.FromAttribute
65 , Text.XML.DOM.Parser.FromDom
64 , Text.XML.DOM.Parser.FromDom
66 , Text.XML.DOM.Parser.Types
65 , Text.XML.DOM.Parser.Types
66+ , Text.XML.Soap
67
67
68test-suite test
68test-suite test
69 type: exitcode-stdio-1.0
69 type: exitcode-stdio-1.0
ghc-963.yamlnew file+7
@@ -0,0 +1,7 @@
1+resolver: lts-22.6
2+
3+extra-deps:
4+ - xml-conduit-writer-0.1.1.5
5+
6+nix:
7+ packages: [zlib]
src/Text/XML/DOM/Parser/Combinators.hs−1
@@ -22,7 +22,6 @@ import Control.Monad.Reader
22import Data.Foldable as F
22import Data.Foldable as F
23import Data.List as L
23import Data.List as L
24import Data.List.NonEmpty (NonEmpty(..))
24import Data.List.NonEmpty (NonEmpty(..))
25−import Data.Monoid
26import Data.Text as T
25import Data.Text as T
27import Data.Traversable
26import Data.Traversable
28import Text.XML
27import Text.XML
src/Text/XML/DOM/Parser/Content.hs+4−3
@@ -20,6 +20,7 @@ import Data.List as L
20import Data.Monoid
20import Data.Monoid
21import Data.Text as T
21import Data.Text as T
22import Data.Typeable
22import Data.Typeable
23+import Prelude as P
23import Text.Read
24import Text.Read
24import Text.XML.DOM.Parser.Types
25import Text.XML.DOM.Parser.Types
25import Text.XML.Lens
26import Text.XML.Lens
@@ -93,7 +94,7 @@ maybeReadContent
93maybeReadContent f t = maybe (Left msg) Right $ f t
94maybeReadContent f t = maybe (Left msg) Right $ f t
94 where
95 where
95 msg = "Not readable " <> n <> ": " <> t
96 msg = "Not readable " <> n <> ": " <> t
96− n = T.pack $ show $ typeRep (Proxy :: Proxy a)
97+ n = T.pack $ P.show $ typeRep (Proxy :: Proxy a)
97
98
98
99
99-- | Tries to read given text to value using 'Read'. Useful to use
100-- | Tries to read given text to value using 'Read'. Useful to use
@@ -114,8 +115,8 @@ readBool t =
114 tvals = ["y", "yes", "t", "true", "1"]
115 tvals = ["y", "yes", "t", "true", "1"]
115 fvals = ["n", "no", "f", "false", "0"]
116 fvals = ["n", "no", "f", "false", "0"]
116 in if
117 in if
117− | lowt `elem` tvals -> Right True
118+ | lowt `L.elem` tvals -> Right True
118− | lowt `elem` fvals -> Right False
119+ | lowt `L.elem` fvals -> Right False
119 | otherwise ->
120 | otherwise ->
120 Left $ "Could not read " <> t <> " as Bool"
121 Left $ "Could not read " <> t <> " as Bool"
121
122
src/Text/XML/DOM/Parser/FromDom.hs−20
@@ -4,7 +4,6 @@ module Text.XML.DOM.Parser.FromDom
4 , proxyFromDom
4 , proxyFromDom
5 -- * Explicit methods for convenience
5 -- * Explicit methods for convenience
6 , elementFromDom
6 , elementFromDom
7− , unionFromDom
8 , textFromDom
7 , textFromDom
9 , stringFromDom
8 , stringFromDom
10 , charFromDom
9 , charFromDom
@@ -21,7 +20,6 @@ module Text.XML.DOM.Parser.FromDom
21import Control.Applicative
20import Control.Applicative
22import Control.Lens
21import Control.Lens
23import Data.Fixed
22import Data.Fixed
24−import Data.OpenUnion
25import Data.Scientific
23import Data.Scientific
26import Data.Text as T hiding (empty)
24import Data.Text as T hiding (empty)
27import Data.Typeable
25import Data.Typeable
@@ -29,7 +27,6 @@ import Data.Void
29import Text.XML
27import Text.XML
30import Text.XML.DOM.Parser.Content
28import Text.XML.DOM.Parser.Content
31import Text.XML.DOM.Parser.Types
29import Text.XML.DOM.Parser.Types
32−import TypeFun.Data.List hiding (Union)
33
30
34proxyFromDom
31proxyFromDom
35 :: forall proxy m a
32 :: forall proxy m a
@@ -116,23 +113,6 @@ instance FromDom Bool where
116boolFromDom :: (Monad m) => DomParserT Identity m Bool
113boolFromDom :: (Monad m) => DomParserT Identity m Bool
117boolFromDom = parseContent readBool
114boolFromDom = parseContent readBool
118
115
119−instance FromDom (Union '[]) where
120− fromDom = empty
121−
122−instance
123− ( Typeable a, FromDom a, FromDom (Union as)
124− , SubList as (a ': as) )
125− => FromDom (Union (a ': as)) where
126− -- fromDom :: forall m. (DomParserMonad m) => m a
127− fromDom = (liftUnion <$> (proxyFromDom (Proxy :: Proxy a)))
128− <|> (reUnion <$> (proxyFromDom (Proxy :: Proxy (Union as))))
129−
130−unionFromDom
131− :: (Monad m, FromDom (Union as))
132− => proxy as
133− -> DomParserT Identity m (Union as)
134−unionFromDom _ = fromDom
135−
136instance FromDom Element where
116instance FromDom Element where
137 fromDom = elementFromDom
117 fromDom = elementFromDom
138
118
src/Text/XML/DOM/Parser/Types.hs+4−4
@@ -88,8 +88,6 @@ data NameMatcher = NameMatcher
88 -- ^ Field for 'Show' instance and bulding usefull errors
88 -- ^ Field for 'Show' instance and bulding usefull errors
89 }
89 }
90
90
91−makeLenses ''NameMatcher
92−
93-- | Instance use 'matchCILocalName' as most general and liberal
91-- | Instance use 'matchCILocalName' as most general and liberal
94-- matching strategy (while XML is often malformed).
92-- matching strategy (while XML is often malformed).
95--
93--
@@ -121,6 +119,8 @@ matchCILocalName tname = NameMatcher
121 , _nmShow = tname
119 , _nmShow = tname
122 }
120 }
123
121
122+makeLenses ''NameMatcher
123+
124-- | Makes matcher which match name by 'Eq' with given
124-- | Makes matcher which match name by 'Eq' with given
125--
125--
126-- @since 2.0.0
126-- @since 2.0.0
@@ -134,7 +134,7 @@ matchName n = NameMatcher
134-- element of the document. Errors are much more usefull with path.
134-- element of the document. Errors are much more usefull with path.
135newtype DomPath = DomPath
135newtype DomPath = DomPath
136 { unDomPath :: [Text]
136 { unDomPath :: [Text]
137− } deriving (Eq, Ord, Show, Monoid)
137+ } deriving (Eq, Ord, Show, Semigroup, Monoid)
138
138
139-- | DOM parser error description.
139-- | DOM parser error description.
140data ParserError
140data ParserError
@@ -184,7 +184,7 @@ instance Exception ParserError
184
184
185newtype ParserErrors = ParserErrors
185newtype ParserErrors = ParserErrors
186 { unParserErrors :: [ParserError]
186 { unParserErrors :: [ParserError]
187− } deriving (Show, Monoid, Generic)
187+ } deriving (Show, Semigroup, Monoid, Generic)
188
188
189makePrisms ''ParserErrors
189makePrisms ''ParserErrors
190
190
src/Text/XML/Soap.hsnew file+46
@@ -0,0 +1,46 @@
1+module Text.XML.Soap where
2+
3+import Control.Lens
4+import Data.String
5+import Text.XML
6+import Text.XML.DOM.Parser
7+import Text.XML.Writer
8+
9+data XmlEnvelope h b = XmlEnvelope
10+ { _xeHeader :: !(Maybe h)
11+ , _xeBody :: !(Maybe b)
12+ } deriving (Eq, Show)
13+
14+makeLenses ''XmlEnvelope
15+
16+xmlEnvelopeToDocument :: (ToXML h, ToXML b) => XmlEnvelope h b -> Document
17+xmlEnvelopeToDocument xe = doc
18+ where
19+ sname n = fromString $ "{http://schemas.xmlsoap.org/soap/envelope/}" <> n
20+ doc =
21+ Document
22+ { documentPrologue = Prologue [] Nothing []
23+ , documentRoot =
24+ Element
25+ { elementName = sname "Envelope"
26+ , elementAttributes = mempty
27+ , elementNodes = [NodeElement header, NodeElement body]
28+ }
29+ , documentEpilogue = []
30+ }
31+ header =
32+ Element
33+ { elementName = sname "Header"
34+ , elementAttributes = mempty
35+ , elementNodes = render . toXML $ xe ^. xeHeader
36+ }
37+ body =
38+ Element
39+ { elementName = sname "Body"
40+ , elementAttributes = mempty
41+ , elementNodes = render . toXML $ xe ^. xeBody
42+ }
43+
44+instance (FromDom h, FromDom b) => FromDom (XmlEnvelope h b) where
45+ fromDom = XmlEnvelope <$> inElemMay "Header" fromDom
46+ <*> inElemMay "Body" fromDom
stack.yamlmode 100644 → 120000+1−6
@@ -1,6 +0,0 @@
1−packages:
2− - .
3−extra-deps:
4− - open-union-0.2.0.0
5− - type-fun-0.1.1
6−resolver: lts-6.25
@@ -0,0 +1 @@
1+ghc-963.yaml