Cleanup
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
--{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Dodge.Data.DoubleTree
|
||||
where
|
||||
|
||||
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
|
||||
@@ -26,37 +27,41 @@ data LabelDoubleTreeNodeType a
|
||||
| LDTMidBelowNode a
|
||||
| LDTBottomNode a
|
||||
|
||||
data DoubleTree a = DT {_dtValue :: a,_dtLeft :: [DoubleTree a],_dtRight :: [DoubleTree a]}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
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 ::
|
||||
-- ,_fldtType ::
|
||||
-- ,_fldtIndentation :: Int
|
||||
-- ,_fldtID :: Int
|
||||
-- ,_fldtChildren =
|
||||
-- ,_fldtChildren =
|
||||
|
||||
data LabelDoubleTree b a = LDT {_ldtValue :: a, _ldtLeft :: [(b,LabelDoubleTree b a)]
|
||||
,_ldtRight :: [(b,LabelDoubleTree b 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)
|
||||
|
||||
-- I am not sure about the double use of records here
|
||||
data ContextLDT b a = TopLDT
|
||||
data ContextLDT b a
|
||||
= TopLDT
|
||||
| LeftwardLDT
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtCloseLeft :: [(b,LabelDoubleTree b a)]
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtCloseLeft :: [(b, LabelDoubleTree b a)]
|
||||
, _cldtParent :: a
|
||||
, _cldtLink :: b
|
||||
, _cldtCloseRight :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtFarRight :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtCloseRight :: [(b, LabelDoubleTree b a)]
|
||||
, _cldtFarRight :: [(b, LabelDoubleTree b a)]
|
||||
}
|
||||
| RightwardLDT
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtFarLeft :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtCloseLeft :: [(b,LabelDoubleTree b a)]
|
||||
| RightwardLDT
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtFarLeft :: [(b, LabelDoubleTree b a)]
|
||||
, _cldtCloseLeft :: [(b, LabelDoubleTree b a)]
|
||||
, _cldtParent :: a
|
||||
, _cldtLink :: b
|
||||
, _cldtCloseRight :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtCloseRight :: [(b, LabelDoubleTree b a)]
|
||||
}
|
||||
|
||||
data LocationLDT b a = LocLDT
|
||||
@@ -75,8 +80,11 @@ instance Functor (LabelDoubleTree b) where
|
||||
|
||||
instance Bifunctor LabelDoubleTree where
|
||||
second = fmap
|
||||
first f (LDT x l r) = LDT x (map (bimap f (first f)) l)
|
||||
(map (bimap f (first f)) r)
|
||||
first f (LDT x l r) =
|
||||
LDT
|
||||
x
|
||||
(map (bimap f (first f)) l)
|
||||
(map (bimap f (first f)) r)
|
||||
|
||||
makeLenses ''DoubleTree
|
||||
makeLenses ''LabelDoubleTree
|
||||
|
||||
Reference in New Issue
Block a user