简体   繁体   中英

how to print the type of an expression in Frege

In the interactive shell and (online) REPL I can enter

:type 1

to find out the type of the expression "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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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