Overlapping and incoherent instances

AntC anthony_clayden at clear.net.nz
Thu Jul 31 01:20:21 UTC 2014


> Simon Peyton Jones <simonpj <at> microsoft.com> writes:
> Tue Jul 29 09:11:05 UTC 2014
> ...
> This is a Big Hammer. 

I agree with Simon's motivation that the whole-module overlap pragma is 
often too brutal.

But I think that what Iavor has developed is still too brutal.
(Sorry, and I hadn't known about these instance-level pragmas before now.)

For my 2d, I think Andreas made an important distinction:

> Andreas Abel andreas.abel at ifi.lmu.de 
> Wed Jul 30 12:07:01 UTC 2014
>  The German equivalent of "overlap", ..., is used exclusively in a 
> symmetrical fashion.  It's like in English, if I say "our interests 
> overlap", then it is pointless to ask whether my interest are 
> overlapping yours or are overlapped by yours.

I'd say that the English "overlap" is also used in a symmetrical fashion
(outside of specialist Haskell instances usage).

There's a difference between:
- this instance is nec. narrower than some other instance
  (IOW anything that's a substitution for this instance,
   is ipso facto a substitution for some wider)
- vs. a partial overlap
  (some substitutions will fit this instance only,
   some will fit another instance, not this one,
   some will fit both)

In my experience, unintended partial overlaps are the nastiest to diagnose.
And partial overlaps are very seldom needed in practice.
They're often a symptom that two separately-developed libraries are 
clashing.

(For example the HList libraries -- as originally released --
 used overlap extensively, but no partial overlaps.)

So I would like the pragmas to be able to say:
OK for this instance to subsumes or be subsumed by some other instance
but it must not partially overlap any instance.

(I guess this is beyond the question Simon's OP asked.)


AntC




More information about the Glasgow-haskell-users mailing list