This commit is contained in:
2022-06-10 23:10:38 +01:00
parent 6966e76206
commit ad576014fb
8 changed files with 41 additions and 37 deletions
+7
View File
@@ -12,6 +12,8 @@ module Dodge.Tree.Compose
, overwriteLabel
, composeTree
, composeTree'
, shiftChildren
, attachTree
, composeTreeRand
-- , compTree
) where
@@ -124,6 +126,11 @@ newf t = safeUpdateSingleNode (isJust . upf . snd) ( (root . _2 %~ g) . (root .
upf = t ^?! root . _1
g x = fromMaybe x (upf x)
attachTree :: (a -> Maybe a) -> Tree a -> Tree ([Tree a],a) -> Tree ([Tree a],a)
attachTree upf t = safeUpdateSingleNode (isJust . upf . snd) ( (root . _2 %~ g) . (root . _1 .:~ t ) )
where
g x = fromMaybe x (upf x)
shiftChildren :: Tree ([Tree a],a) -> Tree a
shiftChildren (Node (ts,x) ts') = Node x (ts ++ map shiftChildren ts')