我正在开发一个编译器插件,如果声明没有作为插件参数给出的类型,它应该中止编译。
我认为该功能Unify.tcMatchTy :: Type -> Type -> Maybe TCvSubstS
可以解决问题。我可以从类型检查器插件的输入中找到其中一种参数类型,但另一种作为插件参数出现。也就是说,作为一个String
.
我如何在类型检查器插件中Type
从 a 中获取 a String
?我尝试使用parseType
后跟调用rnHsType
and tcLHsType
,它确实将 a 转换String
为Type
. 这似乎适用于简单类型,但是当字符串包含类型变量时会导致这种错误:
Text:0:0: error: Not in scope: type variable ‘a’
Text:0:0: error:
• GHC internal error: ‘a’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: []
• In the type ‘a -> b’
我可能在这里遗漏了一些(或者可能是一大块)工作,但是我应该在哪里寻找呢?
(在输入前加上 a 会forall a b.
导致编译器恐慌)