test-monad-laws: Laws for mtl classes as QuickCheck properties.

[ library, mit, test ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.0.0.0
Dependencies base (>=4.9 && <5), monad-control, mtl, QuickCheck (>=2.12), quickcheck-higherorder, transformers, transformers-base [details]
License MIT
Copyright 2017-2020 Li-yao Xia
Author Li-yao Xia
Maintainer lysxia@gmail.com
Category Test
Home page https://github.com/Lysxia/test-monad-laws#readme
Source repo head: git clone https://github.com/Lysxia/test-monad-laws
Uploaded by lyxia at 2020-09-26T22:49:59Z
Distributions
Downloads 289 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-09-26 [all 1 reports]

Readme for test-monad-laws-0.0.0.0

[back to package description]

Testable monad and mtl laws

A library for testing implementations of mtl classes.

test-monad-laws defines laws for monadic effects as QuickCheck properties.

To use this library, quickcheck-higherorder is also needed.

Supported classes:

  • mtl: MonadExcept, MonadReader, MonadState, MonadWriter
  • transformers: MonadTrans
  • transformers-base: MonadBase
  • monad-control: MonadTransControl, MonadBaseControl

This project also tests the effectiveness of these laws, by including some incorrect implementations, called mutants, and some invalid laws.

Organization

For every mtl class, for example MonadReader:

  • The most important module is Test.Monad.Reader, defining laws for the class. Note that these laws are not official. But if your instance does not satisfy them, now you know.
  • Mutants and bad laws are in Test.Monad.Reader.Mutants.
  • For convenience, all the good laws are gathered in a single list in Test.Monad.Reader.Checkers. It can easily be consumed by the library tasty-quickcheck.

Papers with some relevant laws:

  • Just do it: Simple Monadic Equational Reasoning. Jeremy Gibbons, Ralf Hinze.
  • Proof abstraction for imperative languages. William L. Harrison.

Hackage search terms: laws, properties.