Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"opening" datatypes #53

Open
YawarRaza7349 opened this issue Feb 16, 2024 · 0 comments
Open

"opening" datatypes #53

YawarRaza7349 opened this issue Feb 16, 2024 · 0 comments

Comments

@YawarRaza7349
Copy link

This is a proposal that could actually be added to Successor ML implementations (SML/NJ and MLton).

I was looking the MLton codebase and noticed code like this popping up everywhere.

datatype z = datatype Control.Target.arch
datatype z = datatype Control.Target.os
datatype z = datatype Control.Format.t
datatype z = datatype Control.codegen

I had no idea what the point of creating an "alias" and immediately shadowing it would be. I had to look at several examples to realize the purpose of this: it's to make the constructors of each datatype available without qualification.

It would be much clearer if, instead of a weird idiom, this could be expressed directly as:

open datatype Control.Target.arch
open datatype Control.Target.os
open datatype Control.Format.t
open datatype Control.codegen

Or even:

open datatype Control.Target.arch Control.Target.os
  Control.Format.t Control.codegen

Since datatype is a keyword, it can't be the name of a module, so there's no ambiguity with open for modules.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant