1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 17:14:52 +09:00

Control.Applicative.Local: Rename parameter to avoid confusing name shadowing

This commit is contained in:
fr33domlover 2022-09-05 16:27:21 +00:00
parent 5a6ae76b76
commit cdcf3a3326

View file

@ -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