Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在交互式 shell 和(在线)REPL 中我可以输入
:type 1
找出表达式“1”的类型。我可以从代码中使用任何功能来达到相同的效果吗?
目前没有简单的方法可以做到这一点。
然而,REPL 本身是用 Frege 编写的,所以它当然是可能的。
“诀窍”是构建一个完整的程序,比如
module Foo where { x = 1 }
并通过第一个编译器通道运行它,直到并包括类型检查通道。之后,可以在符号表中查询顶级符号x及其类型。
x