---
title: "[OCaml](https://en.wikipedia.org/wiki/OCaml)"
weight: 1
---

- <https://ocaml.org>
- <https://github.com/ocaml/ocaml>
- <https://github.com/rizo/awesome-ocaml>

## Version Compatibility

Here concerned only with source-code compatibility between major releases of the OCaml compiler, not with other enhancements that may be provided by newer releases.

- 4.01 in comparison to 4.02+:
  - There is no `Bytes` module. Workaround: `module Bytes = String`.
  - There is no `bytes` type. Workaround: `type bytes = string` or use `Bytes.t`.
  - [Module aliases](https://blogs.janestreet.com/better-namespaces-through-module-aliases/) don't work in interface files.
  - [Catching exceptions directly in match clauses](https://blogs.janestreet.com/pattern-matching-and-exception-handling-unite/) is not supported.

## Reference

- <http://roscidus.com/blog/blog/2013/12/20/polymorphism-for-beginners/>

## Problems

### Downcasting Objects

- <http://comments.gmane.org/gmane.comp.lang.ocaml.beginners/769>
- <https://groups.google.com/forum/#!msg/comp.lang.ml/ufGfsz0_9oQ/dMtCONswLmwJ>
- <http://caml.inria.fr/pub/ml-archives/caml-list/2002/05/a6520926c4eac029206a31d6aa22f967.fr.html>

## Interactive

```text
$ utop
```

## Performance

- <http://www.ffconsultancy.com/languages/ray_tracer/comparison.html>
- <https://ocaml.org/learn/tutorials/performance_and_profiling.html>

## Installation

### macOS with Homebrew

- `brew install ocaml --with-flambda`
- `brew install opam`
- `opam init`
- `opam switch 4.02.3`

### Ubuntu 14.04

- `sudo apt-add-repository ppa:avsm/ppa`
- `sudo aptitude update`
- `sudo aptitude install ocaml-nox opam`
- `opam init`
- `` eval `opam config env ``\`
- `opam switch 4.02.3`
- `` eval `opam config env ``\`

## Packages

- `opam install core`
- `opam install utop`
- `opam install ocp-indent`
- `opam install async`
- `opam install yojson`
- `opam install core_extended`
- `opam install core_bench`
- `opam install cohttp`
- `opam install async_graphics`
- `opam install cryptokit`
- `opam install menhir`
- `opam install ctypes ctypes-foreign`
- `opam install cmdliner`
- `opam install gg`

## Notes

- <https://janestreet.github.io/ocaml-perf-notes.html>

## Books

- [Real World OCaml](https://realworldocaml.org/v1/en/html/index.html) by Yaron Minsky, Anil Madhavapeddy, and Jason Hickey \[2013\] ([examples](https://github.com/realworldocaml/examples))

## Tutorials

- <https://ocaml.org/learn/tutorials/>
- <http://learnxinyminutes.com/docs/ocaml/>
- <http://try.ocamlpro.com/> <https://github.com/OCamlPro/tryocaml>
- <https://github.com/caiorss/Functional-Programming/blob/master/ocaml/README.md>

## References

- [OCaml at Rosetta Code](http://rosettacode.org/wiki/Category:OCaml)

## Mailing Lists

- <http://lists.ocaml.org/listinfo>

## Interop with C++

- <http://lists.xenproject.org/archives/html/mirageos-devel/2014-05/msg00062.html>
- <https://github.com/ocamllabs/ocaml-ctypes/issues/187>
- <http://blog.shaynefletcher.org/2014/02/extending-ocaml-in-c-boostdate-time.html>
- <http://l-lang.org/blog/Incorporating-C-code-in-an-Ocaml-project-using-Ocamlbuild/>

## See Also

- [ATS](ats)
- [CakeML](cakeml)
- [Standard ML](sml)
