Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- read :: Read FileSourced Void (x -> x) a -> FilePath -> IO (Either String a)
- runRead :: Read FileSourced Void (x -> x) a -> FileSourcedTrees -> Either String a
- type ReadStream src = (HashMap QName (src EscapedAttr), Trees src)
- take1_ :: UnSource src => (Node (src EscapedAttr) -> Bool) -> ReadStream src -> Maybe (Token (ReadStream src), ReadStream src)
- type ReadConstraints src = (Ord (src (Node (src EscapedAttr))), Ord (src EscapedAttr), UnSource src, NoSource src, SourceOf src, Show (Source src), Show (src String), Functor src)
- newtype Read src e f k = Read {
- unRead :: Parsec e (ReadStream src) (f -> k)
- data ReadPerm (src :: * -> *) err a k = ReadPerm {
- readPerm_result :: !(Maybe (a -> k))
- readPerm_parser :: Parsec err (ReadStream src) (ReadPerm src err a k)
- concatCont :: [(a -> k) -> k] -> ([a] -> k) -> k
- consCont :: (a -> b -> c) -> ((a -> k) -> k) -> ((b -> k) -> k) -> (c -> k) -> k
- mapCont :: (a -> b) -> ((a -> k) -> k) -> (b -> k) -> k
- pTokenAttr :: forall e m src. ReadConstraints src => QName -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m (src EscapedAttr)
- pTokenAttrNameClass :: forall e m src. ReadConstraints src => NameClass -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m (QName, src EscapedAttr)
- pTokenPI :: forall e m src. UnSource src => PName -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m Text
- removeXMLNS :: HashMap QName (src EscapedAttr) -> HashMap QName (src EscapedAttr)
- removeSpaces :: UnSource src => Trees src -> Trees src
- readNested :: Ord err => ReadConstraints src => Read src err f a -> ReadStream src -> Read src err f a
- class DecodeText a where
- decodeText :: Parsec Void Text a
- parseErrorTextPretty :: ShowErrorComponent err => ParseError (ReadStream FileSourced) err -> String
- messageItemsPretty :: String -> [String] -> String
- orList :: IsString s => Monoid s => [s] -> s
- showErrorItem :: s ~ ReadStream (Sourced (FileSource Offset)) => Proxy s -> ErrorItem (Token s) -> String
Documentation
read :: Read FileSourced Void (x -> x) a -> FilePath -> IO (Either String a) Source #
Main reading function.
runRead :: Read FileSourced Void (x -> x) a -> FileSourcedTrees -> Either String a Source #
Like readWithRelaxNG
but on a FileSourcedTrees
.
Type ReadStream
type ReadStream src = (HashMap QName (src EscapedAttr), Trees src) Source #
take1_ :: UnSource src => (Node (src EscapedAttr) -> Bool) -> ReadStream src -> Maybe (Token (ReadStream src), ReadStream src) Source #
Take one Node
from the ReadStream
,
or fallback to an attribute, or Nothing
.
Use pTokenAttr
to take only attributes.
Type ReadConstraints
type ReadConstraints src = (Ord (src (Node (src EscapedAttr))), Ord (src EscapedAttr), UnSource src, NoSource src, SourceOf src, Show (Source src), Show (src String), Functor src) Source #
Convenient alias to be less verbose.
Type Read
newtype Read src e f k Source #
Read | |
|
Instances
(Ord err, ReadConstraints src) => Constant (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Dicurryable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Eitherable (Read src err) Source # | |
(Ord err, ReadConstraints src) => Emptyable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Optionable (Read src err) Source # | |
(Ord err, ReadConstraints src) => Repeatable (Read src err) Source # | |
(Ord err, ReadConstraints src) => Tupable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Unitable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Dimapable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Composable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Voidable (Read src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Permutable (Read src err) Source # | |
Defined in Symantic.XML.Read permutable :: Permutation (Read src err) (a -> k) k -> Read src err (a -> k) k perm :: Read src err (a -> k) k -> Permutation (Read src err) (a -> k) k noPerm :: Permutation (Read src err) k k permWithDefault :: a -> Read src err (a -> k) k -> Permutation (Read src err) (a -> k) k optionalPerm :: (Eitherable (Read src err), Dimapable (Read src err), Permutable (Read src err)) => Read src err (a -> k) k -> Permutation (Read src err) (Maybe a -> k) k | |
Ord err => Textable (Read FileSourced err) Source # | |
Defined in Symantic.XML.Read type TextConstraint (Read FileSourced err) a :: Constraint Source # text :: TextConstraint (Read FileSourced err) a => Read FileSourced err (a -> k) k Source # | |
(Ord err, ReadConstraints src, Textable (Read src err)) => XML (Read src err) Source # | |
Defined in Symantic.XML.Read namespace :: Maybe NCName -> Namespace -> Read src err k k Source # element :: QName -> Read src err a k -> Read src err a k Source # attribute :: QName -> Read src err a k -> Read src err a k Source # pi :: PName -> Read src err (Text -> k) k Source # literal :: Text -> Read src err k k Source # | |
Ord err => Definable (Read FileSourced err) Source # | |
Defined in Symantic.XML.Read define :: DefineName -> Read FileSourced err a k -> Read FileSourced err a k Source # | |
(Ord err, ReadConstraints src, Textable (Read src err), Definable (Read src err)) => RelaxNG (Read src err) Source # | |
Defined in Symantic.XML.Read | |
type Permutation (Read src err) Source # | |
Defined in Symantic.XML.Read | |
type TextConstraint (Read FileSourced err) a Source # | |
Defined in Symantic.XML.Read |
Type ReadPerm
data ReadPerm (src :: * -> *) err a k Source #
ReadPerm | |
|
Instances
(Ord err, ReadConstraints src) => Dicurryable (ReadPerm src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Tupable (ReadPerm src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Dimapable (ReadPerm src err) Source # | |
Defined in Symantic.XML.Read | |
(Ord err, ReadConstraints src) => Composable (ReadPerm src err) Source # | |
Defined in Symantic.XML.Read | |
Definable (ReadPerm src err) Source # | |
Defined in Symantic.XML.Read |
Utils
concatCont :: [(a -> k) -> k] -> ([a] -> k) -> k Source #
pTokenAttr :: forall e m src. ReadConstraints src => QName -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m (src EscapedAttr) Source #
An adaptation of megaparsec's pToken
,
to handle attribute
properly.
pTokenAttrNameClass :: forall e m src. ReadConstraints src => NameClass -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m (QName, src EscapedAttr) Source #
An adaptation of megaparsec's pToken
,
to handle attributeMatch
properly.
pTokenPI :: forall e m src. UnSource src => PName -> Set (ErrorItem (Token (ReadStream src))) -> ParsecT e (ReadStream src) m Text Source #
removeXMLNS :: HashMap QName (src EscapedAttr) -> HashMap QName (src EscapedAttr) Source #
readNested :: Ord err => ReadConstraints src => Read src err f a -> ReadStream src -> Read src err f a Source #
readNested v xs
returns a Read
parsing xs
entirely with v
,
updating stateOffset
and re-raising any exception.
Class DecodeText
class DecodeText a where Source #
Instances
DecodeText Bool Source # | |
Defined in Symantic.XML.Read | |
DecodeText Integer Source # | |
Defined in Symantic.XML.Read | |
DecodeText Natural Source # | |
Defined in Symantic.XML.Read | |
DecodeText String Source # | |
Defined in Symantic.XML.Read | |
DecodeText Text Source # | |
Defined in Symantic.XML.Read | |
DecodeText Text Source # | |
Defined in Symantic.XML.Read |
Megaparsec adaptations
parseErrorTextPretty :: ShowErrorComponent err => ParseError (ReadStream FileSourced) err -> String Source #
Rewrite parseErrorTextPretty
to keep Ord
of node
s.
showErrorItem :: s ~ ReadStream (Sourced (FileSource Offset)) => Proxy s -> ErrorItem (Token s) -> String Source #