Maxime Henrion wrote: > 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'
Ah, oh, I didn't even check whether the types in the class are good. I'm not sure, but don't you want class MonadState m where type StateType m :: * get :: m (StateType m) put :: StateType m -> m () ? Then, the substitutions m = State s and StateType (State s) = s yields the expected types for put and get: get :: (State s) s put :: s -> (State s) () Regards, apfelmus _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe