Hi,

I've defined a class and some instances, which I'm hoping would help me
"show" values of types that may include transactional elements.

class TShow a where
   tshow :: a -> IO String

instance Show (TVar a) where
   show = "%"

instance (Show a) => TShow a where
   tshow a = return $ show a

instance (Show a) => TShow (TVar a) where
   tshow ta = do
      a <- readTVar ta
      return $ show a

Having created a new class is it possible to do some magic so that it can be
put it into a deriving clause?

data Type = Type
   { field1 :: Int
   , field2 :: Int
   }
   deriving Show

data AnotherType = AnotherType
   { field3 :: Int
   , field4 :: TVar Type
   }
   deriving *TShow*

Thanks

-John
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to