data-named-0.2.0: Data types for named entities

Safe HaskellNone

Text.Named.Enamex

Description

Parsing text in the Enamex data format. Each node is enclosed between opening and closing tags with tag name representing the label and contents representing children of the node. Both leaf and label values should be escaped by prepending the \ character before special >, <, \ and space characters.

Example:

>>> :m Data.Tree Data.Text Text.Named.Enamex
>>> let drawIt = putStr . drawForest . fmap (fmap unpack) . parseForest
>>> drawIt $ pack "<x>w1.1\\ w1.2</x> <y><z>w2</z> w3</y>"
x
|
`- w1.1 w1.2
,
y
|
+- z
|  |
|  `- w2
|
`- w3

Synopsis

Documentation

parseForest :: Text -> ForestSource

Parse the enamex forest.

parseEnamex :: Text -> [Forest]Source

Parse the enamex file.

mapTwo :: (a -> b) -> (a -> c) -> Tree a -> Tree (Either b c)Source

Map the first function over internal nodes and the second one over leaves.