Enable the importing of module fields so that they can be used in an unqualified fashion.
Possible syntax:
import gleam/pair.{Pair}
fn main() -> Pair(Int, Int) {
Pair(1, 2)
}
@lpil hello~just hope you could help me...
I've make some changes, and currently:
import gleam/pair -> pr
this grammer passes, but
import gleam/pair -> Pair
returns:
3 | import gleam/pair -> Pair
| ^^^^ Unexpected token
|
Expected one of r#"[a-z][0-9a-z_]*"#
Where can I fix this?
Hi @djKooks ! I think the syntax we're after is more like this:
import gleam/pair.{Pair, map_first}
The syntax with -> has already been implemented for functions so no need to worry about that :)
@lpil hello~have some question.
I'm checking grammer.lalrpop file, and it seems this is allowing as for renaming function name, such as:
import gleam/pair as gpair
In this case how do we should define when importing multiple module field, like:
import gleam/pair.{Pair, first} as ???
Please let me know if there is any misunderstaning.
Thanks.
I've not settled on what the exact syntax should be yet but this is my current thinking:
import gleam/pair.{Pair as PairConstructor, first as first_function} as list_module
@lpil hmm...then in this case, are these same?
Yes, that's right.
@lpil oh, is it updated?
Yes, I finished this off yesterday, minus the aliasing using as