This is your Reason(let.opt
) definition.
let (let.opt) = (x, f) => switch (x) { | None => None | Some(x) => f(x) };let (and.opt) = (a, b) => switch (a, b) { | (Some(a), Some(b)) => Some((a, b)) | _ => None };let z = (a,b)=> { let.opt a = a and.opt b = b; Some(a + b);};
This is your Rescript file onocaml@4.12.0
:
//Demo.resleta=Some(10);letb=Some(3);Js.log2("using ocaml 4.12 compiled reasonml let.opt in Rescript",Opts.z(a,b));
Here is a gist.
Here is a project you can run:
idkjs / letop-rescript
using (let.opt) style in rescript
Resources:https://github.com/ocaml/ocaml/pull/1947
Melange:https://github.com/melange-re/melange
Rescript:https://rescript-lang.org/
Discord:https://discord.gg/KAJBzYaf
Top comments(1)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse