[Haskell-cafe] Syntax extension - adding import support to let/where bindings
ollie at ocharles.org.uk
Wed Aug 5 16:55:52 UTC 2015
On Wed, Aug 5, 2015 at 5:43 PM Evan Laforge <qdunkan at gmail.com> wrote:
> > In practice I use a lot more than just two symbols. The point is the
> > repeated qualification quickly introduces more noise and obscures the
> > of the code.
> Well, qualification is only necessary for the symbols that conflict,
> right? It seems to me that if you want an EDSL with a certain
> prelude, you have to make sure the prelude symbols are all distinct.
> If you want to compose two DSLs, then you could make a third prelude
> that imports the other two, but renames colliding symbols.
At this point I am working for the compiler (and in this case doing a lot
of work!), but it should be the other way round - this makes me sad.
Unless there are many collisions... in which case, maybe don't define
> your EDSLs like that in the first place?
My EDSLs for HTML and CSS are meant to reflect those actual languages as
closely as possible. If I start renaming things just to "fit in" with other
symbols, then I've started adding burden on my users.
Also, let's not forget this proposal is useful for more than just EDSLs, so
lets not get too caught up on that - for example, one might wish to import
Data.Text.Lazy or Data.Text in different locations depending on what they
are working with. There are many packages out there with conflicting
symbols that have fairly "localised" use sites, but at a granularity of a
top-level definition rather than a module.
Currently if you want to figure out all imports you parse the top of
> the file and can stop at the first definition. But with this feature
> you have to parse the whole file and thus understand all haskell
> grammar, including all extensions in use. I'd have to give up on my
> fast deps chaser and switch to slow ghc -M... which is maybe the right
> way anyway, I don't know.
> Ok, to be fair, I wouldn't, because I could choose to not use that
> feature, but in *theory* :) And while "you don't have to use it" is
> always brought up, it seems to me the more successful the feature is
> the more likely you do have to use it.
It makes me sad if we can't progress the language on the grounds that
people's attempts at parsing the source code themselves would break. If you
want to know all the imports, then we should be providing this information
through tools for people to consume.
On the other hand, lots of languages have a "local open" feature like
> this. I think many of them make you first import the module, and then
> you can "open" it in a local scope. This would address both my "parse
> the whole file for imports" objection and the "what about instances",
> because module importing would be unchanged.
Indeed, this could be a path forward. I'm not really familiar with any
languages that do this, could you link to some examples of how this works
in other languages?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe