Closed liweijian closed 7 years ago
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.
+1 Support for inline records would be very much appreciated :)
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)))
Any updates on this?
It's already fixed in our bleeding-edge release, which you can access here:
Great, thanks!
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; }
I tried to test the example from this post:
It works as expected, but there's error when I add
[@@deriving sexp]
: