Copyright | (c) Pedro Rodriguez Tavarez <pedro@pjrt.co> |
---|---|

License | BSD3-style (see LICENSE) |

Maintainer | Pedro Rodriguez Tavarez <pedro@pjrt.co> |

Stability | unstable |

Portability | unportable |

Safe Haskell | Safe |

Language | Haskell2010 |

This module implements multiple functions using a `LCRSTree`

to create a
tree where the mode of insertion are paths.

- type PathTree n = LCRSTree n
- data LCRSTree n
- insert :: Eq n => [n] -> PathTree n -> PathTree n
- insertWith :: Eq n => (n -> n -> n) -> [n] -> PathTree n -> PathTree n
- insertReplace :: Eq n => [n] -> PathTree n -> PathTree n
- fromPath :: [n] -> PathTree n
- fromPaths :: Eq n => [[n]] -> PathTree n
- fromPathsWith :: Eq n => (n -> n -> n) -> [[n]] -> PathTree n
- fromPathsReplace :: Eq n => [[n]] -> PathTree n
- toPaths :: PathTree n -> [[n]]
- pathExists :: Eq n => [n] -> LCRSTree n -> Bool

# Documentation

A Left-child-right-sibling tree. https://en.wikipedia.org/wiki/Left-child_right-sibling_binary_tree

insert :: Eq n => [n] -> PathTree n -> PathTree n Source #

Insert a value *a* into the path *[n]* into a tree.

insertWith :: Eq n => (n -> n -> n) -> [n] -> PathTree n -> PathTree n Source #

Like `insert`

, but will use *f* to decide what to do if an existing
value already exists at the path.

insertReplace :: Eq n => [n] -> PathTree n -> PathTree n Source #

Like `insert`

, but replaces the value at the path. May seem odd to
replace a value that is equal to itself, but this can be used with
partially-equal types for some flexibility.

fromPathsWith :: Eq n => (n -> n -> n) -> [[n]] -> PathTree n Source #

Like `fromPaths`

but applies *f* if a give path already exists.

fromPathsReplace :: Eq n => [[n]] -> PathTree n Source #

Like `fromPaths`

but if two equal paths are passed, the former one
will be replaced.