Protocol for OCaml IDE integration. Web sites: OCaml.org is the primary site for the language. discuss.ocaml.org is an instance of Discourse that serves as the primary discussion site for OCaml. watch.ocaml.org is an instance of PeerTube that hosts videos about OCaml topics. Alternate compilers for OCaml: js_of_ocaml, developed by the Ocsigen team, is an optimizing compiler from OCaml to JavaScript. BuckleScript, which also targets JavaScript, with a focus on producing readable, idiomatic JavaScript output. ocamlcc is a compiler from OCaml to C, to complement the native code compiler for unsupported platforms. OCamlJava, developed by INRIA, is a compiler from OCaml to the Java virtual machine (JVM). OCaPic, developed by Lip6, is an OCaml compiler for PIC microcontrollers. Code examples Snippets of OCaml code are most easily studied by entering them into the top-level REPL. This is an interactive OCaml session that prints the inferred types of resulting or defined expressions. The OCaml top-level is started by simply executing the OCaml program: $ ocaml Objective Caml version 3.09.0 # Code can then be entered at the "#" prompt. For example, to calculate 1+2*3: # 1 + 2 * 3;; - : int = 7 OCaml infers the type of the expression to be "int" (a machine-precision integer) and gives the result "7". Hello World The following program "hello.ml": print_endline "Hello World!" can be compiled into a bytecode executable: $ ocamlc hello.ml -o hello or compiled into an optimized native-code executable: $ ocamlopt hello.ml -o hello and executed: $ ./hello Hello World! $ The first argument to ocamlc, "hello.ml", specifies the source file to compile and the "-o hello" flag specifies the output file. Option The option type constructor in OCaml, similar to the Maybe type in Haskell, augments a given data type to either return Some value of the given data type, or to return None. This is used to express that a value might or might not be present.# Some 42;; - : int option = Some 42 # None;; - : 'a option = NoneThis is an example of a function that either extracts an int from an option, if there is one inside, and converts it into a string, or if not, returns an empty string:let extract o = match o with | Some i -> string_of_int i | None -> "";;# extract (Some 42);; - : string = "42" # extract None;; - : string = ""