MonadRef class or the like?
Hal Daume III
hdaume@ISI.EDU
Wed, 18 Sep 2002 09:43:19 -0700 (PDT)
Is there any particular reason there isn't a class for monads for which
things like IORef/STRef exist? I suppose the naive approach would require
functional dependencies + mp typeclasses[1], which is a decent reason :),
but has anyone come up with something that doesn't require extensions?
[1] i'm thinking of something like:
class MonadRef m r | m -> r, r -> m where
newRef :: a -> m (r a)
readRef :: r a -> m a
writeRef :: r a -> a -> m ()
updateRef :: (a -> a) -> r a -> m ()
i think you need the FD in both directions (certainly you need m -> r); i
think the latter would serve to disambiguate things like readRef (having
not actually implemented this, though, i don't know).
- Hal
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume