-
-
Notifications
You must be signed in to change notification settings - Fork 46
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 mel.as
in mel.obj
#834
Conversation
This seems to already have been supported, e.g.: melange/jscomp/test/external_ppx.ml Lines 20 to 26 in c5bf086
There seems to be 2 use cases for 1. the current use case, e.g.:external ff : hi:int -> lo:(_[@mel.as 1]) -> _ = "" [@@mel.obj]
let u = ff ~hi:4 generates: // Generated by Melange
'use strict';
var u = {
hi: 4,
lo: 1
};
exports.u = u;
/* No side effect */ 2. your proposed use caseexternal func : foo:(string [@mel.as "bar"]) -> ... generating DiscussionA few ways I see forward:
|
Another option is to change the positioning of the attribute. I chose to annotate the type of the labelled argument because it's imo more ergonomic, but should we annotate the whole arrow type instead? e.g. external ff :
((hi:int -> ((lo:string -> _)[@mel.as "low"]))[@mel.as "high"]) = ""
[@@mel.obj ] instead of external ff : hi:(int[@mel.as "high"]) -> lo:(string[@mel.as "low"]) -> _ = ""
[@@mel.obj] The first option looks way more readable in Reason syntax than in OCaml syntax: [@mel.obj]
external ff:
[@mel.as "high"] ((~hi: int) => [@mel.as "low"] ((~lo: string) => _)); |
I'd rather keep it on the type, then. even in reason that feels very very weird to write. |
@jchavarri given your recent constraints around React 18, would you like me to finish this PR? |
Yes, I'd appreciate it. Thanks! |
441d284
to
c8341fe
Compare
5dae184
to
cc8a649
Compare
cc82ed7
to
95fdf04
Compare
This was never supported so when having to introduce different identifiers on JS, we would have to resort back to
deriving abstract
, e.g. for the DOM props in reason-react.There would be no need to use
deriving abstract
ifmel.as
was supported inmel.obj
which is what this PR allows.