18 Oct
2009
18 Oct
'09
3:37 a.m.
On Sat, Oct 17, 2009 at 3:21 PM, Andrew Coppin <andrewcoppin@btinternet.com> wrote:
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.
Anything which satisfies the monad laws is a monad. In other words, do you have: return a >>= f = f a m >>= return = m (m >>= f) >>= g = m >>= (\a -> f a >>= g) When I bother, I usually just work out the proofs by hand. -- Dave Menendez <dave@zednenem.com> <http://www.eyrie.org/~zednenem/>