3

Menhir allows to add arbitrary ocaml code to the end of the .mly file, where I want to declare a few functions. But I could not find a way to make menhir add my functions to the .mli file, so that they are visible from the other modules. Is it possible?

Alexey B.
  • 1,106
  • 8
  • 17

1 Answers1

2

The answer is simple, it's no. The code defined in the .mly file is only used by the parser.

As stated in the manual :

A header is a piece of OCaml code, surrounded with %{ and %} . It is copied verbatim at the beginning of the .ml file.

Lhooq
  • 4,281
  • 1
  • 18
  • 37
  • They also allow trailing code that goes in the end of the .ml file. One could think that it is a good place to put some helper functions for the client code, but apparently no luck here. – Alexey B. Nov 10 '16 at 13:39