1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Add callstacks to while & until.

This commit is contained in:
Rob Rix 2017-08-06 09:42:10 -04:00
parent 56eb9407b9
commit 59fd521709

View File

@ -163,14 +163,14 @@ children forEach = withFrozenCallStack $ Children forEach `Then` return
-- | Collect a list of values passing a predicate.
while :: (Alternative m, Monad m) => (a -> Bool) -> m a -> m [a]
while :: (Alternative m, Monad m, HasCallStack) => (a -> Bool) -> m a -> m [a]
while predicate step = many $ do
result <- step
guard (predicate result)
pure result
-- | Collect a list of values failing a predicate.
until :: (Alternative m, Monad m) => (a -> Bool) -> m a -> m [a]
until :: (Alternative m, Monad m, HasCallStack) => (a -> Bool) -> m a -> m [a]
until = while . (not .)