What do you think of introducing to Haskell-2  ad hoc ordering for the 
instance operlap?
For example,
----------------------------------------------------------------------
data C a = C a

class Convertible a b  where  cv :: a -> b -> b

instance (order 0) Convertible a a  where  cv a _ = a            -- Ia

instance Convertible a b => Convertible a (C b)                  -- Ic
  where
  cv a (C b) =  C (cv a b)
----------------------------------------------------------------------

I am suffering from that some compilers regard this particular program 
as ambiguous.
Here the types  (a,a) and (a,C b)  overlap and none of them is the
substitutional instance of another.

But let  (order 0)  point that on the overlapping area the instance Ia
has to apply - because its order is smaller than the default order for
Ic.
Generally, each instance of class <Cs> is assigned the order  o >= 0
- explicitly or by default.
Then for the type T matching the instances I1..Ik of <Cs> the compiler 
has to choose I(j) of the minimal order.
?


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








Reply via email to