如何在小块中禁用Haskell警告?

juh*_*ark 23 haskell compiler-warnings ghc

我想禁用警告只有一些代码块.

我搜索了谷歌,但只查找文件范围或全局范围禁用方法.使用cabal文件或pragma

{-# OPTIONS_GHC #-}
Run Code Online (Sandbox Code Playgroud)

我可以禁用特定功能的警告吗?

She*_*rsh 20

不,你现在不能参加GHC 8.6.1.

{-# OPTIONS_GHC #-}pragma仅为文件头,适用于整个模块.并且没有这样的pragma(或其他方式)来抑制特定位置的警告.您可以在Haskell用户指南中查看完整的pragma列表:

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas

警告列表也可能很有趣:

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using-warnings.html