Add link types to attachment tree

This commit is contained in:
2024-09-11 11:33:08 +01:00
parent c80217a970
commit 60c399935e
6 changed files with 128 additions and 61 deletions
+8
View File
@@ -8,13 +8,21 @@ module Dodge.Data.DoubleTree
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import Data.Bifunctor
data DoubleTree a = DT {_dtValue :: a,_dtLeft :: [DoubleTree a],_dtRight :: [DoubleTree a]}
deriving (Eq,Ord,Show,Read)
data LabelDoubleTree b a = LDT {_ldtValue :: a, _ldtLeft :: [(b,LabelDoubleTree b a)]
,_ldtRight :: [(b,LabelDoubleTree b a)]}
deriving (Eq,Ord,Show,Read)
instance Functor DoubleTree where
fmap f (DT x l r) = DT (f x) (fmap (fmap f) l) (fmap (fmap f) r)
instance Functor (LabelDoubleTree b) where
fmap f (LDT x l r) = LDT (f x) (fmap (second $ fmap f) l) (fmap (second $ fmap f) r)
makeLenses ''DoubleTree
deriveJSON defaultOptions ''DoubleTree