15 Sep
2005
15 Sep
'05
8:28 p.m.
On 15.09 23:40, Bulat Ziganshin wrote:
of course
class Ref c a where new :: a -> IO (c a) get :: c a -> IO a set :: c a -> a -> IO ()
Maybe even: class Ref m t where new :: a -> m (t a) get :: t a -> m a set :: t a -> a -> m () Or if you want to support things like FastMutInts class Ref m t v where new :: v -> m t get :: t -> v -> m a set :: t -> v -> m () That would even support an evil IOArray instance: instance Ref IO (IOArray Int v, Int) v where new iv = newArray_ (0,iv) get (arr,idx) = readArray arr idx set (arr,idx) val = writeArray arr idx val - Einar Karttunen