Tue, 29 Feb 2000 14:20:32 +0300 (MSK), S.D.Mechveliani <[EMAIL PROTECTED]> pisze:

> >     h :: Eq a => a -> a -> Int
> >     h x y = if x == y then 0 else 1 + h [x] [y]
> > which would make h "1" "2" return 7 if in some other module there is:
> >     instance Eq [[[[[[[String]]]]]]] where
> >         x == y = length x == length y
> 
> I wonder, is this really a problem to compile this?

I certainly believe so.

> As this instance got to the scope, the compiler adds dictionaries
> for  Eq a => Eq [..[a]..]  up to the number  7  of them to pass to
> h  (assume the compiler adds the deduced context).

h did not know about these instances - does not accept anything more
than a single dictionary of Eq a!

And if you referred to a case where they are visible at the place
of definition of h, it is still very hard to deduct that instances
being built will lead to the one that is defined separately. It
would probably require to look up at runtime each dynamically built
instance in a large repository of all instances - a big complication
and performance hit.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a22 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-

Reply via email to