Skip to content

Commit

Permalink
Merge pull request #4425 from lenguyenthanh/include-foldr-in-foldable…
Browse files Browse the repository at this point in the history
…-doc

Add `foldr` note to `Foldable` doc
  • Loading branch information
armanbilge authored Apr 24, 2023
2 parents bb443b8 + cb782bc commit 896f00c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/typeclasses/foldable.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,12 @@ after looking at only one value:
```scala mdoc
Foldable[LazyList].foldRight(allFalse, Eval.True)((a,b) => if (a) b else Eval.False).value
```

Unfortunately, since `foldRight` is defined on many collections - this
extension clashes with the operation defined in `Foldable`.
To get past this and make sure you're getting the lazy `foldRight` defined
in `Foldable`, there's an alias `foldr`:

```scala mdoc
allFalse.foldr(Eval.True)((a,b) => if (a) b else Eval.False).value
```

0 comments on commit 896f00c

Please sign in to comment.