Copyright | (c) Jonathan Merritt 2017 |
---|---|
License | BSD3 |
Maintainer | j.s.merritt@gmail.com |
Stability | Experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
This module contains classes and types which are parameterized to allow a very generic typed DOM interface.
Type parameters have been abbreviated to single letters, which are used uniformly throughout:
e
- element typen
- type for the name of an elementa
- type for the name of an attributet
- type for text content in the XML document
- class ToElem e z where
- class FromElem e n a t z where
- class ToXText t z where
- class FromXText t z where
- class Conv p q where
- newtype Attr z = Attr {
- unAttr :: z
- newtype Child z = Child {
- unChild :: z
- newtype Content z = Content {
- unContent :: z
- newtype CData z = CData {
- unCData :: z
- newtype XTextError = XTextError {
- unXTextError :: Text
- data Result e n a t z
- data Path n
- data Cause e n a t
- xTextErrType :: Text -> Text -> Either XTextError a
- prependPath :: n -> Result e n a t z -> Result e n a t z
- replacePathHead :: n -> Result e n a t z -> Result e n a t z
Classes
class FromElem e n a t z where Source #
Typeclass for a type z
which can be read from an element of type e
.
class FromXText t z where Source #
Typeclass for a type z
which can be read from a text type t
.
fromXText :: t -> Either XTextError z Source #
Reads a value of type t
into an Either
.
As a failure case (Left
), the Either
may contain an XTextError
,
describing the reason for the failure. On success (Right
), the
Either
contains a value of type z
.
XML DOM Types
Attribute.
Specifies that a record field of type Attr z
should become an XML
attribute. The name of the attribute is specified by the name of the record
selector, while the value is the textual representation of the value of
type z
.
(KnownSymbol name, ToXText t z) => GToElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Attr (Maybe z)))) Source # | S1 (named) + Attr Maybe - record selector for optional XML attribute. |
(KnownSymbol name, ToXText t z) => GToElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Attr z))) Source # | S1 (named) + Attr - record selector for an XML attribute. |
(KnownSymbol name, FromXText t z) => GFromElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Attr (Maybe z)))) Source # | S1 (named) + Attr Maybe - record selector for an optional XML attribute. |
(KnownSymbol name, FromXText t z) => GFromElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Attr z))) Source # | S1 (named) + Attr - record selector for an XML attribute. |
Conv z (Attr z) Source # | |
Eq z => Eq (Attr z) Source # | |
Show z => Show (Attr z) Source # | |
Arbitrary z => Arbitrary (Attr z) Source # | |
Conv (Attr z) z Source # | |
Child (containing only text).
Specifies that a record field of type Child z
should become a child
element of the current element, containing the textual representation of
the value of type z
.
(KnownSymbol name, ToXText t z) => GToElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child [z]))) Source # | S1 (named) + [Child] - record selector for a list of simple child elements with text. |
(KnownSymbol name, ToXText t z) => GToElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child (Maybe z)))) Source # | S1 (named) + Child Maybe - record selector for an optional simple child element with text. |
(KnownSymbol name, ToXText t z) => GToElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child z))) Source # | S1 (named) + Child - record selector for a simple child element with text. |
(KnownSymbol name, FromXText t z) => GFromElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child [z]))) Source # | S1 (named) + [Child] - record selector for a list of child elements with text content. |
(KnownSymbol name, FromXText t z) => GFromElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child (Maybe z)))) Source # | S1 (named) + Child Maybe - record selector for a simple optional child element with text content. |
(KnownSymbol name, FromXText t z) => GFromElem e n a t (S1 (MetaSel (Just Symbol name) g h i) (Rec0 (Child z))) Source # | S1 (named) + Child - record selector for a simple child element with text content. |
Conv z (Child z) Source # | |
Eq z => Eq (Child z) Source # | |
Show z => Show (Child z) Source # | |
Arbitrary z => Arbitrary (Child z) Source # | |
Conv (Child z) z Source # | |
Content node.
Specifies that a record field of type Content z
should become a content
node of the current element, containing the textual representation of the
value of type z
.
ToXText t z => GToElem e n a t (S1 q (Rec0 (Content (Maybe z)))) Source # | S1 (named or unnamed) + Content Maybe - record selector for an optional content node. |
ToXText t z => GToElem e n a t (S1 q (Rec0 (Content z))) Source # | S1 (named or unnamed) + Content - record selector for a content node. |
FromXText t z => GFromElem e n a t (S1 q (Rec0 (Content (Maybe z)))) Source # | S1 (named or unnamed) + Content Maybe - record selector for an optional content child. |
FromXText t z => GFromElem e n a t (S1 q (Rec0 (Content z))) Source # | S1 (named or unnamed) + Content - record selector for a content child. |
Conv z (Content z) Source # | |
Eq z => Eq (Content z) Source # | |
Show z => Show (Content z) Source # | |
Arbitrary z => Arbitrary (Content z) Source # | |
Conv (Content z) z Source # | |
CData node.
Specifies that a record field of type CData z
should become a CDATA node
of the current element, containing the textual representation of the value
of type z
.
ToXText t z => GToElem e n a t (S1 q (Rec0 (CData [z]))) Source # | S1 (named or unnamed) + [CData] - record selector for a list of CDATA child nodes. |
ToXText t z => GToElem e n a t (S1 q (Rec0 (CData (Maybe z)))) Source # | S1 (named or unnamed) + CData Maybe - record selector for an optional CDATA child node. |
ToXText t z => GToElem e n a t (S1 q (Rec0 (CData z))) Source # | S1 (named or unnamed) + CData - record selector for a CDATA child node. |
FromXText t z => GFromElem e n a t (S1 q (Rec0 (CData [z]))) Source # | S1 (named or unnamed) + [CData] - record selector for a list of CDATA child nodes. |
FromXText t z => GFromElem e n a t (S1 q (Rec0 (CData (Maybe z)))) Source # | S1 (named or unnamed) + CData Maybe - record selector for an optional CDATA child node. |
FromXText t z => GFromElem e n a t (S1 q (Rec0 (CData z))) Source # | S1 (named or unnamed) + CData - record selector for a CDATA child node. |
Conv z (CData z) Source # | |
Eq z => Eq (CData z) Source # | |
Show z => Show (CData z) Source # | |
Arbitrary z => Arbitrary (CData z) Source # | |
Conv (CData z) z Source # | |
Result Types
newtype XTextError Source #
Error which may occur when parsing XML text.
data Result e n a t z Source #
Result of converting an element (type e
) to type z
.
Path to a failure.
Cause of a failure.
Functions
xTextErrType :: Text -> Text -> Either XTextError a Source #
Formats an XTextError
string and returns it as a Left
instance.