As I know the ST monad doesn't provide getState/setState functions. In order to get this kind of overloading we need to put all functions that deal with references in type class: class MonadRef m r where readRef :: r a -> m a writeRef :: a -> r a -> m () I guess that this is an overkill since we can just define IO as type IO a = ST RealWorld a Krasimir --- Keean Schupke <k.schupke@imperial.ac.uk> wrote:
Krasimir Angelov wrote:
ered on top of ST and the stToIO is the lifting function. What does 'automatically be lifted' mean?
Krasimir
For example with the state monad you can define:
instance (MonadState st m,MonadT t m) => MonadState st (t m) where update = up . update setState = up . setState getState = up $ getState
This makes any monad transformer applied to the StateMonad transformer an instance of the StateMonadTransformer. When you use getState, you do not have to prefix the lifting, the type checker unwinds the instance, and for each transformer it removes adds a lift.
If is only possible to define the above for some monad-transformers. In other cases the lifts must be specific to the monad-transformer being lifted through, in which case you would define:
instance Monad m => MonadTransX (MonadState m) where ...
This would be for lifting functions of MonadTransX through MonadState specifically.
Keean.
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
__________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com