[{"name":"Forest.Navigate","comment":" Additional helpers for a list of [zwilias/elm-rosetree](https://package.elm-lang.org/packages/zwilias/elm-rosetree/latest/)s\nusing [`ForestPath`](Forest-Path#ForestPath)\n\n@docs Forest\n\n\n## observe\n\n@docs to\n\n\n## altering\n\n@docs alter, remove, map\n\n","unions":[],"aliases":[{"name":"Forest","comment":" A `List` of [zwilias/elm-rosetree](https://package.elm-lang.org/packages/zwilias/elm-rosetree/latest/)s\n\nExample use cases\n\n  - a tree-view without a common parent\n  - nestable tabs\n  - comments of a post where comment and post types are different\n\n","args":["label"],"type":"List.List (Tree.Tree label)"}],"values":[{"name":"alter","comment":" Change its sub-tree at a given [`ForestPath`](Forest-Path#ForestPath) based on its current value.\n\n    import Tree exposing (tree)\n    import Forest.Navigate\n    import Tree.Path\n    import Forest.Path\n\n    [ Tree.singleton \"gee\"\n    , tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            , Tree.singleton \"bee\"\n            ]\n        ]\n    ]\n        |> Forest.Navigate.alter (Forest.Path.fromIndex 1 (Tree.Path.follow [ 1, 2 ]))\n            (Tree.mapLabel String.toUpper)\n    --> [ Tree.singleton \"gee\"\n    --> , tree \"jo\"\n    -->     [ Tree.singleton \"ann\"\n    -->     , tree \"mic\"\n    -->         [ Tree.singleton \"igg\"\n    -->         , Tree.singleton \"dee\"\n    -->         , Tree.singleton \"BEE\"\n    -->         ]\n    -->     ]\n    --> ]\n\n    [ Tree.singleton \"gee\"\n    , tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            ]\n        ]\n    ]\n        |> Forest.Navigate.alter (Forest.Path.fromIndex 1 (Tree.Path.follow [ 1, 2 ]))\n            (Tree.mapLabel String.toUpper)\n    --> [ Tree.singleton \"gee\"\n    --> , tree \"jo\"\n    -->     [ Tree.singleton \"ann\"\n    -->     , tree \"mic\"\n    -->         [ Tree.singleton \"igg\"\n    -->         , Tree.singleton \"dee\"\n    -->         ]\n    -->     ]\n    --> ]\n\n","type":"Forest.Path.ForestPath -> (Tree.Tree label -> Tree.Tree label) -> Forest.Navigate.Forest label -> Forest.Navigate.Forest label"},{"name":"map","comment":" Change every tree label based on its [`ForestPath`](Forest-Path#ForestPath) and current value.\n\n    import Tree exposing (tree)\n    import Forest.Navigate\n    import Forest.Path\n    import Tree.Path\n\n    [ Tree.singleton -1\n    , tree 1\n        [ Tree.singleton 2\n        , tree 3 [ Tree.singleton 4 ]\n        , Tree.singleton 5\n        ]\n    ]\n        |> Forest.Navigate.map\n            (\\n -> ( n.label * 2, n.path ))\n    --> [ Tree.singleton ( -2, Forest.Path.fromIndex 0 Tree.Path.atTrunk )\n    --> , tree ( 2, Forest.Path.fromIndex 1 Tree.Path.atTrunk )\n    -->     [ Tree.singleton ( 4, Forest.Path.fromIndex 1 (Tree.Path.follow [ 0 ]) )\n    -->     , tree ( 6, Forest.Path.fromIndex 1 (Tree.Path.follow [ 1 ]) )\n    -->         [ Tree.singleton ( 8, Forest.Path.fromIndex 1 (Tree.Path.follow [ 1, 0 ]) ) ]\n    -->     , Tree.singleton ( 10, Forest.Path.fromIndex 1 (Tree.Path.follow [ 2 ]) )\n    -->     ]\n    --> ]\n\n","type":"({ label : label, path : Forest.Path.ForestPath } -> mappedLabel) -> Forest.Navigate.Forest label -> Forest.Navigate.Forest mappedLabel"},{"name":"remove","comment":" Remove the sub-`Tree` at the end of a given [`ForestPath`](Forest-Path#ForestPath)\nand its children.\n\n    import Tree exposing (tree)\n    import Forest.Navigate\n    import Tree.Path\n    import Forest.Path\n\n    [ Tree.singleton \"ann\"\n    , tree \"mic\"\n        [ Tree.singleton \"igg\"\n        , Tree.singleton \"dee\"\n        , Tree.singleton \"bee\"\n        ]\n    ]\n        |> Forest.Navigate.remove (Forest.Path.fromIndex 1 (Tree.Path.follow [ 2 ]))\n    --> [ Tree.singleton \"ann\"\n    --> , tree \"mic\"\n    -->     [ Tree.singleton \"igg\"\n    -->     , Tree.singleton \"dee\"\n    -->     ]\n    --> ]\n\n\n    [ Tree.singleton \"ann\"\n    , tree \"mic\"\n        [ Tree.singleton \"igg\"\n        , Tree.singleton \"dee\"\n        ]\n    ]\n        |> Forest.Navigate.remove (Forest.Path.fromIndex 1 (Tree.Path.follow [ 2 ]))\n    --> [ Tree.singleton \"ann\"\n    --> , tree \"mic\"\n    -->     [ Tree.singleton \"igg\"\n    -->     , Tree.singleton \"dee\"\n    -->     ]\n    --> ]\n\n","type":"Forest.Path.ForestPath -> Forest.Navigate.Forest label -> Forest.Navigate.Forest label"},{"name":"to","comment":" Following the [`ForestPath`](Forest-Path#ForestPath), where do we end?\n\n    import Tree exposing (tree)\n    import Forest.Navigate\n    import Tree.Path\n    import Forest.Path\n\n    [ Tree.singleton \"gee\"\n    , tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            , Tree.singleton \"bee\"\n            ]\n        ]\n    ]\n        |> Forest.Navigate.to (Forest.Path.fromIndex 1 (Tree.Path.follow [ 1, 2 ]))\n    --> Just (Tree.singleton \"bee\")\n\n    [ Tree.singleton \"gee\"\n    , tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            ]\n        ]\n    ]\n        |> Forest.Navigate.to (Forest.Path.fromIndex 1 (Tree.Path.follow [ 1, 2 ]))\n    --> Nothing\n\n","type":"Forest.Path.ForestPath -> Forest.Navigate.Forest label -> Maybe.Maybe (Tree.Tree label)"}],"binops":[]},{"name":"Forest.Path","comment":" Location in a [`Forest`](Forest-Navigate#Forest)\n\n@docs ForestPath\n\n\n## create\n\n@docs fromIndex\n\n\n## observe\n\n@docs treeIndex, pathIntoTreeAtIndex\n\n\n## alter\n\n@docs toChild\n\n","unions":[],"aliases":[{"name":"ForestPath","comment":" The unique location of a `Tree` in a [`Forest`](Forest-Navigate#Forest).\n\nDescribes which tree to step inside\nplus the [`TreePath`](Tree-Path#TreePath) to navigate inside that tree.\n\nRepresented as a tuple to simplify pattern matching and enable using it as a `comparable` key.\n\nInstead of working with that `List` directly, I recommend using the helpers here to create and operate on these paths.\n\n","args":[],"type":"( Basics.Int, Tree.Path.TreePath )"}],"values":[{"name":"fromIndex","comment":" Construct a [`ForestPath`](#ForestPath)\nfrom the [`treeIndex`](#treeIndex) and [`pathIntoTreeAtIndex`](#pathIntoTreeAtIndex)\n\n    import Tree\n    import Tree.Path\n    import Forest.Navigate\n\n    [ Tree.singleton 0\n    , Tree.singleton 1\n    ]\n        |> Forest.Navigate.to (Forest.Path.fromIndex 1 Tree.Path.atTrunk)\n    --> Just (Tree.singleton 1)\n\n","type":"Basics.Int -> Tree.Path.TreePath -> Forest.Path.ForestPath"},{"name":"pathIntoTreeAtIndex","comment":" The [`TreePath`](Tree-Path#TreePath) to navigate inside the tree at the [`treeIndex`](#treeIndex).\n","type":"Forest.Path.ForestPath -> Tree.Path.TreePath"},{"name":"toChild","comment":" The path to its ...th child from there.\n\n    import Tree.Path\n\n    Forest.Path.fromIndex 1 Tree.Path.atTrunk\n        |> Forest.Path.toChild 4\n        |> Forest.Path.toChild 1\n        |> Forest.Path.toChild 8\n    --> Forest.Path.fromIndex 1 (Tree.Path.follow [ 4, 1, 8 ])\n\nAt the first tree:\n\n1.  Take the branch at index 4\n2.  Then take its branch at index 1\n3.  Its child at index 8 is where the navigation should end\n\n","type":"Basics.Int -> Forest.Path.ForestPath -> Forest.Path.ForestPath"},{"name":"treeIndex","comment":" Which tree to step inside in a [`Forest`](Forest-Navigate#Forest)\n","type":"Forest.Path.ForestPath -> Basics.Int"}],"binops":[]},{"name":"Tree.Navigate","comment":" Additional helpers for a [zwilias/elm-rosetree](https://package.elm-lang.org/packages/zwilias/elm-rosetree/latest/)\nusing [`TreePath`](Tree-Path#TreePath)\n\n\n## observe\n\n@docs to\n\n\n## altering\n\n@docs map, alter\n\n\n## transform\n\n@docs restructure\n\n","unions":[],"aliases":[],"values":[{"name":"alter","comment":" Change its sub-tree at a given [`TreePath`](Tree-Path#TreePath) based on its current value.\n\n    import Tree exposing (tree)\n    import Tree.Navigate\n    import Tree.Path\n\n    tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            , Tree.singleton \"bee\"\n            ]\n        ]\n        |> Tree.Navigate.alter (Tree.Path.follow [ 1, 2 ])\n            (Tree.mapLabel String.toUpper)\n    --> tree \"jo\"\n    -->     [ Tree.singleton \"ann\"\n    -->     , tree \"mic\"\n    -->         [ Tree.singleton \"igg\"\n    -->         , Tree.singleton \"dee\"\n    -->         , Tree.singleton \"BEE\"\n    -->         ]\n    -->     ]\n\n    tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            ]\n        ]\n        |> Tree.Navigate.alter (Tree.Path.follow [ 1, 2 ])\n            (Tree.mapLabel String.toUpper)\n    --> tree \"jo\"\n    -->     [ Tree.singleton \"ann\"\n    -->     , tree \"mic\"\n    -->         [ Tree.singleton \"igg\"\n    -->         , Tree.singleton \"dee\"\n    -->         ]\n    -->     ]\n\n","type":"Tree.Path.TreePath -> (Tree.Tree a -> Tree.Tree a) -> Tree.Tree a -> Tree.Tree a"},{"name":"map","comment":" Change every label based on its [`TreePath`](Tree-Path#TreePath) and current value.\n\n    import Tree exposing (tree)\n    import Tree.Navigate\n    import Tree.Path\n\n    tree 1\n        [ Tree.singleton 2\n        , tree 3 [ Tree.singleton 4 ]\n        , Tree.singleton 5\n        ]\n        |> Tree.Navigate.map\n            (\\n -> ( n.label * 2, n.path ))\n    --> tree ( 2, Tree.Path.atTrunk )\n    -->     [ Tree.singleton ( 4, Tree.Path.follow [ 0 ] )\n    -->     , tree ( 6, Tree.Path.follow [ 1 ] )\n    -->         [ Tree.singleton ( 8, Tree.Path.follow [ 1, 0 ] ) ]\n    -->     , Tree.singleton ( 10, Tree.Path.follow [ 2 ] )\n    -->     ]\n\n\n    tree 0 [ Tree.singleton 1, tree 2 [ Tree.singleton 3 ], Tree.singleton 5 ]\n        |> Tree.Navigate.map identity\n        |> Tree.flatten\n    --> [ { label = 0, path = Tree.Path.atTrunk }\n    --> , { label = 1, path = Tree.Path.follow [ 0 ] }\n    --> , { label = 2, path = Tree.Path.follow [ 1 ] }\n    --> , { label = 3, path = Tree.Path.follow [ 1, 0 ] }\n    --> , { label = 5, path = Tree.Path.follow [ 2 ] }\n    --> ]\n\n","type":"({ path : Tree.Path.TreePath, label : label } -> mappedLabel) -> Tree.Tree label -> Tree.Tree mappedLabel"},{"name":"restructure","comment":" A powerful tree transformation which can be described as \"replacing the tree node constructors\"\n\n    invertTree : Tree label -> Tree label\n    invertTree =\n        Tree.Navigate.restructure (\\sub -> tree sub.label (sub.children |> List.reverse))\n\n    toPreOrder : Tree label -> List label\n    toPreOrder =\n        Tree.Navigate.restructure (\\sub -> sub.label :: (sub.children |> List.concat))\n\n    type DifferentTree a\n        = DifferentTree a (List (DifferentTree a))\n\n    toDifferentTree : Tree label -> DifferentTree label\n    toDifferentTree =\n        Tree.Navigate.restructure (\\sub -> DifferentTree sub.label sub.children)\n\nOther names for this pattern are \"unwrap\", \"fold\" and [\"banana\"](https://en.wikipedia.org/wiki/Catamorphism#Terminology_and_history)\nResources I can recommend:\n\n  - [video recording \"Inverting a binary tree with 1 line of Elm - Joël\" from elm online meetup](https://www.youtube.com/watch?v=dSMB3rsufC8)\n  - [blog post \"folds are constructor substitution\"](https://www.haskellforall.com/2021/02/folds-are-constructor-substitution.html)\n\nAdditionally, you get the [`TreePath`](Tree-Path#TreePath) at each step. Check the readme for how this can be useful.\n\n","type":"({ path : Tree.Path.TreePath, label : label, children : List.List folded } -> folded) -> Tree.Tree label -> folded"},{"name":"to","comment":" Following the [`TreePath`](Tree-Path#TreePath), where do we end?\n\n    import Tree exposing (tree)\n    import Tree.Navigate\n    import Tree.Path\n\n    Tree.singleton \"jo\"\n        |> Tree.Navigate.to Tree.Path.atTrunk\n    --> Just (Tree.singleton \"jo\")\n\n    tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            , Tree.singleton \"bee\"\n            ]\n        ]\n        |> Tree.Navigate.to (Tree.Path.follow [ 1, 2 ])\n    --> Just (Tree.singleton \"bee\")\n\n    tree \"jo\"\n        [ Tree.singleton \"ann\"\n        , tree \"mic\"\n            [ Tree.singleton \"igg\"\n            , Tree.singleton \"dee\"\n            ]\n        ]\n        |> Tree.Navigate.to (Tree.Path.follow [ 1, 2 ])\n    --> Nothing\n\n","type":"Tree.Path.TreePath -> Tree.Tree label -> Maybe.Maybe (Tree.Tree label)"}],"binops":[]},{"name":"Tree.Path","comment":" Location in a [`Tree`](https://package.elm-lang.org/packages/zwilias/elm-rosetree/latest/)\n\n@docs TreePath, atTrunk, follow\n\n\n## observe\n\n@docs depth, targetsChildOf, targetsParentOf\n\n\n## alter\n\n@docs step, toParent, toChild\n\n","unions":[],"aliases":[{"name":"TreePath","comment":" The unique location of a (child-)`Tree` in a [`Tree`](https://package.elm-lang.org/packages/zwilias/elm-rosetree/latest/).\n\nYou describe which branch index to go along every step.\n\n    [ {-first go to its child at index-}0\n    , {-then go to the child of its child at index-}2\n    , ...\n    ]\n\nRepresented as a tuple to simplify pattern matching and enable using it as a `comparable` key.\n\nInstead of working with that `List` directly, I recommend using the helpers here to create and operate on these paths.\n\n","args":[],"type":"List.List Basics.Int"}],"values":[{"name":"atTrunk","comment":" Stay at that tree. Don't go anywhere.\n\n    Tree.Path.atTrunk\n    --> Tree.Path.follow []\n\n    Tree.Path.atTrunk\n        |> Tree.Path.depth\n    --> 0\n\n","type":"Tree.Path.TreePath"},{"name":"depth","comment":" On which level of sub-branch is the final tree located?\n\n    Tree.Path.depth Tree.Path.atTrunk\n    --> 0\n\n    Tree.Path.atTrunk\n        |> Tree.Path.toChild 5\n        |> Tree.Path.toChild 2\n        |> Tree.Path.toChild 0\n        |> Tree.Path.depth\n    --> 3\n\n","type":"Tree.Path.TreePath -> Basics.Int"},{"name":"follow","comment":" Conveniently describe the route to go from the trunk.\n\n    Tree.Path.follow [ 2, 4, 0 ]\n    --> [ 2, 4, 0 ]\n\n    -- or\n    Tree.Path.follow [ 2, 4, 0 ]\n    --> Tree.Path.atTrunk\n    -->     |> Tree.Path.toChild 2\n    -->     |> Tree.Path.toChild 4\n    -->     |> Tree.Path.toChild 0\n\n","type":"List.List Basics.Int -> Tree.Path.TreePath"},{"name":"step","comment":" Try to navigate to a child index, returning a [`ForestPath`](Forest-Path#ForestPath) for the children.\n\n    import Tree exposing (Tree)\n    import Tree.Path exposing (TreePath)\n\n\n    Tree.Path.follow [ 2, 4, 0 ]\n        |> Tree.Path.step\n    --> Just ( 2, Tree.Path.follow [ 4, 0 ] )\n\n    Tree.Path.atTrunk\n        |> Tree.Path.step\n    --> Nothing\n\n    -- in this package as Tree.Navigate.to\n    at path =\n        case Tree.Path.step path of\n            Nothing ->\n                Just\n\n            Just ( index, further ) ->\n                Tree.children\n                    >> List.getAt index\n                    >> Maybe.andThen (at further)\n\n","type":"Tree.Path.TreePath -> Maybe.Maybe Tree.Path.ForestPath"},{"name":"targetsChildOf","comment":" Does this path lead to a child or child of a child or ... of the tree at this path?\n\n    Tree.Path.follow [ 2, 3, 0 ]\n        |> Tree.Path.targetsChildOf\n            (Tree.Path.follow [ 2, 3 ])\n    --> True\n\n    Tree.Path.follow [ 2 ]\n        |> Tree.Path.targetsChildOf\n            (Tree.Path.follow [ 2, 3 ])\n    --> False\n\n","type":"Tree.Path.TreePath -> Tree.Path.TreePath -> Basics.Bool"},{"name":"targetsParentOf","comment":" Does this path lead to its parent or the parent of its parent or ... of the tree at this path?\n\n    Tree.Path.follow [ 2 ]\n        |> Tree.Path.targetsParentOf\n            (Tree.Path.follow [ 2, 3 ])\n    --> True\n\n    Tree.Path.follow [ 2, 3, 0 ]\n        |> Tree.Path.targetsParentOf\n            (Tree.Path.follow [ 2, 3 ])\n    --> False\n\n","type":"Tree.Path.TreePath -> Tree.Path.TreePath -> Basics.Bool"},{"name":"toChild","comment":" The path to its ...th child from there.\n\n    Tree.Path.atTrunk\n        |> Tree.Path.toChild 4\n        |> Tree.Path.toChild 1\n        |> Tree.Path.toChild 8\n    --> Tree.Path.follow [ 4, 1, 8 ]\n\n1.  Take the branch at index 4\n2.  Then take its branch at index 1\n3.  Its child at index 8 is where the navigation should end\n\nExample ↓ is for illustration only.\nYou'll have a much easier time using [`Tree.Navigate.restructure`](Tree-Navigate#restructure).\n\n    view path tree =\n        button [ onPress (Clicked path) ]\n            :: (Tree.children tree\n                    |> List.indexedMap\n                        (\\index ->\n                            view (path |> Tree.Path.toChild index)\n                        )\n               )\n            |> column [ padding (10 / Tree.Path.depth path) ]\n\n","type":"Basics.Int -> Tree.Path.TreePath -> Tree.Path.TreePath"},{"name":"toParent","comment":" The `TreePath` to its parent tree – if there is one.\n\n    Tree.Path.follow [ 1, 2, 3 ]\n        |> Tree.Path.toParent\n    --> Just (Tree.Path.follow [ 1, 2 ])\n\n    Tree.Path.atTrunk\n        |> Tree.Path.toParent\n    --> Nothing\n\n","type":"Tree.Path.TreePath -> Maybe.Maybe Tree.Path.TreePath"}],"binops":[]}]