Closed favonia closed 3 years ago
The trolling but otherwise very clear import syntax:
import x.y [ -> none] -- imports nothing
import x.y [x -> private x] -- imports everything (default)
import x.y [x -> public x] -- same as "public import"
import x.y ["z" | "y" as z -> public z | "op2" -> private "op1" | _ -> none]
EDIT: This comment is outdated
omg this would be so great to have!!!
@favonia As powerful as the notation you are suggesting is, I think it might be clearer to our users if we did something a bit more simple-minded and less powerful, maybe along the lines of what is supported in Agda.
(BTW I'm still open to some very powerful version like you suggest)
Well, we can support the less powerful syntax and compile it down to the ultimate syntax. To me, it is never clear what Agda would do if I simultaneous use and hide and/or rename something. (In fact, I just discovered that the documentation was outdated!)
How about this dumb version?
import x.y [ -> hidden ] -- import nothing
public import x.y [ -> hidden ] -- (same as above)
import x.y [ ] -- import everything (default)
import x.y -- (same as above)
public import x.y [ -> private ] -- (same as above)
import x.y [ -> public ] -- import and re-export everything
public import x.y [ ] -- (same as above)
public import x.y -- (same as above)
import x.y [ z | y -> public | op2 -> public op1 | -> hidden ] -- import and re-export z and y, import and re-export op2 as op1, and hide everything else
import x.y [ z | y -> hidden ] -- import everything except z or y
import x.y [ z | y -> hidden | -> public ] -- import and re-export everything except z or y
The defult tag is private
for import
or public
for public import
. Anything not mentioned by the case analysis is implicitly treated as the default tag says.
The full version distinguish meta-variables from names, which means
import x.y ⦉ write your own ML function of type "string list -> string list tag list" ⦊
The restriction is that this needs to be injective except for hidden
.
The full syntax of name modifiers is:
<: ML function :>
or
"[" (cases divided by "|") "]"
A case is one of the following:
pattern -> [tag] [name path]
pattern -> hidden
and a tag is either "public" or "private". A pattern is (in terms of grammar):
atomic_pattern := name | name DOT atomic_pattern | "(" pattern ")"
pattern := | [atomic_pattern] "|" pattern
The pattern is executed by the longest-prefix matching.
This design based on transformers on individual names is misguided. It seems better to define transformers on the entire trees so that we could detect useless imports, etc. For example, importing an non-existing item should be an error, but in this design such an error could not be detected.
import
with the new syntax.[ ] enable the most powerful ML version.
(The issue description contains the latest syntax.)
The full import syntax is
and the full syntax of name modifiers is:
Comparison with Agda:
Something that Agda can't do: