Skip to content

Commit

Permalink
io-sim-classes: MonadEventlog
Browse files Browse the repository at this point in the history
Use traceEventIO, traceMarkerIO name (as in base).
  • Loading branch information
coot committed Sep 14, 2020
1 parent 8a9eca6 commit 007a7ae
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions io-sim-classes/src/Control/Monad/Class/MonadEventlog.hs
@@ -1,36 +1,49 @@
module Control.Monad.Class.MonadEventlog (
MonadEventlog(..)
MonadEventlog(..),
-- * Deprecated API
traceEventM,
traceMarkerM
) where

import Control.Monad.Reader
import Debug.Trace (traceEventIO, traceMarkerIO)
import qualified Debug.Trace as IO (traceEventIO, traceMarkerIO)

class Monad m => MonadEventlog m where

-- | Emits a message to the eventlog, if eventlog profiling is available and
-- enabled at runtime.
traceEventM :: String -> m ()
traceEventIO :: String -> m ()

-- | Emits a marker to the eventlog, if eventlog profiling is available and
-- enabled at runtime.
--
-- The 'String' is the name of the marker. The name is just used in the
-- profiling tools to help you keep clear which marker is which.
traceMarkerM :: String -> m ()
traceMarkerIO :: String -> m ()


traceEventM :: MonadEventlog m => String -> m ()
traceEventM = traceEventIO
{-# DEPRECATED traceEventM "Use traceEventIO" #-}


traceMarkerM :: MonadEventlog m => String -> m ()
traceMarkerM = traceMarkerIO
{-# DEPRECATED traceMarkerM "Use traceEventIO" #-}


--
-- Instances for IO
--

instance MonadEventlog IO where
traceEventM = traceEventIO
traceMarkerM = traceMarkerIO
traceEventIO = IO.traceEventIO
traceMarkerIO = IO.traceMarkerIO

--
-- Instance for ReaderT
--

instance MonadEventlog m => MonadEventlog (ReaderT r m) where
traceEventM = lift . traceEventM
traceMarkerM = lift . traceMarkerM
traceEventIO = lift . traceEventIO
traceMarkerIO = lift . traceMarkerIO

0 comments on commit 007a7ae

Please sign in to comment.