Engineer Chris Phelps presented at LambdaConf 2018, Boulder CO USA with his talk on Testing for Lawful Good Adventurers where he spoke on how laws arise as well as the advantages they provide and how he tested the lawfulness of an implementation differs from testing other domain specifics of the implementation.
'Practitioners of functional programming often speak about "lawful abstractions." Whether implementing well-known mathematical concepts or novel ideas, we can define laws to specify constraints on how an abstraction should behave. These allow us a way to prove the correctness of algorithms separate from domain and data details and allow for flexibility and freedom in algorithm implementation.
In this session, we will discuss how laws arise, and see the advantages they provide for both algorithm and data structure implementers. We'll see how testing the lawfulness of an implementation differs from testing other domain specifics of the implementation. We will look at ways to test the lawfulness of an implementation in Scala. We will see how laws help inform and empower the typeclass pattern and allow for reuse and composition.'