DEV Community

Andrey Frolov
Andrey Frolov

Posted on

First steps - installation of Ocaml

Installation of package manager

brew install gpatch
brew install opam
Enter fullscreen mode Exit fullscreen mode

Installation of Ocaml

# environment setup
opam init
# put the shel in the right step
eval $(opam env)
# install given version of the compiler
opam switch create 4.12.0
eval $(opam env)
# check you got what you want
which ocaml
ocaml -version
Enter fullscreen mode Exit fullscreen mode

So now you can start a repl and play around it

ocaml
Enter fullscreen mode Exit fullscreen mode
let rec fib n =
    if n < 2 then n else fib (n - 1) + fib (n - 2);;
Enter fullscreen mode Exit fullscreen mode

How to solve problems with opam?

On Linux and macOS, this will be the ~/.opam directory, which means you don't need administrative privileges to configure it. If you run into problems configuring opam, just delete the whole ~/.opam directory and start over.

Top comments (0)