Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCaml Syntax: what does >>= mean?

Tags:

ocaml

in this piece of code:

let rec write_from_exactly out s offs len =
    Lwt_unix.write out s offs len >>= fun n ->
       if   n = len then Lwt.return ()
       else write_from_exactly out s (offs + n) (len - n)
in ...

Although I can more or less guess what it does, I couldn't find any official definition on what ">>=" means and how it works.


1 Answers

The symbol >>= is defined by Lwt, not by OCaml itself. It's an infix operator equivalent to bind. You can see the definition of bind in Lwt's documentation.

like image 107
Jeffrey Scofield Avatar answered Sep 19 '25 06:09

Jeffrey Scofield