Hi all,
I have below duplicate code, but i don't know how to use TH instance code.
------------------------------> duplicate code start
<------------------------------
instance Variable PageType where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: PageType) $ fromVariant x
instance Variable Int where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: Int) $ fromVariant x
instance Variable (Maybe Char) where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: Maybe Char) $ fromVariant x
instance Variable (Maybe Int) where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: Maybe Int) $ fromVariant x
instance Variable ProcessID where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: ProcessID) $ fromVariant x
instance Variable GWindowId where
toVariant = toVariant . show
fromVariant x = fmap (\v -> read v :: GWindowId) $ fromVariant x
------------------------------> duplicate code end
<------------------------------
Any TH expert help?
Thanks,
-- Andy
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe