Skip to content

Latest commit

 

History

History
107 lines (93 loc) · 4.22 KB

File metadata and controls

107 lines (93 loc) · 4.22 KB

Emacs OCaml Integration

A literate programming file for integrating the OCaml programming language.

Introduction

After reading Batsov’s OCaml overview essay, I became intrigued with learning more about it. Like him, I’ll probably start learning OCaml using the following resources:

As these installation instructions state, the primary binary to install is the package manager, like:

brew install opam

Initialize the opam package database by running:

opam init

The book suggests installing utop:

opam install core core_bench utop

The book also mentions that opam comes with a user-setup package to install Emacs configs. You can install it as follows, along with some related packages:

opam install user-setup tuareg ocamlformat merlin
opam user-setup install

But I won’t be doing that, as I can configure it.

Basics

I kicked off this code by following with these instructions from Batsov.

Use the tuareg package for OCaml programming:

(use-package tuareg
  :mode (((rx ".ocamlinit" eos) . tuareg-mode)))

Use dune.el to edit Dune project files:

(use-package dune)

Merlin provides advanced IDE features:

(use-package merlin
  :config
  (add-hook 'tuareg-mode-hook #'merlin-mode)
  ;; we're using flycheck instead
  (setq merlin-error-after-save nil))

(use-package merlin-eldoc
  :hook ((tuareg-mode) . merlin-eldoc-setup))

The flycheck package uses Merlin internally:

(use-package flycheck-ocaml
  :config (flycheck-ocaml-setup))

If I get into utop, I can also setup some integration with it like this:

(use-package utop
  :config
  (add-hook 'tuareg-mode-hook #'utop-minor-mode))

Technical Artifacts

Let’s provide a name so we can require this file: