Skip to content

Namespacing for data constructors #140

@d-xo

Description

@d-xo

The current implementation places all data constructor names in the global scope. We do not check for duplicated data constructor names, and in the case where duplicates are present, one overwrites the other:

Fails

data Foo = Baz;
data Bar = Baz;

function main() {
  let x = Baz;
  let y : Foo = Baz;
}
Types do not match: Bar and Foo
 - in:let y : Foo = Baz ;
 - in:function main () {
   let x = Baz ;
   let y : Foo = Baz ;
}

Accepted

data Foo = Baz;
data Bar = Baz;

function main() {
  let x = Baz;
  let y : Bar = Baz;
}

Solution

Implement a namespace for all data constuctors (e.g. Foo.Baz and Bar.Baz) allowing duplication. Consider sugar (e.g. The . operator in lean, or c++ style ADL) to allow omitting the namespace qualifier in cases where a unique namespace can be inferred from the context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions