[GHC] #10023: Relax Monad constraint in traceM and traceShowM to Applicative

GHC ghc-devs at haskell.org
Mon Jan 26 15:54:24 UTC 2015


#10023: Relax Monad constraint in traceM and traceShowM to Applicative
-------------------------------------+-------------------------------------
              Reporter:              |             Owner:
  RyanGlScott                        |            Status:  new
                  Type:  feature     |         Milestone:
  request                            |           Version:  7.10.1-rc1
              Priority:  normal      |  Operating System:  Unknown/Multiple
             Component:              |   Type of failure:  Other
  libraries/base                     |        Blocked By:
              Keywords:              |   Related Tickets:
          Architecture:              |
  Unknown/Multiple                   |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
 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:

 {{{#!hs
 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}}}:

 {{{#!hs
 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}}}.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10023>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list