Skip to content

mplamann/ocaml-semicolon-dwim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocaml-semicolon-dwim

When you want to perform two synchronous computations in sequence, you can write

first_computation ();
second_computation ()

But when these computations return a Deferred.t, there is extra boilerplate:

let%bind () = first_computation () in
second_computation ()

ocaml-semicolon-dwim allows you to type

first_computation ();
second_computation

in both cases. Once you type ;, it asks Merlin the type of first_computation () and inserts the let%bind () = ... in if necessary.

Setup

This mode depends on emacs-tree-sitter and merlin, so make sure those are set up first.

Until emacs-tree-sitter/elisp-tree-sitter#75 is merged, you will need to add a config statement like:

(push '(tuareg-mode . ocaml) tree-sitter-languages)

to make tree-sitter-mode recognize tuareg-mode as a mode for editing ocaml.

This also requires emacs 25 or later, built with dynamic module support.

Install the ocaml dependencies with opam install ecaml, then build the ecaml plugin with dune build. Add the resulting .so file to emacs’s load-path, then add this to your emacs config:

(require 'ecaml_plugin)
(add-hook 'tuareg-mode-hook #'ocaml-semicolon-dwim-mode)

About

Emacs plugin to make it easier to write Async code in Ocaml

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages