Before we define the specification, we need to set up the specs libraries, and grab a hold of our data structure and the laws we want to verify.
And to use the laws, we need to provide a constructor function, that given a single argument will return a new data structure containing that argument. We also make sure that the constructor for our semigroup implementation lifts the value into a non empty list, so we can concatenate the values.
Then we provide the specification for the test runner. As we're using
Hifive here, it expects that each definition for the specification to
have a function that will throw exceptions on failures. We use the
asTest
property from Claire that returns exactly what Hifive (and
Mocha & other testing libraries) expect.
Specification for the monadic laws