33

I want to disable warning only some block of code.

I searched Google but only find file scope or global scope disable method. Using cabal file or pragma

{-# OPTIONS_GHC #-}

Can I disable warning for specific function?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
juhyung park
  • 503
  • 4
  • 8

1 Answers1

28

No, you can't currently in GHC 9.2.1.

The {-# OPTIONS_GHC #-} pragma is file-header only and applies to the whole module. And there are no such pragmas (or other ways) to suppress warnings in specific locations. You can check the full list of pragmas in the Haskell user guide:

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

The list of warnings might also be interesting:

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

Shersh
  • 9,019
  • 3
  • 33
  • 61
  • 1
    see also https://gitlab.haskell.org/ghc/ghc/-/issues/602 where this issue is tracked, though there are probably Haskell programmers out there who were born after the issue was opened – Ben Millwood Dec 02 '22 at 17:52