Skip to content

nickforce/OCaml_helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://ocaml.org/install

bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"

[/usr/local/bin] -> opam package manager install path

opam init

update paths in ~/.zshrc update current shell env

eval $(opam env --switch=default)

Setup OCaml Development Environment

opam install dune merlin ocaml-lsp-server odoc ocamlformat utop dune-release

Link Merlin with editor

opam user-setup install

Using the REPL

utop

Exit the REPL

exit 0;;

Starting a new project

dune init project helloworld

All the metadata of your project is available in the file dune-project. Edit it to match your specific project.

We can build our program with dune build, which creates an executable file:

dune build

To run the program, we can use:

dune exec ./bin/main.exe

Or alternatively

dune exec helloworld

Configure OCamlFormat to format your code

echo "version = `ocamlformat --version`" > .ocamlformat

In addition to the editor, Dune is also able to drive OCamlFormat. Running this command will automatically format all files from your codebase:

dune fmt

Generate documentation with odoc

odoc is a tool that is not meant to be used by hand, just as compilers are not meant to be run manually in complex projects. Dune can drive odoc to generate documentation in the form of HTML, LaTeX, or man pages, from the docstrings and interface of the project's modules.

The following command will generate the documentation as HTML:

dune build @doc

# Unix or macOS
open _build/default/_doc/_html/index.html

Resources

About

OCaml_helloworld

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages