OCaml By Examples

Language Basics

Project Management

  • dune
  • dune-release
  • opam pin

Advanced Ocaml

  • functors
  • monads

Libraries

Calling C programs

console

https://opam.ocaml.org/packages/ctypes/
$ opam install ctypes ctypes-foreign

main.ml

...
let sigemptyset = foreign "sigemptyset" (ptr sigset_t @-> returning int)
let sigfillset = foreign "sigfillset" (ptr sigset_t @-> returning int)
let sigaddset = foreign "sigaddset" (ptr sigset_t @-> int @-> returning int)
let sigdelset = foreign "sigdelset" (ptr sigset_t @-> int @-> returning int)
let sigismember = foreign "sigismember" (ptr sigset_t @-> int @-> returning int)
next: Compiling to javascript