Warning: I have not tried this ...
You can completely replace the Debug.Trace module with compiler flags. Make another module with trivial function implementations in Debug.Trace :
module NoTrace (trace) where: trace :: String -> a -> a {-# INLINE trace #-} trace _message = id ...
Put this module in another package called no-trace .
Hide the Debug.Trace module in ghc arguments including every module from the base package, except Debug.Trace . Replace Debug.Trace with NoTrace from the no-trace package.
ghc -package="base (Control, Control.Applicative, ..., Data.Word, Foreign, ...)" \ -package="no-trace (NoTrace as Debug.Trace)" \ ...
This was due to the crazy idea of ββusing a compiler flag that modifies the prelude to replace the prelude for those who rewrite the rules in order to remove trace s, but these rewrite rules will damage everything that the module compiled with them imports, even if the downstream importer still wants to use traces. When searching for how to replace the prelude, I found that ghc can replace any module.
source share