Implement zipper for attachment trees
This commit is contained in:
@@ -41,31 +41,27 @@ data LabelDoubleTree b a = LDT {_ldtValue :: a, _ldtLeft :: [(b,LabelDoubleTree
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
|
||||
-- I am not sure about the double use of records here
|
||||
data ContextLDT b a = TopLDT
|
||||
{ _cldtValue :: a}
|
||||
data ContextLDT b a = TopLDT
|
||||
| LeftwardLDT
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtCloseLeft :: [LabelDoubleTree b a]
|
||||
, _cldtCloseLeft :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtParent :: a
|
||||
, _cldtLink :: b
|
||||
, _cldtValue :: a
|
||||
, _cldtCloseRight :: [LabelDoubleTree b a]
|
||||
, _cldtFarRight :: [LabelDoubleTree b a]
|
||||
, _cldtCloseRight :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtFarRight :: [(b,LabelDoubleTree b a)]
|
||||
}
|
||||
| RightwardLDT
|
||||
{ _cldtUp :: ContextLDT b a
|
||||
, _cldtFarLeft :: [LabelDoubleTree b a]
|
||||
, _cldtCloseLeft :: [LabelDoubleTree b a]
|
||||
, _cldtFarLeft :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtCloseLeft :: [(b,LabelDoubleTree b a)]
|
||||
, _cldtParent :: a
|
||||
, _cldtLink :: b
|
||||
, _cldtValue :: a
|
||||
, _cldtCloseRight :: [LabelDoubleTree b a]
|
||||
, _cldtCloseRight :: [(b,LabelDoubleTree b a)]
|
||||
}
|
||||
|
||||
-- this is not quite right, it duplicates the value when the context is at the
|
||||
-- top
|
||||
data LocationLDT b a = LocLDT
|
||||
{ _locLdtContext :: ContextLDT b a
|
||||
, _locLdtLeft :: [LabelDoubleTree b a]
|
||||
, _locLdtRight :: [LabelDoubleTree b a]
|
||||
, _locLDT :: LabelDoubleTree b a
|
||||
}
|
||||
|
||||
instance Functor DoubleTree where
|
||||
@@ -84,5 +80,7 @@ instance Bifunctor LabelDoubleTree where
|
||||
|
||||
makeLenses ''DoubleTree
|
||||
makeLenses ''LabelDoubleTree
|
||||
makeLenses ''LocationLDT
|
||||
makeLenses ''ContextLDT
|
||||
deriveJSON defaultOptions ''DoubleTree
|
||||
deriveJSON defaultOptions ''LabelDoubleTree
|
||||
|
||||
Reference in New Issue
Block a user