Skip to Main content Skip to Navigation
Journal articles

Merlin: a language server for OCaml (experience report)

Frédéric Bour 1 Thomas Réfis 2 Gabriel Scherer 3 
3 PARSIFAL - Proof search and reasoning with logic specifications
LIX - Laboratoire d'informatique de l'École polytechnique [Palaiseau], Inria Saclay - Ile de France
Abstract : We report on the experience of developing Merlin, a language server for the OCaml programming language in development since 2013. Merlin is a daemon that connects to your favourite text editor and provides services that require a fine-grained understanding of the programming language syntax and static semantics: instant feedback on warnings and errors, autocompletion, "type of the code under the cursor", "go to definition", etc. Language servers need to handle incomplete and partially-incorrect programs, and try to be incremental to minimize recomputation after small editing actions. Merlin was built by carefully adapting the existing tools (the OCamllex lexer and Menhir parser generators) to better support incrementality, incompleteness and error handling. These extensions are elegant and general, as demonstrated by the interesting, unplanned uses that the OCaml community found for them. They could be adapted to other frontends-in any language. Besides incrementality, we discuss the way Merlin communicates with editors, describe the design decisions that went into some demanding features and report on some of the non-apparent difficulties in building good editor support, emerging from expressive programming languages or frustrating tooling ecosystems. We expect this experience report to be of interest to authors of interactive language tooling for any programming language; many design choices may be reused, and some hard-won lessons can serve as warnings.
Document type :
Journal articles
Complete list of metadata

Cited literature [10 references]  Display  Hide  Download
Contributor : Scherer Gabriel Connect in order to contact the contributor
Submitted on : Wednesday, November 21, 2018 - 9:01:32 AM
Last modification on : Wednesday, June 8, 2022 - 12:50:07 PM
Long-term archiving on: : Friday, February 22, 2019 - 1:05:00 PM


Files produced by the author(s)



Frédéric Bour, Thomas Réfis, Gabriel Scherer. Merlin: a language server for OCaml (experience report). Proceedings of the ACM on Programming Languages, ACM, 2018, 2 (ICFP), pp.1 - 15. ⟨10.1145/3236798⟩. ⟨hal-01929161⟩



Record views


Files downloads