
17 Oct
2009
17 Oct
'09
3:37 p.m.
On Sat, Oct 17, 2009 at 3:21 PM, Andrew Coppin
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