Skip to content

Open Extensible Types #5584

@vicuna

Description

@vicuna

Original bug ID: 5584
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:26:46Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Related to: #6219
Monitored by: @gasche @lpw25 mehdi @diml @ygrek @yallop @hcarty @yakobowski @alainfrisch

Bug description

OCaml already has one open extensible type (exn), it would be useful to extend this and allow abstract types to be declared open.

This could be particularly useful when combined with GADTs.

Example syntax:

open type foo

extend foo with Constr of int

open type 'a bar

extend _ bar with Gadt1: int bar

extend char bar with Gadt2

I've attached a patch (tested with revision 12270) and more details can be found at:

https://sites.google.com/site/ocamlopen/

Note that this patch does not yet add these extensions to the camlp4 parser, and may break existing camlp4 code.

File attachments

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions