Comment out LDTs
This commit is contained in:
+86
-86
@@ -16,24 +16,24 @@ singleLDT x = LDT x [] []
|
||||
ldtToDT :: LDTree b a -> DTree a
|
||||
ldtToDT (LDT x l r) = DT x (map (ldtToDT . snd) l) (map (ldtToDT . snd) r)
|
||||
|
||||
locLDTToLocDT :: LocationLDT b a -> LocationDT a
|
||||
locLDTToLocDT (LocLDT con t) = LocDT (conLDTToConDT con) (ldtToDT t)
|
||||
--locLDTToLocDT :: LocationLDT b a -> LocationDT a
|
||||
--locLDTToLocDT (LocLDT con t) = LocDT (conLDTToConDT con) (ldtToDT t)
|
||||
|
||||
conLDTToConDT :: ContextLDT b a -> ContextDT a
|
||||
conLDTToConDT = \case
|
||||
TopLDT -> TopDT
|
||||
LeftwardLDT u cl p _ cr fr -> LeftwardDT
|
||||
(conLDTToConDT u)
|
||||
(map (ldtToDT . snd) cl)
|
||||
p
|
||||
(map (ldtToDT . snd) cr)
|
||||
(map (ldtToDT . snd) fr)
|
||||
RightwardLDT u fl cl p _ cr -> RightwardDT
|
||||
(conLDTToConDT u)
|
||||
(map (ldtToDT . snd) fl)
|
||||
(map (ldtToDT . snd) cl)
|
||||
p
|
||||
(map (ldtToDT . snd) cr)
|
||||
--conLDTToConDT :: ContextLDT b a -> ContextDT a
|
||||
--conLDTToConDT = \case
|
||||
-- TopLDT -> TopDT
|
||||
-- LeftwardLDT u cl p _ cr fr -> LeftwardDT
|
||||
-- (conLDTToConDT u)
|
||||
-- (map (ldtToDT . snd) cl)
|
||||
-- p
|
||||
-- (map (ldtToDT . snd) cr)
|
||||
-- (map (ldtToDT . snd) fr)
|
||||
-- RightwardLDT u fl cl p _ cr -> RightwardDT
|
||||
-- (conLDTToConDT u)
|
||||
-- (map (ldtToDT . snd) fl)
|
||||
-- (map (ldtToDT . snd) cl)
|
||||
-- p
|
||||
-- (map (ldtToDT . snd) cr)
|
||||
|
||||
dtStartPropagate :: (a -> c) -> (c -> a -> c) -> DTree a -> DTree c
|
||||
dtStartPropagate g f (DT x l r) = DT z
|
||||
@@ -265,22 +265,22 @@ prettyLDT f (LDT x l r) =
|
||||
concatMap (map ('/' :) . prettyLDT f . snd) r
|
||||
++ (f x : concatMap (map ('\\' :) . prettyLDT f . snd) l)
|
||||
|
||||
ldtToLoc :: LDTree b a -> LocationLDT b a
|
||||
ldtToLoc = LocLDT TopLDT
|
||||
--ldtToLoc :: LDTree b a -> LocationLDT b a
|
||||
--ldtToLoc = LocLDT TopLDT
|
||||
|
||||
-- should probably do tests for these
|
||||
locUp :: LocationLDT b a -> Maybe (LocationLDT b a)
|
||||
locUp (LocLDT TopLDT _) = Nothing
|
||||
locUp (LocLDT c@LeftwardLDT{} t) =
|
||||
Just $
|
||||
LocLDT
|
||||
(_cldtUp c)
|
||||
(LDT (_cldtParent c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)) (_cldtFarRight c))
|
||||
locUp (LocLDT c@RightwardLDT{} t) =
|
||||
Just $
|
||||
LocLDT
|
||||
(_cldtUp c)
|
||||
(LDT (_cldtParent c) (_cldtFarLeft c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)))
|
||||
---- should probably do tests for these
|
||||
--locUp :: LocationLDT b a -> Maybe (LocationLDT b a)
|
||||
--locUp (LocLDT TopLDT _) = Nothing
|
||||
--locUp (LocLDT c@LeftwardLDT{} t) =
|
||||
-- Just $
|
||||
-- LocLDT
|
||||
-- (_cldtUp c)
|
||||
-- (LDT (_cldtParent c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)) (_cldtFarRight c))
|
||||
--locUp (LocLDT c@RightwardLDT{} t) =
|
||||
-- Just $
|
||||
-- LocLDT
|
||||
-- (_cldtUp c)
|
||||
-- (LDT (_cldtParent c) (_cldtFarLeft c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)))
|
||||
|
||||
--locToTop :: LocationLDT b a -> LocationLDT b a
|
||||
--locToTop loc = maybe loc locToTop $ locUp loc
|
||||
@@ -303,11 +303,11 @@ locToTop loc = maybe loc locToTop $ locUp' loc
|
||||
|
||||
--locToTop = fix $ \x -> fromMaybe x $ locUp x
|
||||
|
||||
locLeftmost :: LocationLDT b a -> LocationLDT b a
|
||||
locLeftmost loc = maybe loc locLeftmost $ alaf First foldMap Just $ locGoLeft loc
|
||||
--locLeftmost :: LocationLDT b a -> LocationLDT b a
|
||||
--locLeftmost loc = maybe loc locLeftmost $ alaf First foldMap Just $ locGoLeft loc
|
||||
|
||||
locRightmost :: LocationLDT b a -> LocationLDT b a
|
||||
locRightmost loc = maybe loc locRightmost $ alaf Last foldMap Just $ locGoRight loc
|
||||
--locRightmost :: LocationLDT b a -> LocationLDT b a
|
||||
--locRightmost loc = maybe loc locRightmost $ alaf Last foldMap Just $ locGoRight loc
|
||||
|
||||
locDTLeftmost :: LocationDT a -> LocationDT a
|
||||
locDTLeftmost loc = maybe loc locDTLeftmost $ alaf First foldMap Just $ locDTGoLeft loc
|
||||
@@ -315,15 +315,15 @@ locDTLeftmost loc = maybe loc locDTLeftmost $ alaf First foldMap Just $ locDTGoL
|
||||
locDTRightmost :: LocationDT a -> LocationDT a
|
||||
locDTRightmost loc = maybe loc locDTRightmost $ alaf Last foldMap Just $ locDTGoRight loc
|
||||
|
||||
-- should probably do tests for these
|
||||
locGoLeft :: LocationLDT b a -> [LocationLDT b a]
|
||||
locGoLeft (LocLDT c (LDT v l r)) =
|
||||
[LocLDT (LeftwardLDT c closel v link closer r) t | (closel, (link, t), closer) <- locGoHelp id l]
|
||||
---- should probably do tests for these
|
||||
--locGoLeft :: LocationLDT b a -> [LocationLDT b a]
|
||||
--locGoLeft (LocLDT c (LDT v l r)) =
|
||||
-- [LocLDT (LeftwardLDT c closel v link closer r) t | (closel, (link, t), closer) <- locGoHelp id l]
|
||||
|
||||
-- should probably do tests for these
|
||||
locGoRight :: LocationLDT b a -> [LocationLDT b a]
|
||||
locGoRight (LocLDT c (LDT v l r)) =
|
||||
[LocLDT (RightwardLDT c l closel v link closer) t | (closel, (link, t), closer) <- locGoHelp id r]
|
||||
---- should probably do tests for these
|
||||
--locGoRight :: LocationLDT b a -> [LocationLDT b a]
|
||||
--locGoRight (LocLDT c (LDT v l r)) =
|
||||
-- [LocLDT (RightwardLDT c l closel v link closer) t | (closel, (link, t), closer) <- locGoHelp id r]
|
||||
|
||||
-- should probably do tests for these
|
||||
locDTGoLeft :: LocationDT a -> [LocationDT a]
|
||||
@@ -351,49 +351,49 @@ locDTGoHelp f = go []
|
||||
go cleft (y : ys) = (cleft, f y, ys) : go (cleft <> [y]) ys
|
||||
go _ [] = []
|
||||
|
||||
-- Propgates a value (of type c) down the branches of the ContextLDT.
|
||||
-- The value is updated according a "left" or "right" function (lf or rf),
|
||||
-- that acts on the parent value, the link, and the child value.
|
||||
-- For each context node, the updated value is used to update a final value (of type d).
|
||||
cldtPropagateFold ::
|
||||
(c -> a -> b -> a -> c) ->
|
||||
(c -> a -> b -> a -> c) ->
|
||||
(c -> LocationLDT b a -> d -> d) ->
|
||||
c ->
|
||||
LocationLDT b a ->
|
||||
d ->
|
||||
d
|
||||
cldtPropagateFold lf rf up x loc =
|
||||
alaf
|
||||
Endo
|
||||
foldMap
|
||||
( \(LocLDT con' t') ->
|
||||
cldtPropagateFold
|
||||
lf
|
||||
rf
|
||||
up
|
||||
(lf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
||||
(LocLDT con' t')
|
||||
)
|
||||
(locGoLeft loc)
|
||||
. alaf
|
||||
Endo
|
||||
foldMap
|
||||
( \(LocLDT con' t') ->
|
||||
cldtPropagateFold
|
||||
lf
|
||||
rf
|
||||
up
|
||||
(rf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
||||
(LocLDT con' t')
|
||||
)
|
||||
(locGoRight loc)
|
||||
. up x loc
|
||||
---- Propgates a value (of type c) down the branches of the ContextLDT.
|
||||
---- The value is updated according a "left" or "right" function (lf or rf),
|
||||
---- that acts on the parent value, the link, and the child value.
|
||||
---- For each context node, the updated value is used to update a final value (of type d).
|
||||
--cldtPropagateFold ::
|
||||
-- (c -> a -> b -> a -> c) ->
|
||||
-- (c -> a -> b -> a -> c) ->
|
||||
-- (c -> LocationLDT b a -> d -> d) ->
|
||||
-- c ->
|
||||
-- LocationLDT b a ->
|
||||
-- d ->
|
||||
-- d
|
||||
--cldtPropagateFold lf rf up x loc =
|
||||
-- alaf
|
||||
-- Endo
|
||||
-- foldMap
|
||||
-- ( \(LocLDT con' t') ->
|
||||
-- cldtPropagateFold
|
||||
-- lf
|
||||
-- rf
|
||||
-- up
|
||||
-- (lf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
||||
-- (LocLDT con' t')
|
||||
-- )
|
||||
-- (locGoLeft loc)
|
||||
-- . alaf
|
||||
-- Endo
|
||||
-- foldMap
|
||||
-- ( \(LocLDT con' t') ->
|
||||
-- cldtPropagateFold
|
||||
-- lf
|
||||
-- rf
|
||||
-- up
|
||||
-- (rf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
||||
-- (LocLDT con' t')
|
||||
-- )
|
||||
-- (locGoRight loc)
|
||||
-- . up x loc
|
||||
|
||||
reduceLocLDT :: Monoid m => (LocationLDT b a -> m) -> LocationLDT b a -> m
|
||||
reduceLocLDT f x =
|
||||
foldMap (reduceLocLDT f) (locGoLeft x) <> f x
|
||||
<> foldMap (reduceLocLDT f) (locGoRight x)
|
||||
--reduceLocLDT :: Monoid m => (LocationLDT b a -> m) -> LocationLDT b a -> m
|
||||
--reduceLocLDT f x =
|
||||
-- foldMap (reduceLocLDT f) (locGoLeft x) <> f x
|
||||
-- <> foldMap (reduceLocLDT f) (locGoRight x)
|
||||
|
||||
reduceLocDT :: Monoid m => (LocationDT a -> m) -> LocationDT a -> m
|
||||
reduceLocDT f x =
|
||||
|
||||
Reference in New Issue
Block a user