mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Freeze the callstacks in <|>.
This commit is contained in:
parent
abaad4fc76
commit
ffb01ff388
@ -337,8 +337,8 @@ instance Enum grammar => Alternative (Assignment ast grammar) where
|
|||||||
(Source `Then` continueL) <|> (Source `Then` continueR) = Source `Then` uncurry (<|>) . (continueL &&& continueR)
|
(Source `Then` continueL) <|> (Source `Then` continueR) = Source `Then` uncurry (<|>) . (continueL &&& continueR)
|
||||||
(Alt ls `Then` continueL) <|> (Alt rs `Then` continueR) = Alt ((Left <$> ls) <> (Right <$> rs)) `Then` either continueL continueR
|
(Alt ls `Then` continueL) <|> (Alt rs `Then` continueR) = Alt ((Left <$> ls) <> (Right <$> rs)) `Then` either continueL continueR
|
||||||
(Alt ls `Then` continueL) <|> r = Alt ((Left <$> ls) <> pure (Right r)) `Then` either continueL id
|
(Alt ls `Then` continueL) <|> r = Alt ((Left <$> ls) <> pure (Right r)) `Then` either continueL id
|
||||||
l <|> r | Just c <- (liftA2 (IntMap.unionWith (<|>)) `on` choices) l r = Choose c (atEnd l <|> atEnd r) `Then` id
|
l <|> r | Just c <- (liftA2 (IntMap.unionWith (<|>)) `on` choices) l r = withFrozenCallStack $ Choose c (atEnd l <|> atEnd r) `Then` id
|
||||||
| otherwise = wrap $ Alt (l :| [r])
|
| otherwise = withFrozenCallStack $ wrap (Alt (l :| [r]))
|
||||||
where choices :: Assignment ast grammar a -> Maybe (IntMap.IntMap (Assignment ast grammar a))
|
where choices :: Assignment ast grammar a -> Maybe (IntMap.IntMap (Assignment ast grammar a))
|
||||||
choices (Choose choices _ `Then` continue) = Just (continue <$> choices)
|
choices (Choose choices _ `Then` continue) = Just (continue <$> choices)
|
||||||
choices (Many rule `Then` continue) = ((Many rule `Then` continue) <$) <$> choices rule
|
choices (Many rule `Then` continue) = ((Many rule `Then` continue) <$) <$> choices rule
|
||||||
|
Loading…
Reference in New Issue
Block a user