[Haskell-cafe] Syntax extension - adding import support to let/where bindings

Oliver Charles ollie at ocharles.org.uk
Wed Aug 5 14:20:21 UTC 2015

On Wed, Aug 5, 2015 at 2:32 PM, Brandon Allbery <allbery.b at gmail.com> wrote:

> 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.)
> I wonder if this use case can be addressed by a different mechanism
> (extension), though:
>     import qualified Something.Specific
>     {- ... -}
>     foo = ...
>       where using Something.Specific -- names would be unqualified in this
> scope

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

If we use import and rule out instance importing, then we might have to
improve the error messages about missing instances. For example,

    No instance for (Eq Foo)
    In the expression: foo == foo
    In an equation for ‘it’: it = foo == foo
    Note: an instance was found in Foo, but this must be imported at the
module level.

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.

using could also work, at the cost of taking up another keyword (and a
potentially useful keyword, as using has meaning in other languages that we
may ultimately find ourselves wanting in Haskell).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150805/da0ddb20/attachment.html>

More information about the Haskell-Cafe mailing list