-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open Extensible Types #5584
Description
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.