Skip to content

Commit a1d31b5

Browse files
authored
Merge pull request #86 from purescript/fix-index-warning
Fix shadowed name warnings in `indexl` / `indexr`
2 parents 36c0431 + 99d679c commit a1d31b5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Data/Foldable.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ instance foldableMultiplicative :: Foldable Multiplicative where
175175
fold :: forall f m. Foldable f => Monoid m => f m -> m
176176
fold = foldMap id
177177

178-
-- | Similar to 'foldl', but the result is encapsulated in a monad.
178+
-- | Similar to 'foldl', but the result is encapsulated in a monad.
179179
-- |
180-
-- | Note: this function is not generally stack-safe, e.g., for monads which
180+
-- | Note: this function is not generally stack-safe, e.g., for monads which
181181
-- | build up thunks a la `Eff`.
182182
foldM :: forall f m a b. Foldable f => Monad m => (a -> b -> m a) -> a -> f b -> m a
183183
foldM f a0 = foldl (\ma b -> ma >>= flip f b) (pure a0)
@@ -331,24 +331,24 @@ notElem x = not <<< elem x
331331
indexl :: forall a f. Foldable f => Int -> f a -> Maybe a
332332
indexl idx = _.elem <<< foldl go { elem: Nothing, pos: 0 }
333333
where
334-
go cursor elem =
335-
case cursor.elem of
334+
go cursor a =
335+
case cursor.elem of
336336
Just _ -> cursor
337337
_ ->
338338
if cursor.pos == idx
339-
then { elem: Just elem, pos: cursor.pos }
339+
then { elem: Just a, pos: cursor.pos }
340340
else { pos: cursor.pos + 1, elem: cursor.elem }
341341

342342
-- | Try to get nth element from the right in a data structure
343343
indexr :: forall a f. Foldable f => Int -> f a -> Maybe a
344344
indexr idx = _.elem <<< foldr go { elem: Nothing, pos: 0 }
345345
where
346-
go elem cursor =
347-
case cursor.elem of
346+
go a cursor =
347+
case cursor.elem of
348348
Just _ -> cursor
349349
_ ->
350350
if cursor.pos == idx
351-
then { elem: Just elem, pos: cursor.pos }
351+
then { elem: Just a, pos: cursor.pos }
352352
else { pos: cursor.pos + 1, elem: cursor.elem }
353353

354354
-- | Try to find an element in a data structure which satisfies a predicate.

0 commit comments

Comments
 (0)