<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 2:32 PM, Brandon Allbery <span dir="ltr"><<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">The biggest problem with this is the question of instances. The typechecker requires that all instances be global; otherwise you can break invariants. (Consider what happens if a different Ord instance is in scope in that part of the program.)</div><div class="gmail_extra"><br></div><div class="gmail_extra">I wonder if this use case can be addressed by a different mechanism (extension), though:</div><div class="gmail_extra"><br></div><div class="gmail_extra">    import qualified Something.Specific<br>    {- ... -}</div><div class="gmail_extra">    foo = ...</div><div class="gmail_extra">      where using Something.Specific -- names would be unqualified in this scope</div></div></blockquote><div><br></div><div>This is a good point. I hadn't considered that, but I wouldn't want to be importing instances - only symbols (types, type families, top level definitions).</div><div><br></div><div>If we use <font face="monospace, monospace">import</font><font face="arial, helvetica, sans-serif"> and rule out instance importing, then we might have to improve the error messages about missing instances. For example,</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><div><font face="monospace, monospace">    No instance for (Eq Foo)</font></div><div><font face="monospace, monospace">    In the expression: foo == foo</font></div><div><font face="monospace, monospace">    In an equation for ‘it’: it = foo == foo</font></div><div><font face="monospace, monospace">    Note: an instance was found in Foo, but this must be imported at the module level.</font></div><div style="font-family:arial,helvetica,sans-serif"><br></div></div><div style="font-family:arial,helvetica,sans-serif">Obviously the wording is open for discussion, but the idea is that GHC could be aware of the instances, find them, but refuse to use them. Questionable whether we want this, but it's an idea.</div><div style="font-family:arial,helvetica,sans-serif"><br></div><div><font face="monospace, monospace">using</font><font face="arial, helvetica, sans-serif"> could also work, at the cost of taking up another keyword (and a potentially useful keyword, as </font><font face="monospace, monospace">using</font><font face="arial, helvetica, sans-serif"> has meaning in other languages that we may ultimately find ourselves wanting in Haskell).</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><i>ocharles</i></font></div></div></div></div>