Thanks all, it works fine (see below). <br><br>I lamentably try to make the same for show:<br>> showTypeable :: (Typeable a) => a -> String
<br>> showTypeable x = case cast x of<br>> Just x' -> show x'<br>> Nothing -> ""
<br><br>Because it really upsets me to add this show constraints to the Equ constructor ;)<br>what if i want to make an Obs instance with non showable elements, with no intention to show it of course? <br><br>Corentin<br>
<br>
> instance Typeable1 Obs where
<br>
> typeOf1 _ = mkTyConApp (mkTyCon "Obs") []
<br>
<br>
> (===) :: (Typeable a, Typeable b, Eq b) => a -> b -> Bool
<br>
> (===) x y = cast x == Just y
<br>
<br><br>> data Obs a where
<br>> Player :: Obs Player <br>> Official :: Obs Bool<br>> Equ :: (Eq a, Show a, Typeable a) => Obs a -> Obs a -> Obs Bool
<br>> Plus :: (Num a) => Obs a -> Obs a -> Obs a
<br>> Time :: (Num a) => Obs a -> Obs a -> Obs a
<br>> Minus :: (Num a) => Obs a -> Obs a -> Obs a
<br>> And :: Obs Bool -> Obs Bool -> Obs Bool
<br>> Or :: Obs Bool -> Obs Bool -> Obs Bool
<br>> Not :: Obs Bool -> Obs Bool
<br>> Konst :: (Show a, Eq a) => a -> Obs a
<br> <br> <br> <br>> instance Show t => Show (Obs t) where
<br>> show Player = "Player"
<br>> show Official = "Official"
<br>> show (Equ a b) = (show a) ++ " Eq " ++ (show b)
<br>> show (Plus a b) = (show a) ++ " Plus " ++ (show b)
<br>> show (Minus a b) = (show a) ++ " Minus " ++ (show b)
<br>> show (Time a b) = (show a) ++ " Time " ++ (show b)
<br>> show (Konst a) = " (Konst " ++ (show a) ++ ")"
<br>> show (And a b) = (show a) ++ " And " ++ (show b)
<br>> show (Or a b) = (show a) ++ " Or " ++ (show b)
<br>> show (Not a) = " (Not " ++ (show a) ++ ")"
<br> <br> <br>> instance Eq t => Eq (Obs t) where
<br>> Player == Player = True
<br>> Official == Official = True
<br>> Equ a b == Equ c d = (a,b) === (c,d) <br>> Plus a b == Plus c d = (a == c) && (b == d)
<br>> Minus a b == Minus c d = (a == c) && (b == d)
<br>> Time a b == Time c d = (a == c) && (b == d)
<br>> And a b == And c d = (a == c) && (b == d)
<br>> Or a b == Or c d = (a == c) && (b == d)
<br>> Not a == Not b = (a == b)
<br>> Konst a == Konst b = a == b
<br>> _ == _ = False
<br><br>