Wiki
Clone wikihelium / popl20 / Tutorial_Install
Tutorial 0: Compile and run
Requirements and installation
To install the interpreter, you will need:
- Ocaml 4.07.1 or higher
- OCamlbuild
If your system does not come with the latest OCaml compiler, try installing Opam and then using Opam to install the right version of the OCaml compiler.
To install Helium, download the sources, go the main directory, and run make
.
Interpreter (interactive mode)
After the installation, you can run the REPL (that is, the interpreter in the interactive mode). Stay in the main Helium directory, and run the helium executable in the bin directory:
$ bin/helium
[IO,RE]>
Now, let's compute something. Type in 2+3;;
. You will see this:
[IO,RE]> 2+3;; 5 : Int
2+3
is the expression, while ;;
terminates the expression passed to the REPL. The system answers with the value of the expression and its type.
Loading a file
To load a source file, type in the following code and save it under the name Map.he
let rec map f xs = match xs with | [] => [] | x :: xs' => f x :: map f xs' end
[IO,RE]> import Map;; [IO,RE]> open Map;; [IO,RE]> map;; <func> : ('c ->['b] 'a) ->['b] List 'c ->['b] List 'a
Interpreting a file
You can also interpret a file. Just pass its name as an argument to the interpreter. For example, add the following line to Map.he
:
let _ = map printInt [1,2,3]
$ bin/helium Map.he 1 2 3
Updated