OCaml: Difference between revisions
imported>Vbgl m fix markup |
m put languages on the bottom of the page |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 10: | Line 10: | ||
This hook also sets the '''CAML_LD_LIBRARY_PATH''' environment variable that is used for locating the dynamically loaded shared libraries (aka stublibs). | This hook also sets the '''CAML_LD_LIBRARY_PATH''' environment variable that is used for locating the dynamically loaded shared libraries (aka stublibs). | ||
== Scripting with OCaml == | |||
OCaml can be used in nix-shell scripts as follows: | |||
<syntaxHighlight lang=ocaml> | |||
#!/usr/bin/env nix-shell | |||
(* | |||
#!nix-shell --pure -i ocaml -p ocaml | |||
*) | |||
print_string "Hello world! 🚀 \n";; | |||
</syntaxHighlight> | |||
== Using Emacs == | == Using Emacs == | ||
| Line 53: | Line 64: | ||
Various versions of the '''ocamlPackage''' attribute set are available, corresponding to various versions of OCaml. For instance, the attribute set '''ocaml-ng.ocamlPackages_4_04''' contains the OCaml compiler at version 4.04 and OCaml libraries compiled with that particular compiler. | Various versions of the '''ocamlPackage''' attribute set are available, corresponding to various versions of OCaml. For instance, the attribute set '''ocaml-ng.ocamlPackages_4_04''' contains the OCaml compiler at version 4.04 and OCaml libraries compiled with that particular compiler. | ||
=== Custom version === | |||
So as to get the set of OCaml libraries built with/for a custom version of the OCaml compiler, e.g., to enable '''flambda''' support, you may use the '''ocamlPackages.overrideScope''' function: | |||
<syntaxHighlight lang=nix> | |||
ocamlPackagesFlambda = ocamlPackages.overrideScope (self: super: { | |||
ocaml = super.ocaml.override { flambdaSupport = true; }; | |||
}); | |||
</syntaxHighlight> | |||
More details: https://github.com/NixOS/nixpkgs/pull/53357#issuecomment-451727433 | |||
[[Category:Languages]] | |||