Module is inferred to be safe [GHC-58656]

Flag: -Wsafe

GHC implements the SafeHaskell extension which allows programmers to restrict modules to a specific subset which is considered safe and does not contain loopholes such as unsafePerformIO. More details are available in the GHC User’s Guide. The compiler can automatically infer whether a given module is safe or not. GHC can emit a warning if a module is inferred to be safe, but not annotated as safe.

Examples

A module is inferred as safe but not annotated as safe

In this example the module has been inferred to be safe, but not annotated as such. If the module is annotated, the warning disappears.

messages/GHC-58656/inferred-safe/before/InferredSafe.hs:2:17: warning: [GHC-58656] [-Wsafe]
    ‘InferredSafe’ has been inferred as safe!
  |
2 | {-# OPTIONS_GHC -fwarn-safe #-}
  |
InferredSafe.hs
Before
{-# LANGUAGE Haskell2010 #-}
{-# OPTIONS_GHC -Wsafe #-}
module InferredSafe where

theAnswer :: Int
theAnswer = 42
After
{-# LANGUAGE Haskell2010, Safe #-}
{-# OPTIONS_GHC -Wsafe #-}
module InferredSafe where

theAnswer :: Int
theAnswer = 42