ModuleName.(e)
is equivalent to let open ModuleName in e
ModuleName
is opened only for e
[@tailcall]
[@tailcall]
on a function will induce error if the function cannot be made tail recursive.Error will be like this:
Error (warning 51 [wrong-tailcall-expectation]): expected tailcall
#
Unlike Haskell, no such facility is available.
But this should be good enough:
let value1, value2 = ModuleName.(value1, value2)
https://stackoverflow.com/questions/38937520/ocaml-open-only-certain-values-types-from-module
Can work with utop.
M-x run-ocaml
: start tuareg (is an alias for tuareg-run-ocaml
)C-c C-s
: Start utopC-x C-e
/ C-c C-e
: Feed block of current line (or selection) to utopC-c C-t
: Show type of value under cursorhttps://ocamlpro.github.io/ocaml-cheat-sheets/tuareg-mode.pdf
Tuareg: Emacs major mode for OCaml.
Insert template code snippet:
let _ in
if _ then _ else _
match _ with _
An automatic code formatter.
dune integration (needs setup in dune-project):
Dry run: dune build @fmt
Apply: dune promote
Ignore all warnings: dune <command> --profile release
#use "myfile.ml"
https://www.systutorials.com/utop-key-bindings-key-shortcuts/
Links:
Eg:
[@@deriving _]
Meant to supercede an older tool?: ocamldoc
Cross referencing possible
Use comments in the (** ‥ *)
format.
Module docstring: First odoc comment
Type, exception docstrings: odoc comment right before definition (normal comments can be there in between though)
Constructor docstring: On same line
Function docstring: before and after function definition
Stop odoc mode with a 'stop comment': (**/**)
Inlince code: [hello]
List: ul, ol
Alignment: