This commit is contained in:
2025-09-24 12:28:24 +01:00
parent eb068f5335
commit da8230fe00
2 changed files with 52 additions and 53 deletions
+3 -4
View File
@@ -45,7 +45,7 @@ shiftChildren :: Tree ([Tree a], a) -> Tree a
shiftChildren (Node (ts, x) ts') = Node x (ts ++ map shiftChildren ts')
composeTree :: MetaTree a b -> Tree a
composeTree mt = attachList' (composeNode $ _mtTree mt) (_mtBranches mt)
composeTree mt = attachList (composeNode $ _mtTree mt) (_mtBranches mt)
mtTopLabels :: MetaTree a b -> Tree b
mtTopLabels (MTree lab _ bs) = Node lab (map (mtTopLabels . _mbTree) bs)
@@ -67,7 +67,6 @@ decomposeSelfTree st = fmap fst (_unST st) : concatMap (f . snd) (_unST st)
combineTree :: (a -> b) -> MetaTree a b -> SelfTree b
combineTree f mt = case _mtTree mt of
NodeTree t -> ST (Node (_mtLabel mt, Left $ fmap f t) (_unST . combineTree f . _mbTree <$> _mtBranches mt))
--NodeTree t -> ST (Node (Left $ fmap f t) _)
NodeMTree mt' ->
ST
( Node (_mtLabel mt, Right $ combineTree f mt') $
@@ -78,8 +77,8 @@ composeNode :: MetaNode a b -> Tree a
composeNode (NodeTree t) = t
composeNode (NodeMTree mt) = composeTree mt
attachList' :: Tree a -> [MetaBranch a b] -> Tree a
attachList' t = shiftChildren . foldr attachBranch (fmap ([],) t)
attachList :: Tree a -> [MetaBranch a b] -> Tree a
attachList t = shiftChildren . foldr attachBranch (fmap ([],) t)
attachBranch :: MetaBranch a b -> Tree ([Tree a], a) -> Tree ([Tree a], a)
attachBranch mb =