Skip to content

non-recursive type declarations #6016

Description

@vicuna

Original bug ID: 6016
Reporter: @diml
Assigned to: @diml
Status: closed (set by @xavierleroy on 2016-12-07T10:47:21Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: later
Target version: later
Fixed in version: 4.02.2+dev / +rc1
Category: typing
Related to: #6623
Monitored by: bobot "Julien Signoles" @Chris00

Bug description

All type declarations are by default recursive. This is a problem when one wants to alias a type in a sub-module. The classic solution is to create a "proxy" type:

  type t
  module M = struct
    type tmp = t
    type t = tmp
  end

At Jane Street we have been using a camlp4 extension to do that automatically when a type is marked with the keyword "nonrec":

  type t
  module M = struct
    type nonrec t = t
  end

We believe it could be useful to everybody and it would be better to have it into the language proper, for instance to avoid polluting signatures with useless types everywhere.

File attachments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions