Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an implementation of the let* operator included with OCaml?

Tags:

monads

ocaml

So called "let operators" are now supported in OCaml, however I was wondering if a default implementation of let* and and*, for monads, are shipped with the standard library in a module somewhere?

like image 240
ᅙᄉᅙ Avatar asked Sep 06 '25 03:09

ᅙᄉᅙ


1 Answers

They are not defined directly, but you can "import" them as:

let (let*) = Option.bind

let editor_home =
  let* home = Sys.getenv_opt "HOME" in 
  let* editor = Sys.getenv_opt "EDITOR" in 
  Some (editor ^ " " ^ home)
like image 50
Vladimir Keleshev Avatar answered Sep 07 '25 21:09

Vladimir Keleshev