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
|
||||
|
||||
@@ -13,6 +13,7 @@ module Dodge.Data.Item (
|
||||
module Dodge.Data.Item.Location,
|
||||
) where
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
@@ -34,6 +35,7 @@ data Item = Item
|
||||
, _itID :: NewInt ItmInt
|
||||
, _itLocation :: ItemLocation
|
||||
, _itEffect :: ItEffect
|
||||
, _itAmmoSlots :: IM.IntMap AmmoType
|
||||
, _itInvSize :: Int
|
||||
, _itDimension :: ItemDimension
|
||||
, _itCurseStatus :: CurseStatus
|
||||
|
||||
@@ -22,7 +22,6 @@ import Dodge.Data.Item.Scope
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Dodge.Data.GenFloat
|
||||
import Dodge.Data.Hammer
|
||||
import Dodge.Data.Item.HeldDelay
|
||||
@@ -38,7 +37,7 @@ data ItemUse
|
||||
{ _heldDelay :: UseDelay
|
||||
, _heldHammer :: HammerPosition
|
||||
, _heldAim :: AimParams
|
||||
, _heldAmmoTypes :: IM.IntMap AmmoType
|
||||
-- , _heldAmmoTypes :: IM.IntMap AmmoType
|
||||
, _heldParams :: HeldParams
|
||||
, _heldTriggerType :: TriggerType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user