Class ATs Question

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Apr 28 04:17:25 EDT 2006


Hello Ashley,

Friday, April 28, 2006, 5:09:07 AM, you wrote:

> You can do two-way fundeps. Can these be done with associated types? For
> instance:

> It might not be a great loss if not.

may be you want to say "it might be a great loss" ?

i'm using two-way fundeps to implement monad-independent algorithms
that uses references. these definitions:

class (Monad m) => Ref m r | m->r, r->m where
    newRef :: a -> m (r a)
    readRef   :: r a -> m a
    writeRef  :: r a -> a -> m ()
instance Ref IO IORef where
    newRef = newIORef
    readRef = readIORef
    writeRef = writeIORef
instance Ref (ST s) (STRef s) where
    newRef = newSTRef
    readRef = readSTRef
    writeRef = writeSTRef

allows me to write algorithms that works in both monads



-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-prime mailing list