Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- type Path = [String]
- data Err
- = ErrExpectContent { }
- | ErrExpectAttrib { }
- | ErrAttribValue { }
- | ErrEnd { }
- | ErrNull { }
- | ErrMsg String
- data ExtractionErr = ExtractionErr {}
- type ElementExtractor a = ReaderT (Path, Element) (ResultT ExtractionErr Identity) a
- runElementExtractor :: ElementExtractor a -> Element -> Path -> Result ExtractionErr a
- attrib :: String -> ElementExtractor String
- attribAs :: String -> (String -> Either String a) -> ElementExtractor a
- children :: ContentsExtractor a -> ElementExtractor a
- contents :: ContentsExtractor a -> ElementExtractor a
- type ContentsExtractor a = StateT Ctx (ResultT ExtractionErr Identity) a
- runContentsExtractor :: ContentsExtractor a -> [Content] -> Int -> Path -> Result ExtractionErr (a, Ctx)
- element :: String -> ElementExtractor a -> ContentsExtractor a
- text :: ContentsExtractor String
- textAs :: (String -> Either Err a) -> ContentsExtractor a
- anyContent :: ContentsExtractor Content
- eoc :: ContentsExtractor ()
Documentation
Location for some content.
For now it is a reversed list of content indices (starting at 1) and element names. This may change to something less "stringly typed".
Extraction errors.
ErrExpectContent | Some expected content is missing |
ErrExpectAttrib | An expected attribute is missing |
| |
ErrAttribValue | An attribute value was bad |
| |
ErrEnd | Expected end of contents |
ErrNull | Unexpected end of contents |
ErrMsg String |
Element extraction
type ElementExtractor a = ReaderT (Path, Element) (ResultT ExtractionErr Identity) a Source
runElementExtractor :: ElementExtractor a -> Element -> Path -> Result ExtractionErr a Source
attrib :: String -> ElementExtractor String Source
:: String | name of attribute to extract |
-> (String -> Either String a) | function returning given string to some value or an error message |
-> ElementExtractor a |
children :: ContentsExtractor a -> ElementExtractor a Source
contents :: ContentsExtractor a -> ElementExtractor a Source
Contents extraction
type ContentsExtractor a = StateT Ctx (ResultT ExtractionErr Identity) a Source
runContentsExtractor :: ContentsExtractor a -> [Content] -> Int -> Path -> Result ExtractionErr (a, Ctx) Source
element :: String -> ElementExtractor a -> ContentsExtractor a Source
eoc :: ContentsExtractor () Source