State Transformer
Ashley Yakeley
ashley@semantic.org
Sat, 19 Jan 2002 15:43:53 -0800
At 2002-01-19 08:16, Marcin 'Qrczak' Kowalczyk wrote:
>Here is mine. The same code can work with MVars too, as long as the
>order of operations is consistent with the empty/full state. The
>empty/full state is real for MVars and imagined for IORef/STRef.
Could you simply the interface if you consider (MVar a) to hold a (Maybe
a)?
class Monad m => Ref m a r | r -> m a where
newRef :: a -> m r
getRef :: r -> m a
setRef :: r -> a -> m ()
modifyRef :: r -> (a -> m a) -> m ()
instance Ref (ST s) a (STRef s a) where
...
instance Ref IO a (IORef a) where
...
instance Ref IO (Maybe a) (MVar a) where
...
--
Ashley Yakeley, Seattle WA