Copyright | (c) Callum Lowcay 2017 |
---|---|
License | BSD3 |
Maintainer | cwslowcay@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
This module contains monads and utility functions for extracting GEDCOM records from the raw syntax tree.
- type StructureParser a = GDTree -> StructureMonad (Either GDTree a)
- data MultiMonad a
- runMultiMonad :: [GDTree] -> MultiMonad a -> StructureMonad a
- parseMulti :: StructureParser a -> MultiMonad [a]
- parseOptional :: StructureParser a -> MultiMonad (Maybe a)
- parseRequired :: GDTag -> StructureParser a -> MultiMonad a
- data StructureMonad a
- addReference :: Typeable a => GDXRefID -> a -> StructureMonad ()
- runStructure :: StructureMonad a -> (Either GDError a, Map GDXRefID Dynamic)
Documentation
type StructureParser a Source #
= GDTree | The subtree to parse. |
-> StructureMonad (Either GDTree a) | Either parsed structure, or the subtree itself if the subtree doesn't contain the expected GEDCOM structure. |
A parser that extracts a GEDCOM structure from a GEDCOM subtree.
data MultiMonad a Source #
A Monad for parsing GEDCOM structures out of a list of GEDCOM subtrees.
:: [GDTree] | The subtrees to parse the structure from. |
-> MultiMonad a | The MultiMonad that does the parsing. |
-> StructureMonad a |
Run a MultiMonad
into a StructureMonad
.
parseMulti :: StructureParser a -> MultiMonad [a] Source #
Parse multiple instances of a structure
parseOptional :: StructureParser a -> MultiMonad (Maybe a) Source #
Parse an optional instance of a structure
:: GDTag | The tag that identifies the required structure. |
-> StructureParser a | |
-> MultiMonad a |
Parse a required instance of a structure
data StructureMonad a Source #
A monad for parsing an instance of a GEDCOM structure from a GEDCOM subtree.
:: Typeable a | |
=> GDXRefID | The cross reference to add. |
-> a | The value the reference will resolve to. |
-> StructureMonad () |
Add a reference to the cross reference table.
runStructure :: StructureMonad a -> (Either GDError a, Map GDXRefID Dynamic) Source #
Run a StructureMonad
, returning either an error or a value, and the
cross reference table.