I have created a type which implements Functor, Applicative and Monad. I wanted to verify that they follow the laws of each. But upon trying to do this manually, it turned into a daunting and quite difficult task.
So, what I am wondering is:
How can I automatically test that the laws of each class are properly implemented?
But upon trying to do this manually, it turned into a daunting and quite difficult task.
One way is to state your laws in a language like Coq and formally prove them. For example, John Wiegley proved pipes law in Coq.
How can I automatically test that the laws of each class are properly implemented?
You cannot get a strong guarantee unless you prove them. Maybe you can check their property using a library like Quickcheck .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.