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

Support inline records of OCaml 4.03? #9

Closed
liweijian opened this issue Jun 21, 2016 · 7 comments
Closed

Support inline records of OCaml 4.03? #9

liweijian opened this issue Jun 21, 2016 · 7 comments

Comments

@liweijian
Copy link

I tried to test the example from this post:

utop #
type shape =
  | Circle of { center_x: float;
                center_y: float;
                radius: float;
              }
  | Rect of { x_lo: float;
              y_lo: float;
              x_hi: float;
              y_hi: float;
            }
;;
type shape =
    Circle of { center_x : float; center_y : float; radius : float; }
  | Rect of { x_lo : float; y_lo : float; x_hi : float; y_hi : float; }

It works as expected, but there's error when I add [@@deriving sexp]:

utop #
type shape =
  | Circle of { center_x: float;
                center_y: float;
                radius: float;
              }
  | Rect of { x_lo: float;
              y_lo: float;
              x_hi: float;
              y_hi: float;
            }
[@@deriving sexp]
;;
Error: Error while running external preprocessor
Command line: /Users/liweijian/.opam/4.03.0/lib/ppx_deriving/./ppx_deriving '/var/folders/6m/g2c97rl9517201ffjyspkxlw0000gn/T/camlppxa5e248' '/var/folders/6m/g2c97rl9517201ffjyspkxlw0000gn/T/camlppxc2357d'
@trefis
Copy link
Contributor

trefis commented Jun 21, 2016

Inline records are indeed not supported at the moment.

The 4.03-compatible version of our libraries and tools was meant as "a preview"/"an alpha release": we released it during the beta of the compiler so people could start trying their codebase with the new compiler. In particular the main interest was to work with existing (4.02) code, supporting new features of the language was not required.

We are going to switch to 4.03 internally very soon, at which point we will release new versions of our libraries which will work with 4.03 and should support these new features.

@smolkaj
Copy link

smolkaj commented Jul 15, 2016

+1
Support for inline records would be very much appreciated :)

@ghost
Copy link

ghost commented Jul 15, 2016

It's almost done internally. We are just discussing whether the sexp for A of { x : int; y : int } should be (A (x 1) (y 2)) or (A ((x 1) (y 2)))

@smolkaj
Copy link

smolkaj commented Sep 2, 2016

Any updates on this?

@yminsky
Copy link

yminsky commented Sep 2, 2016

It's already fixed in our bleeding-edge release, which you can access here:

https://github.com/janestreet/opam-repository

@smolkaj
Copy link

smolkaj commented Sep 2, 2016

Great, thanks!

@liweijian
Copy link
Author

I just found that inline records has been supported

type shape =
  | Circle of { center_x: float;
                center_y: float;
                radius: float;
              }
  | Rect of { x_lo: float;
              y_lo: float;
              x_hi: float;
              y_hi: float;
            }
[@@deriving sexp]
;;
type shape =
    Circle of { center_x : float; center_y : float; radius : float; }
  | Rect of { x_lo : float; y_lo : float; x_hi : float; y_hi : float; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants