Please, what is wrong here?

------------------------------------------------------------
module T where

class S a          where  s :: a -> a
class S a => OS a  where  o :: a -> a
class S a => R a   where  r :: a -> a 

data F a = F a a  

instance R a              => S  (F a)  where  s x = x
instance (R a,OS a)       => OS (F a)  where  o x = x

instance (R a,OS a,Num a) => S  (F a)  where  s _ = error ""  --
------------------------------------------------------------


ghc -c  -fglasgow-exts -optC-fallow-overlapping-instances  T.hs

reports
T.hs:10:
    Could not deduce `Num a'
        (arising from an instance declaration at T.hs:10)
        from the context (R a, OS a)
    Probable cause: missing `Num a' in instance declaration context
    When checking the superclasses of an instance declaration


This is  ghc-3.02-i386-unknown-bin...  taken from
                                      dcs.gla.ac.uk..../glasgow/3.02


The idea was that the second  S (F a)  is defined more specifically.
OS (F a)  uses the instance of  S (F a).  It has to choose the one
which is more specific for the given data - ?


------------------
Sergey Mechveliani
[EMAIL PROTECTED]





Reply via email to