-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A tree used to merge and maintain paths -- -- This package contains two modules: Data.LCRSTree and -- Data.PathTree. -- -- A PathTree is a tree used to build unified paths from some -- node. This means being able to merge multiple paths, that may overlap -- at the root, in a sensible way. The module comes with a set of -- functions to add paths. -- -- A Left-Children-Right-Siblings tree (LCRSTree) is a tree that -- represents a multi-way tree (aka, a Rose Tree) in a binary-tree -- format. It is the underlying implementation of PathTree. -- -- -- https://en.wikipedia.org/wiki/Left-child_right-sibling_binary_tree @package PathTree @version 0.1.1.0 module Data.LCRSTree -- | A Left-child-right-sibling tree. -- https://en.wikipedia.org/wiki/Left-child_right-sibling_binary_tree data LCRSTree n Empty :: LCRSTree n Leaf :: n -> (LCRSTree n) -> LCRSTree n Node :: n -> (LCRSTree n) -> (LCRSTree n) -> LCRSTree n -- | Functor instance -- | Return the depth of the tree. This means the depth of the longest -- branch lcrsDepth :: Integral i => LCRSTree n -> i -- | Convert a Tree into a LCRSTree fromRoseTree :: Tree n -> LCRSTree n -- | Convert a LCRSTree into a Tree -- -- This function fails if a non-top Node is passed. A non-top node -- is a node Node n c s where s /= Empty. toRoseTree :: LCRSTree n -> Tree n instance GHC.Classes.Eq n => GHC.Classes.Eq (Data.LCRSTree.LCRSTree n) instance GHC.Show.Show n => GHC.Show.Show (Data.LCRSTree.LCRSTree n) instance GHC.Base.Functor Data.LCRSTree.LCRSTree instance Data.Foldable.Foldable Data.LCRSTree.LCRSTree -- | This module implements multiple functions using a LCRSTree to -- create a tree where the mode of insertion are paths. module Data.PathTree -- | A path tree is simply a LCRSTree type PathTree n = LCRSTree n -- | A Left-child-right-sibling tree. -- https://en.wikipedia.org/wiki/Left-child_right-sibling_binary_tree data LCRSTree n Empty :: LCRSTree n Leaf :: n -> (LCRSTree n) -> LCRSTree n Node :: n -> (LCRSTree n) -> (LCRSTree n) -> LCRSTree n -- | Insert a value a into the path [n] into a tree. insert :: (Eq n) => [n] -> PathTree n -> PathTree n -- | Like insert, but will use f to decide what to do if an -- existing value already exists at the path. insertWith :: (Eq n) => (n -> n -> n) -> [n] -> PathTree n -> PathTree n -- | 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. insertReplace :: (Eq n) => [n] -> PathTree n -> PathTree n -- | Given a single path, create a tree from it. fromPath :: [n] -> PathTree n -- | Like fromPath, but for multiple paths. fromPaths :: Eq n => [[n]] -> PathTree n -- | Like fromPaths but applies f if a give path already -- exists. fromPathsWith :: Eq n => (n -> n -> n) -> [[n]] -> PathTree n -- | Like fromPaths but if two equal paths are passed, the former -- one will be replaced. fromPathsReplace :: Eq n => [[n]] -> PathTree n -- | Returns all paths from the root node(s). Note that toPaths . -- fromPaths may NOT return the same tree back due to some -- reordering of siblings. toPaths :: PathTree n -> [[n]] -- | Given a path, determine if it exists fully. For a path to "exists -- fully" means that it ends on a level that contains a leaf. pathExists :: Eq n => [n] -> LCRSTree n -> Bool