Local types and instances

Gershom B gershomb at gmail.com
Mon Apr 30 00:33:12 UTC 2018


Given the open world assumption, how do you know a priori if a type is declared at greater scope?

(Note: one answer here is that you can refuse to link in such a contradictory instance, so instead of an ‘open world’ you move to a ‘coherent world’ where you have to discharge a global coherence constraint check at compile time — I never fully fleshed this out, but I think it might open a number of interesting possibilities).

(Also — I just realized this is in the wrong location — the haskell-prime list. Proposals like this that do not exist yet in any compiler tend to be out of scope for the prime process, such as it exists. It would be better to produce a sketch and ask for feedback in a different venue — perhaps glasgow-haskell-users, and if you reach a point where you have a full spec then you can submit it through the ghc proposals process.)

-g


On April 29, 2018 at 7:37:30 PM, Matthew Farkas-Dyck (strake888 at gmail.com) wrote:

On 4/29/18, Edward Kmett <ekmett at gmail.com> wrote:
> This isn't sound.
>
> You lose the global uniqueness of instance resolution, which is a key part
> of how libraries like Data.Set and Data.Map move the constraints from being
> carried around in the Set to the actual use sites. With "local" instances it
> is very easy to construct such a map in one local context and use it in
> another with a different instance.

Ah, i forgot to say explicitly: local instances of types declared at
greater scope are not allowed. Is it unsound nonetheless?
_______________________________________________
Haskell-prime mailing list
Haskell-prime at haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-prime/attachments/20180429/c87acc08/attachment.html>


More information about the Haskell-prime mailing list