Thu, 27 Apr 2000 00:27:05 -0700, Mike Jones <[EMAIL PROTECTED]> pisze:
> class (Monad m) => InstrumentMonad m where
> yuck :: a -> m a
This means that any type constructor that is an instance of Monad can
be made an instance of InstrumentMonad by providing the implementation
of yuck for this type constructor.
This implies that any InstrumentMonad is also a Monad, i.e. a context
(InstrumentMonad m, Monad m) will be simplified to (Monad m), and
that yuck :: InstrumentMonad m => a -> m a, and that you specify
implementations of yuck for various type constuctors in InstrumentMonad
instances.
> instance InstrumentMonad Vi where (Line 30)
> return a = Vi (\s -> (s, a))
> Vi sf0 >>= f =
return and (>>=) are methods of Monad, not of InstrumentMonad.
They should be defined for Vi in instance Monad Vi.
In instance InstrumentMonad Vi a function yuck should be defined,
with type a -> Vi a.
BTW. ghc-4.06 includes the module MonadState (requires -fglasgow-exts)
with a parametrized type constructor of state monads. It's enough to use
type Vi = State ViState
and you already have the Monad instance, with a couple of functions
to manage the state.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-