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

Brandon Allbery allbery.b at gmail.com
Wed Aug 5 13:32:52 UTC 2015

On Wed, Aug 5, 2015 at 6:28 AM, Oliver Charles <ollie at ocharles.org.uk>

> I find myself wanting to be able to say something like:
> foo = ...
>   where import Something.Specific
> The result would be to import the contents of Something.Specific into the
> scope of foo and its other where bindings, but not import into the rest of
> the module that foo is defined in. As a motivating example, I'm currently
> working on building some HTML in Haskell, and the amount of symbols that
> come into scope is huge, when you have a DSL for both CSS and HTML - the
> real pain point being that you get symbols that often conflict.

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

brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150805/77f3e325/attachment.html>

More information about the Haskell-Cafe mailing list