diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index 0aee9847d..754380ca6 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -231,11 +231,16 @@ springLinkTest = LTest (const Nothing) $ type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a) -leftIsParentCombine' :: LDTComb CItem ItemLink -leftIsParentCombine' ltree rtree = Nothing - leftIsParentCombine :: LDTComb CItem ItemLink leftIsParentCombine ltree rtree = do + let l = rightChildList ltree + xs = dropWhile ((\s -> not $ S.member s (structureToPotentialFunction rtree)) . fst) l + (sf,linktype) <- safeHead xs + return $ + ltree & ldtRight .:~ (linktype, rtree & ldtValue . _2 .~ sf) + +leftIsParentCombine' :: LDTComb CItem ItemLink +leftIsParentCombine' ltree rtree = do lu <- (ltree ^. ldtValue . _3 . tryRightLink) rtree --(rtree ^. ldtValue) return $ ltree & ldtValue %~ (lu ^. luParentUpdate) @@ -255,6 +260,12 @@ leftChildList t = foldl' f l (reverse $ t ^.. ldtLeft . each . _1) l = fst $ itemToBreakLists (t ^. ldtValue . _1) (t ^. ldtValue . _2) f x y = tail $ dropWhile ((/=y) . snd) x +rightChildList :: LabelDoubleTree ItemLink CItem -> [(ItemStructuralFunction, ItemLink)] +rightChildList t = foldl' f l (reverse $ t ^.. ldtRight . each . _1) + where + l = snd $ itemToBreakLists (t ^. ldtValue . _1) (t ^. ldtValue . _2) + f x y = tail $ dropWhile ((/=y) . snd) x + rightIsParentCombine' :: LDTComb CItem ItemLink rightIsParentCombine' ltree rtree = do lu <- (rtree ^. ldtValue . _3 . tryLeftLink) ltree -- (ltree ^. ldtValue)