Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:20
Show Gist options
  • Select an option

  • Save dacr/d6eca4121126aad677024f3280ab13f1 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/d6eca4121126aad677024f3280ab13f1 to your computer and use it in GitHub Desktop.
ocaml cheat sheet / published by https://github.com/dacr/code-examples-manager #c0e2dcaf-f992-4b0a-b0bd-551a7734ee3b/606747b38faec51cf68ca8915e7b46a6714baaed

OCAML

getting started

OCAML install

sudo apt-get install opam
opam init

eval $(opam env)
which ocaml
ocaml --version

opam switch list-available
opam switch create 4.14.0
eval $(opam env)
which ocaml
ocaml --version

REPL & SCRIPTING

opam install utop
utop

A script named : hello.ml

#!/usr/bin/env utop
(* simple example script *)
let x= 42;;
Printf.printf "the response is %d " x ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment