[Haskell-cafe] Re: Re: Re: monad subexpressions

Antoine Latter aslatter at gmail.com
Fri Aug 3 21:13:44 EDT 2007


On 8/3/07, Chris Smith <cdsmith at twu.net> wrote:
> Yes, unless of course you did:
>
>     instance (Monad m, Num n) => Num (m n)
>
> or some such nonsense. :)

I decided to take this as a dare - at first I thought it would be easy
to declare (Monad m, Num n) => m n to be an instance of Num (just lift
or return the operators as necessary), but I ran into trouble once I
realized I needed two things I wasn't going to get:

An instance of Eq (m n), and an instance of Show (m n) for all monads
m.  Eq would need a function of the form:

(==) :: Monad m => m a -> m a -> Bool

and Show would need a function of type m a -> String

There's no way I'm getting a function of those types using return and
join to operate on the monad.

So, there went that idea.

-Antoine


More information about the Haskell-Cafe mailing list