module Control.Monad.Class.MonadEventlog
  ( MonadEventlog (..)
    -- * Deprecated API
  , traceEventM
  , traceMarkerM
  ) where

import           Control.Monad.Reader
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.
  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.
  traceMarkerIO :: String -> m ()


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


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


--
-- Instances for IO
--

instance MonadEventlog IO where
  traceEventIO :: String -> IO ()
traceEventIO = String -> IO ()
IO.traceEventIO
  traceMarkerIO :: String -> IO ()
traceMarkerIO = String -> IO ()
IO.traceMarkerIO

--
-- Instance for ReaderT
--

instance MonadEventlog m => MonadEventlog (ReaderT r m) where
  traceEventIO :: String -> ReaderT r m ()
traceEventIO = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (String -> m ()) -> String -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m ()
forall (m :: * -> *). MonadEventlog m => String -> m ()
traceEventIO
  traceMarkerIO :: String -> ReaderT r m ()
traceMarkerIO = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (String -> m ()) -> String -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m ()
forall (m :: * -> *). MonadEventlog m => String -> m ()
traceMarkerIO