최신 Reason/OCaml과 함께 Rescript에서 `let.opt` 사용

이것은 이유(let.opt ) 정의입니다.

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);
};

이것은 [email protected]의 Rescript 파일입니다.

//Demo.res
let a = Some(10);
let b = Some(3);

Js.log2("using ocaml 4.12 compiled reasonml let.opt in Rescript", Opts.z(a,b));

여기 요점이 있습니다.




실행할 수 있는 프로젝트는 다음과 같습니다.



<사업부 클래스="readme-개요">

idkjs / letop-rescript


rescript에서 (let.opt) 스타일 사용





자원: https://github.com/ocaml/ocaml/pull/1947

멜란지: https://github.com/melange-re/melange

Rescript: https://rescript-lang.org/

디스코드: https://discord.gg/KAJBzYaf

좋은 웹페이지 즐겨찾기