skip to main content
research-article
Open Access

Merlin: a language server for OCaml (experience report)

Published:30 July 2018Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

a103-bour.webm

webm

76.8 MB

References

  1. Lukas Diekmann and Laurence Tratt. 2014. Eco: A language composition editor. In Software Language Engineering (SLE).Google ScholarGoogle Scholar
  2. Matthew Flatt, Eli Barzilay, and Robert Bruce Findler. 2009. Scribble: closing the book on ad hoc documentation tools. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Nicolas Jeannerod, Yann Régis-Gianas, and Ralf Treinen. 2017. Having Fun With 31.521 Shell Scripts. (April 2017). https://hal.archives-ouvertes.fr/hal-01513750 .Google ScholarGoogle Scholar
  4. Clinton L. Jeffery. 2003. Generating LR Syntax Error Messages from Examples. TOPLAS 25, 5 (Sept. 2003), 631–640. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Cyrus Omar, Ian Voysey, Michael Hilton, Joshua Sunshine, Claire Le Goues, Jonathan Aldrich, and Matthew A. Hammer. 2017. Toward Semantic Foundations for Program Editors. In SNAPL.Google ScholarGoogle Scholar
  6. François Pottier. 2016. Reachability and error diagnosis in LR(1) parsers. In Proceedings of the 25th International Conference on Compiler Construction (CC 2016). 88–98. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. François Pottier and Yann Régis-Gianas. 2006. Towards efficient, typed LR parsers. In ACM Workshop on ML (Electronic Notes in Theoretical Computer Science), Vol. 148. 155–180. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Tim A. Wagner. 1998. Practical Algorithms for Incremental Software Development Environments. Ph.D. Dissertation. Berkeley. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Tim A. Wagner and Susan L. Graham. 1997. History-Sensitive Error Recover. IEEE Trans. on Software Engineering (1997).Google ScholarGoogle Scholar
  10. Tim A. Wagner and Susan L. Graham. 1998. Efficient and Flexible Incremental Parsing. ACM Trans. on Programming Languages and Systems 20, 5 (1998). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Merlin: a language server for OCaml (experience report)

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader