Delete location double trees

This commit is contained in:
2026-03-17 15:37:15 +00:00
parent 96c2fb00e1
commit 13b12f01a8
5 changed files with 2 additions and 315 deletions
-80
View File
@@ -5,11 +5,6 @@
module Dodge.Data.DoubleTree where
import Control.Lens
--import Data.Aeson
--import Data.Aeson.TH
import Data.Bifunctor
--import qualified Data.Map.Strict as M
data DoubleTreeNodeType
= DTRootNode
@@ -18,67 +13,15 @@ data DoubleTreeNodeType
| DTMidBelowNode
| DTBottomNode
-- for each child, records the link type to the father node
data LabelDoubleTreeNodeType a
= LDTRootNode
| LDTTopNode a
| LDTMidAboveNode a
| LDTMidBelowNode a
| LDTBottomNode a
data DTree a = DT {_dtValue :: a, _dtLeft :: [DTree a], _dtRight :: [DTree a]}
deriving (Eq, Ord, Show, Read)
data LDTree b a = LDT -- LabelDoubleTree
{ _ldtValue :: a
, _ldtLeft :: [(b, LDTree b a)]
, _ldtRight :: [(b, LDTree b a)]
}
deriving (Eq, Ord, Show, Read)
---- I am not sure about the double use of records here
--data ContextLDT b a
-- = TopLDT
-- | LeftwardLDT
-- { _cldtUp :: ContextLDT b a
-- , _cldtCloseLeft :: [(b, LDTree b a)]
-- , _cldtParent :: a
-- , _cldtLink :: b
-- , _cldtCloseRight :: [(b, LDTree b a)]
-- , _cldtFarRight :: [(b, LDTree b a)]
-- }
-- | RightwardLDT
-- { _cldtUp :: ContextLDT b a
-- , _cldtFarLeft :: [(b, LDTree b a)]
-- , _cldtCloseLeft :: [(b, LDTree b a)]
-- , _cldtParent :: a
-- , _cldtLink :: b
-- , _cldtCloseRight :: [(b, LDTree b a)]
-- }
--data LocationLDT b a = LocLDT
-- { _locLdtContext :: ContextLDT b a
-- , _locLDT :: LDTree b a
-- }
instance Functor DTree where
fmap f (DT x l r) = DT (f x) (fmap (fmap f) l) (fmap (fmap f) r)
instance Foldable DTree where
foldMap f (DT x l r) = foldMap (foldMap f) l <> f x <> foldMap (foldMap f) r
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 LDTree where
second = fmap
first f (LDT x l r) =
LDT
x
(map (bimap f (first f)) l)
(map (bimap f (first f)) r)
data ContextDT a
= TopDT
| LeftwardDT
@@ -102,35 +45,12 @@ data LocationDT a = LocDT
}
makeLenses ''DTree
--makeLenses ''LDTree
--makeLenses ''LocationLDT
--makeLenses ''ContextLDT
makeLenses ''LocationDT
makeLenses ''ContextDT
--instance Functor (LocationLDT b) where
-- fmap f (LocLDT c t) = LocLDT (fmap f c) (fmap f t)
instance Functor LocationDT where
fmap f (LocDT c t) = LocDT (fmap f c) (fmap f t)
--instance Functor (ContextLDT b) where
-- fmap f = \case
-- TopLDT -> TopLDT
-- LeftwardLDT u cl p l cr fr -> LeftwardLDT
-- (fmap f u)
-- (fmap (fmap (fmap f)) cl)
-- (f p)
-- l
-- (fmap (fmap (fmap f)) cr)
-- (fmap (fmap (fmap f)) fr)
-- RightwardLDT u fl cl p l cr -> RightwardLDT (fmap f u)
-- (fmap (fmap (fmap f)) fl)
-- (fmap (fmap (fmap f)) cl)
-- (f p)
-- l
-- (fmap (fmap (fmap f)) cr)
instance Functor ContextDT where
fmap f = \case
TopDT -> TopDT