diff --git a/src/Control/Applicative/Local.hs b/src/Control/Applicative/Local.hs index cba8830..7778394 100644 --- a/src/Control/Applicative/Local.hs +++ b/src/Control/Applicative/Local.hs @@ -23,28 +23,28 @@ where import Control.Applicative --- | Apply action between zero and @n@ times, inclusive, and list the results. +-- | Apply action between zero and @times@ times, inclusive, and list the results. atMost :: Alternative f => Int -> f a -> f [a] -atMost n action = go n +atMost times action = go times where go n = if n <= 0 then pure [] else liftA2 (:) action (go $ n - 1) <|> pure [] --- | Apply action between zero and @n@ times, inclusive, and discard results. +-- | Apply action between zero and @times@ times, inclusive, and discard results. atMost_ :: Alternative f => Int -> f a -> f () -atMost_ n action = go n +atMost_ times action = go times where go n = if n <= 0 then pure () else action *> (go $ n - 1) <|> pure () --- | Apply action between one and @n@ times, inclusive, and list the results. +-- | Apply action between one and @times@ times, inclusive, and list the results. upTo :: Alternative f => Int -> f a -> f [a] -upTo n action = liftA2 (:) action $ atMost n action +upTo times action = liftA2 (:) action $ atMost times action --- | Apply action between one and @n@ times, inclusive, and discard results. +-- | Apply action between one and @times@ times, inclusive, and discard results. upTo_ :: Alternative f => Int -> f a -> f () -upTo_ n action = action *> atMost_ n action +upTo_ times action = action *> atMost_ times action