the MPTC Dilemma (please solve)

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun Mar 19 15:18:54 EST 2006


Hello Manuel,

Sunday, March 19, 2006, 7:25:44 PM, you wrote:

>> i had a class which defines "default" reference type for monads:
>> 
>> class Ref m r | m->r where

to be exact,

class Ref m r | m->r, r->m where
>>   newRef :: a -> m (r a)
>>   readRef :: r a -> m a
>>   writeRef :: r a -> a -> m ()

or even worser:

class Ref2 m r a | m a->r, r->m
instance (Unboxed a) => Ref2 IO IOURef a
instance (!Unboxed a) => Ref2 IO IORef a
instance (Unboxed a) => Ref2 (ST s) (STURef s) a
instance (!Unboxed a) => Ref2 (ST s) (STRef s) a

MMTC> My statement remains:  Why use a relational notation if you can have a
MMTC> functional one?

how about these examples?

MMTC>   class Monad m => RefMonad m where
MMTC>     type Ref m :: * -> *

can i use `Ref` as type function? for example:

data StrBuffer m = StrBuffer (Ref m Int)
                             (Ref m String)
                             
-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-prime mailing list