Add -Winferred-safe-imports and -Wmissing-safe-haskell-mode warnings
Add -Winferred-safe-imports
warning
We preserve whether module was declared or inferred Safe. When
explicitly-declared-Safe module imports implicitly-inferred-Safe module, we warn.
The inferred status is volatile, often enough it's a happy coincidence, something
which cannot be relied upon. However, explicitly Safe
or Trustworthy
modules won't accidentally become Unsafe
.
(Note: Safe Haskell is not part of PVP; we need tooling first see https://github.com/haskell/pvp/issues/22)
This commit partly reverts e69619e923e84ae61a6bb4357f06862264daa94b
commit by reintroducing Sf_SafeInferred
SafeHaskellMode
.
This patch lacks tests for now, but while working on it, it already catched
for example
https://github.com/haskell/unix/blob/master/System/Posix/Files.hsc (explicitly declared Safe)
importing
https://github.com/haskell/time/blob/master/lib/Data/Time/Clock/POSIX.hs (implicitly inferred Safe).
Issue like that is exactly what I had in mind, when writing this patch: Now I can go and annotate time
modules as Safe
or Trustworthy
making the Safe Haskell part of (more) explicit contract.
I'll add tests if we agree this is good addition, and when we agree on a warning name. I argue that this warning could be added to -Wall
: it will trigger only when author explicitly enables Safe
.