[Haskell-cafe] Re: GHC 6.7 and Associated Types
Maxime Henrion
mux at FreeBSD.org
Tue Apr 17 07:30:02 EDT 2007
apfelmus wrote:
> 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:
State.hs:19:39:
Kind mis-match
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.
Cheers,
Maxime
More information about the Haskell-Cafe
mailing list