OCaml: Difference between revisions

imported>Vbgl
A few words about OCaml
 
imported>Mic92
fix markup
Line 3: Line 3:
== Findlib, ocamlfind ==
== Findlib, ocamlfind ==


OCaml libraries are usually located using [[http://projects.camlcity.org/projects/findlib.html findlib]] and the associated '''ocamlfind''' tool. These tools are found under the '''ocamlPackages.findlib''' attribute and rely on the '''OCAMLPATH''' environment variable.
OCaml libraries are usually located using [http://projects.camlcity.org/projects/findlib.html findlib] and the associated '''ocamlfind''' tool. These tools are found under the '''ocamlPackages.findlib''' attribute and rely on the '''OCAMLPATH''' environment variable.


A hook in the '''findlib''' package will automatically populate this variable with the paths to the other libraries. For instance, when starting a shell with
A hook in the '''findlib''' package will automatically populate this variable with the paths to the other libraries. For instance, when starting a shell with
Line 13: Line 13:
== Using Emacs ==
== Using Emacs ==


[[https://github.com/ocaml/tuareg Tuareg]] is an Emacs OCaml mode. It can be installed with
[https://github.com/ocaml/tuareg Tuareg] is an Emacs OCaml mode. It can be installed with
<code>nix-env -iA nixpkgs.emacsPackagesNg.tuareg</code>.
<code>nix-env -iA nixpkgs.emacsPackagesNg.tuareg</code>.


Line 20: Line 20:
   (add-to-list 'package-directory-list "~/.nix-profile/share/emacs/site-lisp/elpa")
   (add-to-list 'package-directory-list "~/.nix-profile/share/emacs/site-lisp/elpa")


There is some more documentation in the [[https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/emacs-packages.nix nixpkgs sources]].
There is some more documentation in the [https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/emacs-packages.nix nixpkgs sources].


[[https://github.com/ocaml/merlin Merlin]] provides additional functionality to Emacs. It can be installed through <code>nix-env -iA nixpkgs.ocamlPackages.merlin</code>.
[https://github.com/ocaml/merlin Merlin] provides additional functionality to Emacs. It can be installed through <code>nix-env -iA nixpkgs.ocamlPackages.merlin</code>.


Beware that merlin is specific to one particular version of OCaml (it won’t work correctly with a compiler of a different version).
Beware that merlin is specific to one particular version of OCaml (it won’t work correctly with a compiler of a different version).
Line 38: Line 38:
   )
   )


A useful complement to merlin is [[https://www.typerex.org/ocp-indent.html '''ocp-indent''']], a customizable tool to indent OCaml code. It can be installed using <code>nix-env -iA nixpkgs.ocamlPackages.ocpIndent</code>. To enable it in Emacs, don’t forget to add the following line to your '''.emacs''':
A useful complement to merlin is [https://www.typerex.org/ocp-indent.html '''ocp-indent'''], a customizable tool to indent OCaml code. It can be installed using <code>nix-env -iA nixpkgs.ocamlPackages.ocpIndent</code>. To enable it in Emacs, don’t forget to add the following line to your '''.emacs''':


   (require 'ocp-indent)
   (require 'ocp-indent)