Merlin/OCamllsp inferred type when polymorphic type is already known

Let’s say we have the OCaml expression:

Logs.Tag.def "some_logging_tag" Stdint.Uint32.printer

Let’s say we hover over def, merlin tells us the type of def is

?doc:string -> string -> (Format.formatter -> 'a -> unit) -> 'a Logs.Tag.def

However, merlin should be able to do better. Given the we are passing Stdint.Uint32.printer (whose type is Format.formatter -> Stdint.Uint32 -> unit ), the inferred type of Logs.Tag.def more specifically is:

?doc:string -> string -> (Format.formatter -> Stdint.Uint32 -> unit) -> Stdint.Uint32 Logs.Tag.def

While this example is simple (and you can do this in your head), this can be very useful when there are a lot of polymorphic variables.

The Haskell language server does this. It gives you both the type with polymorphic variables and the “actual” type based on usage in code. It can be very useful, specially when types become complex.

Is this planned for Merlin? Does this feature already exist perhaps?

1 Like

@vd – Sorry for the ping but there is a high chance you might know the answer to this question :slight_smile: . Thanks!