diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/collection/tree/zipper.lux | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/stdlib/source/lux/data/collection/tree/zipper.lux b/stdlib/source/lux/data/collection/tree/zipper.lux index d4b7ec4f6..a0b9eca9c 100644 --- a/stdlib/source/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/lux/data/collection/tree/zipper.lux @@ -9,15 +9,14 @@ [data ["." maybe ("#@." monad)] [collection - ["." list ("#@." functor fold monoid)] - ["." stack (#+ Stack)]]]] + ["." list ("#@." functor fold monoid)]]]] ["." // (#+ Tree) ("#@." functor)]) (type: #export (Zipper a) {#.doc "Tree zippers, for easy navigation and editing over trees."} {#parent (Maybe (Zipper a)) - #lefts (Stack (Tree a)) - #rights (Stack (Tree a)) + #lefts (List (Tree a)) + #rights (List (Tree a)) #node (Tree a)}) (structure: #export (equivalence ,equivalence) @@ -28,10 +27,10 @@ (and (:: (//.equivalence ,equivalence) = (get@ #node reference) (get@ #node sample)) - (:: (stack.equivalence (//.equivalence ,equivalence)) = + (:: (list.equivalence (//.equivalence ,equivalence)) = (get@ #lefts reference) (get@ #lefts sample)) - (:: (stack.equivalence (//.equivalence ,equivalence)) = + (:: (list.equivalence (//.equivalence ,equivalence)) = (get@ #rights reference) (get@ #rights sample)) (:: (maybe.equivalence (equivalence ,equivalence)) = @@ -42,8 +41,8 @@ (def: #export (zip tree) (All [a] (-> (Tree a) (Zipper a))) {#parent #.None - #lefts stack.empty - #rights stack.empty + #lefts #.Nil + #rights #.Nil #node tree}) (def: #export (unzip zipper) @@ -83,7 +82,7 @@ (#.Cons head tail) {#parent (#.Some zipper) - #lefts stack.empty + #lefts #.Nil #rights tail #node head})) @@ -203,8 +202,8 @@ (function (_ children) (list& (for {@.old (: (Tree ($ 0)) - (//.tree [value {}]))} - (//.tree [value {}])) + (//.tree value {}))} + (//.tree value {})) children)) zipper)) @@ -215,8 +214,8 @@ (list@compose children (list (for {@.old (: (Tree ($ 0)) - (//.tree [value {}]))} - (//.tree [value {}]))))) + (//.tree value {}))} + (//.tree value {}))))) zipper)) (def: #export (remove zipper) @@ -248,8 +247,8 @@ (update@ <side> (function (_ side) (#.Cons (for {@.old (: (Tree ($ 0)) - (//.tree [value {}]))} - (//.tree [value {}])) + (//.tree value {}))} + (//.tree value {})) side)))))))] [insert-left #lefts] |