[Haskell-cafe] Deriving something else?
John Ky
newhoggy at gmail.com
Mon Dec 8 07:03:42 EST 2008
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/8fec8768/attachment.htm
More information about the Haskell-Cafe
mailing list