[Haskell-cafe] Return of the revenge of the revisit of the extensible records, reiterated

AntC anthony_clayden at clear.net.nz
Tue Dec 3 07:25:45 UTC 2013

> John Lato <jwlato <at> gmail.com> writes:

> On Mon, Dec 2, 2013 at 9:17 PM, AntC wrote:
> > ...
> Importing an overlapping instance is trapped immediately;
> no risk of incoherence.
> How can this possibly work with open type families?  What happens in this 
> > module A where
> > type instance F a b c | b /~ c = Int
> > module B where
> > type instance F a b c | a /~ c = Bool
> During compilation, neither A nor B is aware of the other.  What happens 
in a module that imports both?

Thanks John, a good use case!

The trapping is needed with imports for any approach to open instances (not 
just type families). Suppose I have NoOverlappingInstances everywhere: 

> module A where
> instance C a b c where ...
> module B where
> instance C a b c where ...
> module D where
> instance C Int Bool Char where ...

And a module that imports all three.
Any importer has to validate all instances sometime or other.

(Currently ghc sticks its head in the sand,
 and hopes there won't be a usage that trips over the ambiguity.)

All we're talking about is _when_ we validate.
I'd rather know at the point of declaring the instance,
or of importing the instance.


More information about the Haskell-Cafe mailing list