Cleanup LabelDoubleTree -> LDTree

This commit is contained in:
2025-06-27 08:55:00 +01:00
parent 73c708a325
commit dd5a747559
11 changed files with 101 additions and 218 deletions
+13 -20
View File
@@ -30,17 +30,10 @@ data LabelDoubleTreeNodeType a
data DoubleTree a = DT {_dtValue :: a, _dtLeft :: [DoubleTree a], _dtRight :: [DoubleTree a]}
deriving (Eq, Ord, Show, Read)
--data FLatLabelDoubleTreeNode b a = FLDT
-- {_fldtValue :: a
-- ,_fldtType ::
-- ,_fldtIndentation :: Int
-- ,_fldtID :: Int
-- ,_fldtChildren =
data LabelDoubleTree b a = LDT
data LDTree b a = LDT -- LabelDoubleTree
{ _ldtValue :: a
, _ldtLeft :: [(b, LabelDoubleTree b a)]
, _ldtRight :: [(b, LabelDoubleTree b a)]
, _ldtLeft :: [(b, LDTree b a)]
, _ldtRight :: [(b, LDTree b a)]
}
deriving (Eq, Ord, Show, Read)
@@ -49,24 +42,24 @@ data ContextLDT b a
= TopLDT
| LeftwardLDT
{ _cldtUp :: ContextLDT b a
, _cldtCloseLeft :: [(b, LabelDoubleTree b a)]
, _cldtCloseLeft :: [(b, LDTree b a)]
, _cldtParent :: a
, _cldtLink :: b
, _cldtCloseRight :: [(b, LabelDoubleTree b a)]
, _cldtFarRight :: [(b, LabelDoubleTree b a)]
, _cldtCloseRight :: [(b, LDTree b a)]
, _cldtFarRight :: [(b, LDTree b a)]
}
| RightwardLDT
{ _cldtUp :: ContextLDT b a
, _cldtFarLeft :: [(b, LabelDoubleTree b a)]
, _cldtCloseLeft :: [(b, LabelDoubleTree b a)]
, _cldtFarLeft :: [(b, LDTree b a)]
, _cldtCloseLeft :: [(b, LDTree b a)]
, _cldtParent :: a
, _cldtLink :: b
, _cldtCloseRight :: [(b, LabelDoubleTree b a)]
, _cldtCloseRight :: [(b, LDTree b a)]
}
data LocationLDT b a = LocLDT
{ _locLdtContext :: ContextLDT b a
, _locLDT :: LabelDoubleTree b a
, _locLDT :: LDTree b a
}
instance Functor DoubleTree where
@@ -75,10 +68,10 @@ instance Functor DoubleTree where
instance Foldable DoubleTree where
foldMap f (DT x l r) = foldMap (foldMap f) l <> f x <> foldMap (foldMap f) r
instance Functor (LabelDoubleTree b) where
instance Functor (LDTree b) where
fmap f (LDT x l r) = LDT (f x) (fmap (second $ fmap f) l) (fmap (second $ fmap f) r)
instance Bifunctor LabelDoubleTree where
instance Bifunctor LDTree where
second = fmap
first f (LDT x l r) =
LDT
@@ -87,7 +80,7 @@ instance Bifunctor LabelDoubleTree where
(map (bimap f (first f)) r)
makeLenses ''DoubleTree
makeLenses ''LabelDoubleTree
makeLenses ''LDTree
makeLenses ''LocationLDT
makeLenses ''ContextLDT
--deriveJSON defaultOptions ''DoubleTree