New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revised Syntax for Polymorphic Variants #2494
Comments
Comment author: administrator Hello, Yes, patches are welcome. Send them to caml-bugs@pauillac.inria.fr, as -- Michel cdutchyn@cs.ubc.ca wrote/écrivait (Thu, Apr 22, 2004 at 09:16:35PM +0200):
|
Comment author: administrator Fixed by MM on 2004-05-25 |
Comment author: administrator Christopher, I've fixed most of the bugs you reported. More precisely:
Right: this remains to be done. Briefly, here is the correspondence: [ Other constructs ("[<" and "[>") are unchanged.
See the correspondence above.
Fixed.
Fixed. Thanks for reporting this bug. -- Michel |
Original bug ID: 2494
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Christopher Dutchyn
Version: 3.07+2
OS: Solaris5 / WindowsXP / FreeBSD
Submission from: n247-118.wireless.ubc.ca (142.103.247.118)
Several problems with revised syntax:
1) there is no documentation on how to write polymorphic variants
2) it appears that you can only write one variant per type declaration
3) there is a mandatory whitespace requirement in variants
4) the pretty printer for the revised syntax uses deprecated syntax
I cannot locate any documentation on how to write polymorphic variants in the
revised syntax in the 3.07 tutorial or manual.
Looking through the camlp4/meta/pa_r.ml source, it appears that
type foo = [|
Foo of int |
Bar of string |];works, with a deprecated warning. The nondeprecated syntax seems to be:
type foo = [ <
Foo of int | <
Bar of string ];except that you only get one variant:
type foo = [ <
Foo of int ]; The following variations fail with errors: type foo = [ <
Foo of int | <Bar of string ]; (* type foo = [ <
Foo of int |Bar of string ]; *) (* Parse error: [field] expected after '<' (in [type]) *) (* interestingly the error message drops the "<" before
Bar )type foo = [ <
Foo of int |
Bar of string ];( Unbound type parameter [..] )
( I guess this makes sense, but shows the previous error )
( message emits invalid syntax. *)
Unexpectedly, one must have a space between "[" and "<":
type foo = [<`Foo of int ];
(* Parse error: [type] expected after '=' (in [type_declaration]) *)
The pretty printer for revised syntax outputs the deprecated syntax:
type foo = [ <
Foo of int ]; (* type foo = [|
Foo of int|] )type foo = [| `Foo of int|]
( ... Warning: use of syntax of variants types deprecated ... *)
Is someone maintaining the Camlp4 (and the revised syntax) so I can submit a
patch?
Chris Dutchyn
The text was updated successfully, but these errors were encountered: