我是一名 OCaml 新手,正在使用一些我没有编写的相当复杂(至少对我来说)的 OCaml 代码。如果我可以看到某些值的推断类型,那么对理解它会有很大帮助,就像我可以通过将鼠标悬停在任何值上来使用 F# 和 Visual Studio 一样,例如:
(截图借自http://theburningmonk.com/2010/01/learning-f-part-1/)
我想我可以分解代码并将其提供给顶层以获取类型,但是还有其他更简单的方法吗?
首先,您必须编译您的文件(foo.ml
)与-annot
旗帜。这会生成注释文件(foo.annot
)包含有关内部所有标识符的类型信息。您可以将其包含在 makefile 或构建过程中。
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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)