Importing type variants (continued from discussion #3232) #3512
barcek
started this conversation in
Ideas & suggestions
Replies: 1 comment 1 reply
-
Types are not namespaces, modules are. Your code would be written like so: import types
...
"url" -> types.Url
... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Adding a thought on this subject, re something I've noticed early on using Gleam. Importing a larger number of variants can get unwieldy, especially having to update imports if the custom type is extended or reduced at a later point in development.
From @Dan-C-Reed's use in discussion #3232):
This works, but is just two variants. There could be more:
It would be useful if all variants didn't need to be imported, but could be accessed via the type in place, e.g.:
This would help clarify the relationship between variants locally too.
Using the qualified import syntax, i.e. accessing via the module name, is possible and reasonable if there's only one custom type per module, but with multiple types each with multiple variants also potentially confusing.
Beta Was this translation helpful? Give feedback.
All reactions