Cleanup
This commit is contained in:
@@ -16,6 +16,7 @@ module Dodge.Tree.Compose
|
||||
-- , composeAndLog
|
||||
, toOnward
|
||||
, attachOnward
|
||||
, showIntsString
|
||||
-- , cmpToMT
|
||||
-- , compTree
|
||||
, module Dodge.Tree.Compose.Data
|
||||
@@ -27,6 +28,7 @@ import TreeHelp
|
||||
--import Dodge.Base
|
||||
import LensHelp
|
||||
|
||||
import Data.List (intersperse)
|
||||
import Data.Tuple
|
||||
--import Data.Bifunctor
|
||||
--import Control.Monad.State
|
||||
@@ -201,7 +203,7 @@ 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) (fmap (_unST . combineTree f . _mbTree) $ _mtBranches mt))
|
||||
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')
|
||||
$ map (_unST . combineTree f . _mbTree) $ _mtBranches mt)
|
||||
@@ -233,6 +235,7 @@ toOnward rm
|
||||
= Just (rm & rmClusterStatus . csLinks . at OnwardCluster .~ Nothing)
|
||||
| otherwise = Nothing
|
||||
|
||||
numSelfTree :: SelfTree a -> SelfTree ([Int],a)
|
||||
numSelfTree st = evalState (numSelfTree' st) [0]
|
||||
|
||||
numSelfTree' :: SelfTree a -> State [Int] (SelfTree ([Int],a))
|
||||
@@ -241,9 +244,8 @@ numSelfTree' (ST (Node lrt bs)) = do
|
||||
modify (ix 0 +~ 1)
|
||||
bs' <- mapM (fmap _unST . numSelfTree' . ST) bs
|
||||
case lrt of
|
||||
(y,Left t) -> return $ ST (Node ((is,y),Left $ fmap ((_1 %~ (\x -> x:is)) . swap) $ numTraversable t) bs')
|
||||
(y,Left t) -> return $ ST (Node ((is,y),Left $ (_1 %~ (:is)) . swap <$> numTraversable t) bs')
|
||||
(y,Right mt') -> return $ ST (Node ((is,y),Right (evalState (numSelfTree' mt') (0:is))) bs')
|
||||
-- return $ MTree (is,lab) (mn & nodeMetaTree %~ (\nmt -> evalState (numMetaTree' nmt) (0:is))) bs'
|
||||
|
||||
numMetaTree :: MetaTree a String -> MetaTree a ([Int],String)
|
||||
numMetaTree mt = evalState (numMetaTree' mt) [0]
|
||||
@@ -254,3 +256,6 @@ numMetaTree' (MTree lab mn bs) = do
|
||||
modify (ix 0 +~ 1)
|
||||
bs' <- mapM (mbTree %%~ numMetaTree') bs
|
||||
return $ MTree (is,lab) (mn & nodeMetaTree %~ (\nmt -> evalState (numMetaTree' nmt) (0:is))) bs'
|
||||
|
||||
showIntsString :: ([Int],String) -> String
|
||||
showIntsString (is,s) = foldr1 (++) (intersperse ":" (map show is)) ++ ':':s
|
||||
|
||||
Reference in New Issue
Block a user