Mike Jones writes:
> I am having a problem with a derived class. I define:
>
> class (Monad m) => InstrumentMonad m where
> yuck :: a -> m a
>
> Then I define:
>
> instance InstrumentMonad Vi where (Line 30)
> return a = Vi (\s -> (s, a))
> Vi sf0 >>= f =
> Vi $ \s0 ->
> let
> (s1, a1) = sf0 s0
> Vi sf1 = f a1
> (s2, a2) = sf1 s1
> in (s2, a2)
>
> And when I compile, I get the error:
>
> Vi.hs:30:
> No instance for `Monad Vi'
> arising from an instance declaration at Vi.hs:30
>
> Vi.hs:31: Class `InstrumentMonad' does not have a method `return'
>
> Vi.hs:32: Class `InstrumentMonad' does not have a method `>>='
You need to define the methods for class Monad (return, >>=) in an instance
for class Monad, and the methods for class InstrumentMonad (yuck) in an
instance for class InstrumentMonad.
--
Frank Atanassow, Dept. of Computer Science, Utrecht University
Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
Tel +31 (030) 253-1012, Fax +31 (030) 251-3791