gleam-lang / suggestions

📙 A place for ideas and feedback
26 stars 2 forks source link

Allow underscore in custom type variants #133

Open sporto opened 3 years ago

sporto commented 3 years ago

When there are many custom types it can get quite hard to distingush where are they coming from. E.g. In Rust you can do WizardStage::SelectRecepients. But in Gleam you cannot, you can only see SelectRecepients.

One strategy I use quite often in Elm is to write the variant like WizardStage_SelectRecepients. This makes the code a lot clearer, as is easy to tell where the variant belongs to.

In Gleam I cannot have an underscore. The compiler complains. Using WizardStageSelectRecepients isn't great as there is no clear separation between the parts.

So it would be great to allow _ in these names (or some other character). Thanks

lpil commented 3 years ago

If we were to introduce this how would be enforce the naming convention? I wish to avoid any situation in which developers could disagree and debate the correctly way to format the name. Currently there is only one possible style.

Would you instead consider using a module namespace? wizard_stage.SelectReceptients

sporto commented 3 years ago

A namespace doesn't seem enough, I often have all the types in the same module. Trying to use namespaces would force me to create lots of modules. Unless I could define modules in the same file like OCaml.