简体   繁体   English

如何在Frege中打印表达式的类型

[英]how to print the type of an expression in Frege

In the interactive shell and (online) REPL I can enter 在交互式外壳和(在线)REPL中,我可以输入

:type 1

to find out the type of the expression "1". 找出表达式“ 1”的类型。 Is there any function that I can use from code to achieve the same effect? 我可以从代码中使用任何功能来达到相同的效果吗?

There is no easy way to do this at this time. 目前尚无简便的方法。

However, the REPL is itself written in Frege, so it certainly is possible. 但是,REPL本身是用Frege编写的,因此当然可以。

The "trick" is to construct a complete program, like “技巧”是构建一个完整的程序,例如

module Foo where { x = 1 }

and run it through the first compiler passes, up to and including the type checking pass. 并在第一个编译器遍历(包括类型检查遍历)中运行它。 After that, one could query the symbol table for the top level symbol x and its type. 之后,可以在符号表中查询顶级符号x及其类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM