Add link types to attachment tree
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user