I'm a OCaml newbie working with some pretty complex (at least for me) OCaml code I didn't write. It would help a lot to understand it if I could see the inferred types for some of the values, as I can do with F# and Visual Studio by hovering over any value, e.g.:
(screenshot borrowed from http://theburningmonk.com/2010/01/learning-f-part-1/)
I guess I could break down the code and feed it to the toplevel to get the types, but is there any other, simpler way?
First, you must compile your file (foo.ml
) with the -annot
flag. This generates the annotation file (foo.annot
) that contains type information about all identifiers inside. You can include this as part of your makefile or build process.
Then, you need to rely on your IDE to display that information. I do this in Tuareg (the emacs mode) using Ctrl+C, Ctrl+T, which highlights the current expression and displays its type.
OcaIDE which is an O'Caml plug-in for Eclipse displays the inferred types on the fly while editing your code.
Example:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With