关闭 AutoDeriveTypeable

Turning off AutoDeriveTypeable

最新版本的 GHC 自动为所有数据类型派生 Typeable 个实例。我想把它关掉。以前,AutoDeriveTypeable 语言扩展用于启用此功能,所以我想如果我使用 NoAutoDeriveTypeable 语言编译指示,就可以解决问题。然而,即使 GHC 没有发出关于未知语言编译指示的错误,NoAutoDeriveTypeable 似乎没有任何影响,因为我可以在生成的核心中看到与 Typeable 相关的 CAF。

There is a DynFlag for this, and turns out it can be turned on with the -dno-typeable-binds compile-time flag。根据文档,此标志仅用于调试目的:

-dno-typeable-binds

This avoid generating Typeable-related bindings for modules and types. This is useful when debugging because it gives smaller modules and dumps, but the compiler will panic if you try to use Typeable instances of things that you built with this flag.