让GHC只进行类型检查? [英] Make GHC only type-check?

查看:94
本文介绍了让GHC只进行类型检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,无论是标准的,还是一种巧妙的破解方法,只要运行类型检查器就可以在文件上调用GHC?例如

Is there a way, either standard, or a clever hack, to make invoking GHC on a file only run the type-checker? E.g.

$ ghc --just-check-the-types x.hs
$

没有输出文件,没有.hi或.o等等。不想/不能使用GHC API。

No output files, no .hi or .o, etc. Don't want to/can't use the GHC API. Just talking about the command-line program, here.

推荐答案

那么 ghc -fno-code file名为.hs 。它不会产生任何其他文件,并且如果你的文件没有被检测到会显示错误。

What about ghc -fno-code file.hs. It will generate no other files and will show errors if your files don't typecheck.

警告:这将不是详尽的模式匹配,所以如果你想要那些额外的有用的警告,不要单独使用这个选项。

Caveat: this will not do analysis on in-exhaustive pattern matches, so if you want those additional useful warnings, don't use this option alone.

这篇关于让GHC只进行类型检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆