Skip to content
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

Closed
vicuna opened this issue Apr 22, 2004 · 3 comments
Closed

Revised Syntax for Polymorphic Variants #2494

vicuna opened this issue Apr 22, 2004 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 22, 2004

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

  1. I cannot locate any documentation on how to write polymorphic variants in the
    revised syntax in the 3.07 tutorial or manual.

  2. 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. *)

  3. Unexpectedly, one must have a space between "[" and "<":
    type foo = [<`Foo of int ];
    (* Parse error: [type] expected after '=' (in [type_declaration]) *)

  4. 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

@vicuna
Copy link
Author

vicuna commented Apr 27, 2004

Comment author: administrator

Hello,

Yes, patches are welcome. Send them to caml-bugs@pauillac.inria.fr, as
a reply to this message.

-- Michel

cdutchyn@cs.ubc.ca wrote/écrivait (Thu, Apr 22, 2004 at 09:16:35PM +0200):

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

  1. I cannot locate any documentation on how to write polymorphic variants in the
    revised syntax in the 3.07 tutorial or manual.

  2. 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. *)

  3. Unexpectedly, one must have a space between "[" and "<":
    type foo = [<`Foo of int ];
    (* Parse error: [type] expected after '=' (in [type_declaration]) *)

  4. 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

@vicuna
Copy link
Author

vicuna commented May 25, 2004

Comment author: administrator

Fixed by MM on 2004-05-25

@vicuna vicuna closed this as completed May 25, 2004
@vicuna
Copy link
Author

vicuna commented May 25, 2004

Comment author: administrator

Christopher,

I've fixed most of the bugs you reported. More precisely:

Several problems with revised syntax:
1) there is no documentation on how to write polymorphic variants

Right: this remains to be done.

Briefly, here is the correspondence:

[ Foo of int | Bar of bool ] becomes [= Foo of int | Bar of bool ]

Other constructs ("[<" and "[>") are unchanged.

  1. [ ...]

See the correspondence above.

  1. Unexpectedly, one must have a space between "[" and "<":

Fixed.

  1. The pretty printer for revised syntax outputs the deprecated syntax:

Fixed.

Thanks for reporting this bug.

-- Michel

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant