-
Notifications
You must be signed in to change notification settings - Fork 86
/
MonadEventlog.hs
49 lines (36 loc) · 1.23 KB
/
MonadEventlog.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 = traceEventIO
{-# DEPRECATED traceEventM "Use traceEventIO" #-}
traceMarkerM :: MonadEventlog m => String -> m ()
traceMarkerM = traceMarkerIO
{-# DEPRECATED traceMarkerM "Use traceEventIO" #-}
--
-- Instances for IO
--
instance MonadEventlog IO where
traceEventIO = IO.traceEventIO
traceMarkerIO = IO.traceMarkerIO
--
-- Instance for ReaderT
--
instance MonadEventlog m => MonadEventlog (ReaderT r m) where
traceEventIO = lift . traceEventIO
traceMarkerIO = lift . traceMarkerIO