Relax Monad constraint in traceM and traceShowM to Applicative
Now that Applicative
is a superclass of Monad
in GHC 7.10, the current type signatures of traceM
and traceShowM
from Debug.Trace
are too constricted:
traceM :: Monad m => String -> m ()
traceM string = trace string $ return ()
traceShowM :: (Show a, Monad m) => a -> m ()
traceShowM = traceM . show
These can be equivalently defined with Applicative
:
traceM :: Applicative m => String -> m ()
traceM string = trace string $ pure ()
traceShowM :: (Show a, Applicative m) => a -> m ()
traceShowM = traceM . show
However, the M
suffixes probably won't make sense after changing the type signatures, so it might be wise to create new traceA
and traceShowA
functions and deprecate traceM
and traceShowM
.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.1-rc1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett, hvr |
Operating system | |
Architecture |