Skip to content

"opening" datatypes #53

@YawarRaza7349

Description

@YawarRaza7349

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions