proposal: remove laws directory from repository
See original GitHub issueEarlier today I created #170 and #172, but I now realize that many of the property tests are dysfunctional. To provide one more example, the test for semigroup associativity seeks to assert:
(a `concat` b) `concat` c = a `concat` (b `concat` c)
Since it uses the same value for a
, b
, and c
, it actually asserts:
(a `concat` a) `concat` a = a `concat` (a `concat` a)
If a
is Identity('x')
and both sides evaluate to Identity('xxx')
, we haven’t proven the fantasy-land/concat
method of our Identity type to be associative, have we?
The functions provided in fantasy-land/laws
are not very useful. To actually test many of these properties we can’t use a universally applicable function such as identity :: a -> a
. Instead, we must use functions specialized to the data types being tested. Choosing these functions requires a great deal of care, and this is the thing which makes testing these properties challenging, not copying a line from the spec and adding the fantasy-land/
prefixes where appropriate.
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (15 by maintainers)
Top GitHub Comments
I’m in favour of moving the laws to a separate repository to allow releases for the two projects to be made independently. Currently we’re in an awkward position because we can’t really follow SemVer for the laws without confusing those who only use the spec.
The idea for the laws was to provide the laws in a easy to reference function setup, so you didn’t have to keep remembering what they are. This also prevents the issue of subtle bugs, which is how we’ve ended up in the left/right identity issue.
I like the
lhs
,rhs
setup as well as it eradicates the equality issue (not everything can be equal as some structures are lazy and require executing in certain ways), by putting that on the implementer.Something like (just an idea):