OCaml for the impatient - Adam Bard and his magical blog. This is the most up to date setup using Opam, jbuilder, Merlin, VSCode etc.,. August 2017.
See also: opam
emacs
+ utop
+ merlin
+ typerex
= Excellent IDE.
2014-11-25: Run ocamlbrowser
in a shell to see a tk
based documentaiton browser.
OCamlEditor
Fortunately, you can install it using opam install
ocamleditor
… unfortunately you are dealing with various
idiosyncrasis of gtk on mac… ugh.. To keep it short, lablgtk
installation by opam might fail with pkg-config
errors. The fix is:
https://github.com/Homebrew/homebrew/issues/14123#issuecomment-37896791
… before running opam install ocamleditor
. Solution
via
Note: looks butt-ugly on mac, as expected.
opam
allows you create “sandboxes” and install packages in them. See the -A --alias-of
option.
See Setting up an OCaml environment for Programming. Use ocamlfind
, ocamlbuild
and make
.
Apr 2016. See ogen – a tool for creating new OCaml projects with OPAM, Oasis, and Merlin.
Compiling an ocaml file:
That has no dependecies
ocamlopt foo.ml -o foo
that has a dependency (say csv)
ocamlfind ocamlopt -o test -linkpkg -package csv test.ml
ocamlfind
ocamlfind
is a program that finds all the ocaml packages that
are installed on your system (or opam instance, for that matter).ocamlfind -h
to see list of commands available.ocamlfind printconf
shows the path configs etc.,ocamlfind list
will list all the packages installed.ocamldep
typical usage: ocamldep *.ml
, which will dumps dependency lines.
Different file types
.cmo
–.cmi
–.mli
–Ocaml has good study materials – textbooks, lecture notes. There is also the advantage of being able to roll-over to F# for “enterprise” stuff.
-How OCaml Type Checker works. In general Olegs http://okmij.org/ftp/ is a treasure trove of CS material.
- Memory Layout in Ocaml – comment by avsm
- Why OCaml [2002]. Also has many links to OCaml pages. - OCaml programming with
emacs.
- Another Why OCaml
- OCaml briefly – a brief tour of OCaml.
- What is the appeal of OCaml today? Why use it over something like Haskell or Java (reddit); 2018-07-11.
Yaron Minsky:
js_of_ocaml
, TyXML
and React
Build tools:
Some opinions on the merits of using these tools:
What is the preferred way to structure and build OCaml projects?
ocamlbuild
but oasis
may be better now.ocamlbuild
comes with the distribution.oasis
builds myocamlbuild.ml
file automatically for you.oasis
gives you access to oasis-db
, a CPAN like system.ocamlfind
.opam
really doesn’t care about build systems.ocamlbuild
for building Opa lang
.type download_result =
[ `aborted_by_user
| `network_failure of string
| `success of filepath ]
esumii/min-caml: a complete optimizing native-code compiler for a reasonably usable subset of OCaml, in 2000 lines of OCaml. Paper.
PSA: Tired of inscrutable type errors from OCaml? If you use jbuilder/dune, just add this to your jbuild build stanza:
(flags (:standard -short-paths))
and your type errors and inferred types from Merlin will magically improve!