On Sat, Oct 17, 2009 at 3:21 PM, Andrew Coppin
<[email protected]> 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 <[email protected]>
<http://www.eyrie.org/~zednenem/>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe