[Haskell-cafe] Re: GHC 6.7 and Associated Types
mux at FreeBSD.org
Tue Apr 17 07:30:02 EDT 2007
> Maxime Henrion wrote:
> > class MonadState m where
> > type StateType m :: *
> > get :: m StateType
> > put :: m StateType -> m ()
> > As for instances:
> > instance MonadState (State s) where
> > type StateType = s -- this is line 22
> When defining the type function StateType, you have to give it the
> required argument m = State s:
> type StateType (State s) = s
> > get = State $ \s -> (s, s)
> > put s = State $ \_ -> ((), s)
I tried that too already, it gives:
Expected kind `k -> *', but `()' has kind `*'
In the type `m ()'
In the type `m StateType -> m ()'
In the class declaration for `MonadState'
Line 19 being the definition of put in the class.
More information about the Haskell-Cafe