Skip to content

Instantly share code, notes, and snippets.

@idkjs
Created July 11, 2021 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idkjs/ad33256480e20600222ae6a57efb46ee to your computer and use it in GitHub Desktop.
Save idkjs/ad33256480e20600222ae6a57efb46ee to your computer and use it in GitHub Desktop.
Rescript + Reason + OCaml@4.12.0 for `let.opts` in Rescript
let a = Some(10);
let b = Some(3);
Js.log2("using ocaml 4.12 compiled reasonml let.opt in Rescript", Opts.z(a,b));
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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment