Skip to content

Commit f3a0d1d

Browse files
committed
Utils: iterateN: upd docs
1 parent a564ac5 commit f3a0d1d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Nix/Utils.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,13 @@ traverseM
325325
-> m (f (t b))
326326
traverseM f x = sequenceA <$> traverse f x
327327

328-
-- | Apply a function @n@ times to a given value.
329-
iterateN :: Int -> (a -> a) -> a -> a
330-
iterateN n f x = fix ((<*> (0 /=)) . ((bool x . f) .) . (. pred)) $ n -- It is hard to read - yes. It is a single action without recursion - yes.
328+
iterateN
329+
:: forall a
330+
. Int -- ^ times
331+
-> (a -> a) -- ^ function apply
332+
-> a -- ^ on value
333+
-> a
334+
iterateN n f x = fix ((<*> (0 /=)) . ((bool x . f) .) . (. pred)) n -- It is hard to read - yes. It is a non-recursive momoized action - yes.
331335

332336
-- | Apply Kleisli arrow N times, join 'm's.
333337
nestM :: Monad m => Int -> (a -> m a) -> a -> m a

0 commit comments

Comments
 (0)