<div dir="ltr">If your instances are allowed to depend on values that are in scope in your nested context then the choice of those values is effectively part of the name of the data type. Otherwise I can package one of those 'local' data type definitions up, pass it out into another context that brings it back under the `where` clause that defined the local data type with a different value. So, yes, unless you're willing to figure out how to somehow decide the equality of arbitrary values and functions. If you try to say you can't write that sort of scenario by using some sort of magical generative trick that says each invocation of the function that got you down to that data type gives you an entirely 'fresh' type, I suspect you'll run into subtle problems with unification / type checking. I'd love to be wrong, but my expectation is that all of these paths fail.<div><br></div><div>In any event, Gershom is right, this is the wrong forum for this discussion.<br><div><div><div><br></div><div>-Edward<br><div><br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 29, 2018 at 7:37 PM, Matthew Farkas-Dyck <span dir="ltr"><<a href="mailto:strake888@gmail.com" target="_blank">strake888@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 4/29/18, Edward Kmett <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:<br>
> This isn't sound.<br>
><br>
> You lose the global uniqueness of instance resolution, which is a key part<br>
> of how libraries like Data.Set and Data.Map move the constraints from being<br>
> carried around in the Set to the actual use sites. With "local" instances it<br>
> is very easy to construct such a map in one local context and use it in<br>
> another with a different instance.<br>
<br>
</span>Ah, i forgot to say explicitly: local instances of types declared at<br>
greater scope are not allowed. Is it unsound nonetheless?<br>
</blockquote></div><br></div>