haskell / mtl

The Monad Transformer Library
http://www.haskell.org/haskellwiki/Monad_Transformers
Other
360 stars 63 forks source link

MonadAccum law tests #125

Open kozross opened 2 years ago

kozross commented 2 years ago

This relates to this comment here. Specifically, these tests use property-based testing to exercise all the stated laws of MonadAccum, with a large enough test count to be meaningful.

kozross commented 2 years ago

@andreasabel I mostly tagged you as a reviewer because you suggested/requested some tests. Was this what you had in mind?

I started with MonadAccum for two reasons: it's one of the (currently only two) type classes provided by mtl which even states any laws, and of the two, it is by far the easiest, both in terms of the laws themselves, and also to test.

andreasabel commented 2 years ago

Well done!

I started with MonadAccum for two reasons: it's one of the (currently only two) type classes provided by mtl which even states any laws, and of the two, it is by far the easiest, both in terms of the laws themselves, and also to test.

Testing the laws is of course the gold standard!

Even simple unit tests that cover the functionality are useful, detecting basic problems like missing exports, unintended loops, etc.