If you are a student that wants to know how to setup your environment
to practice your OCaml skills with Learn-OCaml, this tutorial is for
you. There are two ways to use the Learn-OCaml system: in web
application, directly on the browser (hence, wit zero
configuration) ; or with a command line tool named
Your teacher must have provided an URL for the Learn-OCaml instance used in your OCaml course. Then, to start using the platform:
Open a browser on this URL.
Fill the nickname to be identifiable by your teacher.
Create a token.
Click on the exercise button. At this point, you should see a list of exercises.
Select the exercise you want to work on.
Read the exercise statement and use the text editor to complete the source code.
Once you think you have a valid solution for the exercise, click on the “Grade” button. This will automatically check if your answer is indeed correct and save it on the server.
Important note: Write down your token! This is the information that will allow you to recover your session from another machine.
As an experienced programmer, you probably want to use your favorite
editor (Emacs, Vim, Atom, VSCode, etc) to program in OCaml. This is
possible thanks to our command line tool named
Yet, it requires more efforts in terms of setup. Maybe your teacher
learn-ocaml-client on the computer lab machines.
There are two methods to install
If you are already using the OCaml package manager OPAM, simply do:
opam install learn-ocaml
Note: you need a working
opam environment (at least
git clone firstname.lastname@example.org:ocaml-sf/learn-ocaml.git && cd learn-ocaml
opam install opam-installer && eval $(opam env) && make build-deps
make && make opaminstall
The first time you run
learn-ocaml-client, you will be asked for the
URL of the Learn-OCaml instance you want to use and you will also be
asked to enter your nickname and your token.
Once this is done, this information is stored in the file
~/.config/learnocaml/client.json so that you do not have to enter it
anymore. If you want to change this configuration, remove this file and
the client will recreate it the next time it is launched.
learn-ocaml-client allows you to submit the content of a file as an
answer to an exercise of the Learn-OCaml instance. This answer will be
graded and saved onto the server, exactly as in the web application.
The first thing to do is to get the identifier of the exercise you want to work on. This identifier is written on the webpage of the server.
The, let us assume that the exercise identifier is
that you have written an answer in the file named
can submit your answer from the command line by:
learn-ocaml-client --id=exercise1 myanswer.ml
As a response, you will obtain a grading report of the following form: