Implement more general tree composition

This commit is contained in:
2022-06-11 17:07:58 +01:00
parent de71c61409
commit 6cd1d6c130
3 changed files with 39 additions and 12 deletions
+11 -8
View File
@@ -3,19 +3,22 @@
module Dodge.Tree.Compose.Data where
import Data.Tree
import Control.Lens
data ComposingNode a
= SplitDown {_unCompose :: a}
-- | useAll {_unCompose :: a}
| UseSome {_composeIndices :: [Int], _unCompose :: a}
| UseNone {_unCompose :: a}
-- | useLabel {_composeIndex :: Int, _unCompose :: a} -- defaults to using no children
type CompTree a = Tree (Tree a)
data MetaBranch a
= MBranch {_mbLabel :: String, _mbAttach :: a -> Maybe a, _mbTree :: MetaTree a}
data MetaTree a
= MTree {_mtLabel :: String , _mtTree :: MetaTree a , _mtBranches :: [MetaBranch a] }
| BTree {_btLabel :: String , _btValue :: a , _btBranches :: [MetaTree a] }
--type CompTree a = Tree (Tree a)
type LabTree a = (a -> Maybe ([String],a),Tree a)
type LabCompTree a = Tree (LabTree a)
data TreeSubLabelling = TreeSubLabelling
{ _topLabel :: String
, _subLabels :: Maybe (Tree TreeSubLabelling)
}
makeLenses ''ComposingNode
makeLenses ''TreeSubLabelling
makeLenses ''MetaTree
makeLenses ''MetaBranch