Copyright | (c) 2021-2022 Mirko Westermeier |
---|---|
License | MIT |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
HTMell content tree related types and functions.
Synopsis
- type HTree c = Tree (String, Maybe c)
- name :: HTree c -> String
- content :: HTree c -> Maybe c
- children :: Tree c -> Forest c
- childList :: HTree c -> [(String, HTree c)]
- isLeaf :: HTree c -> Bool
- isInnerNode :: HTree c -> Bool
- summary :: HTree c -> String
- drawHTree :: HTree c -> String
- findNode :: HTree c -> String -> Maybe (HTree c)
- processTree :: (String -> Maybe a -> [HTree b] -> HTree b) -> HTree a -> HTree b
The content tree type
type HTree c = Tree (String, Maybe c) #
The main content tree type, having pairs of name and content as nodes
Basic tree operations
childList :: HTree c -> [(String, HTree c)] #
All child nodes of the given tree, addressed by their name
isInnerNode :: HTree c -> Bool #
True iff the given HTree
node has children.
String representation
summary :: HTree c -> String #
Very short structural summary of a given tree, considering names only,
separated by ","
, children in "("
and ")"
.
Example: The tree loaded from the following filesystem structure
content |--- 1_foo.md '--- 2_bar |--- 42_baz.md '--- 17_quux.md
has the summary
"(foo,bar(quux,baz))"
.
Content queries
Refer to HTMell for an explanation of how directory and file names
correspond to the HTree
s names in a content tree.
Tree transformation
:: (String -> Maybe a -> [HTree b] -> HTree b) | A function that modifies a given deconstructed |
-> HTree a | The tree to modify. |
-> HTree b | The modified tree. |
Bottom-up inside-out processing of a content tree. Each node will be
modified by the given function, possibly changing the tree's
HTMellContent
instance.