[Haskell-cafe] Monadic correctness

Edward Z. Yang ezyang at MIT.EDU
Sat Oct 17 15:29:57 EDT 2009

Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009:
> Suppose we have
>    newtype Foo x
>    instance Monad Foo
>    runFoo :: Foo x -> IO x
> What sort of things can I do to check that I actually implemented this 
> correctly? I mean, ignoring what makes Foo special for a moment, how can 
> I check that it works correctly as a monad.

A proper monad obeys the monad laws:


You can probably cook up some quickcheck properties to test for these,
but really you should be able to convince yourself by inspection  that
your monad follows these laws.


More information about the Haskell-Cafe mailing list