{-# OPTIONS -XPatternSignatures #-}
{-# OPTIONS -XTypeSynonymInstances #-}

data H_XML = XML String
             deriving (Eq)

instance Show H_XML where
   show (XML s) = s

instance Read H_XML where
   readsPrec i s =  [(XML s,"")]

class ToXML a where
  toXML :: a -> H_XML
  fromXML :: H_XML -> a

-- class FromXML a where
--  fromXML :: H_XML -> a

instance ToXML Bool where
  toXML b = XML (show b)
  fromXML (XML b) = read b

-- instance FromXML Bool where
--   fromXML (XML b) = read b

instance ToXML Int where
  toXML i = XML (show i)
  fromXML (XML i) = read i

--instance FromXML Int where
--  fromXML (XML i) = read i

instance ToXML String where
  toXML s = XML (show s)
  fromXML (XML s) = read s

-- instance FromXML String where
--  fromXML (XML s) = read s

instance (ToXML a, ToXML b) => ToXML (a,b) where
  toXML (a,b) = XML ("result")
  fromXML s = (fromXML s, fromXML s)

-- testConversion s = toXML (fromXML s)

-- prop_XMLConvert s  = s == toXML (fromXML s)
prop_XMLConvert' s  = s == toXML (fromXML s :: Int)

prop_XMLConvert2 i = i == fromXML (toXML i)

   
  