Consider this minimal OCaml program, that defines a functor with two arguments, but then applies it with only the second argument, resulting in a functor-application type error.
module F(K : Map.OrderedType) (V : sig type value end) = struct
module S = Map.Make(K)
type t = V.value S.t
end
module Val = struct type value = string end
module IValMap = F(Val)
Merlin
Using Merlin+Emacs (reproduced under both OCaml 5.3 with Merlin 5.5~503 and OCaml 5.4 with Merlin 5.5~504), I see the following error message in the echo area / minibuffer:
2. Module Val matches the expected module type
This is only the last line of the “real” error message I want to see, and unfortunately it does not help me debug the problem. Note that the *merlin-errors buffer, which stores error messages shown to the user, also has only this line.
Does someone know how to fix Merlin to see the full error message?
ocaml-eglot
I decided to give eglot + ocaml-eglot a try (cc @xvw) to see if it would solve my problem.
At first after installing ocaml-lsp-server and eglot I would see only the first line of the “real” error message, which is
ocamllsp: This application of the functor F is ill-typed.
Also not very useful! But luckily the ocaml-eglot README has documentation about exactly that, how to configure Flymake for multi-line error messages. After following the recommended steps, I now see the following error message:
ocamllsp: This application of the functor F is ill-typed.
These arguments:
Val
do not match these parameters:
(K : Map.OrderedType) (V : ...) -> ...
This is better, but also not the full error message. Does someone know how to fix eglot to see the full error message?
OCaml
Calling the compiler (from the terminal or from Emacs) gives me the full error message:
File "test.ml", line 7, characters 16-22:
7 | module IntSet = F(Val)
^^^^^^
Error: This application of the functor "F" is ill-typed.
These arguments:
Val
do not match these parameters:
(K : Map.OrderedType) (V : ...) -> ...
1. An argument appears to be missing with module type Map.OrderedType
2. Module Val matches the expected module type
The first 3 lines are unnecessary within an editor that already highlights the error location in the source, but the rest is the error message that I want, in full.