You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix foldMapDefaultL
Previously,
```purescript
foldMapDefaultL singleton [1, 2] = [2, 1]
```
This commit fixes this:
```purescript
foldMapDefaultL singleton [1, 2]
= foldMapDefaultR singleton [1, 2]
= [1, 2]
```
* Refactor test to detect foldMapDefaultL bug
This refactors the test for the Foldable instance of array and the
default implementations of Foldable's functions.
In a way, it does not really make sense to test the default
implementations of Foldable's functions, because they are part of the
rules of the type class. Up to execution speed and memory usage, every
valid instance has to satisfy
```purescript
foldMap = foldMapDefaultL
foldMap = foldMapDefaultR
foldl = foldlDefault
foldr = foldrDefault
```
and, for any reasonable instance that is also a functor,
```purescript
foldMap f = fold <<< map f
```
Testing these properties for some instances that we think are valid
should reveal errors in the specification.
I've refactored the test so that the equations above can be tested via
`foldMap` on any Monoid m, in particular on non-commutative monoids such
as `Array a`, which detects the `foldMapDefaultL` bug.
* Revert "Refactor test to detect foldMapDefaultL bug"
This reverts commit a9d74ce.
* Add test for fix in 0fa2889
0 commit comments