Hi, There was an email about this some time ago which discussed this problem for the special case of the ST-monad:
http://www.haskell.org/pipermail/haskell/2001-September/007922.html What I really would like to see is a proof that such refmonads cannot be encoded in pure Haskell. Cheers, /Josef On Thu, 29 May 2003, Tim Sweeney wrote: > Given the common definition of RefMonad: > > class Monad m => RefMonad m r | m -> r where > newRef :: a -> m (r a) > readRef :: r a -> m a > writeRef :: r a -> a -> m () > > Is it possible to actually implement a working instance of RefMonad in > Haskell, without making use of a built-in monad like IO or ST? If so, > I'd love any tips -- I've been making good use of monads for a while, > but can't figure this one out. > > The Java programmer in me wants to implement RefMonad by passing > around a function from integers (think of them as pointers or heap > indices) to "objects", and in readRef, "cast" the "object" to the > appropriate type "t". > > If it's not possible to implement a typesafe RefMonad instance > directly in Haskell, without making use of built-in imperative > features like IO, then doesn't this refute the claims that monads > implement imperative features functionally? > > -Tim _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell