@@ -17,6 +17,10 @@ import Prelude.Kore
1717import Control.Monad
1818 ( when
1919 )
20+ import Control.Monad.Catch.Pure
21+ ( CatchT
22+ , mapCatchT
23+ )
2024import Control.Monad.Morph
2125 ( MFunctor (.. )
2226 )
@@ -25,8 +29,8 @@ import Control.Monad.Reader
2529 )
2630import qualified Control.Monad.State.Strict as Strict
2731import Control.Monad.Trans.Accum
28- ( AccumT ( AccumT )
29- , runAccumT
32+ ( AccumT
33+ , mapAccumT
3034 )
3135import Control.Monad.Trans.Except
3236 ( ExceptT
@@ -55,12 +59,10 @@ import System.Clock
5559import Control.Monad.Counter
5660import ListT
5761 ( ListT (.. )
58- )
59- import qualified ListT
60- ( mapListT
62+ , mapListT
6163 )
6264
63- {- Monad that can also handle profiling events.
65+ {- | Monad that can also handle profiling events.
6466-}
6567class Monad profiler => MonadProfiler profiler where
6668 profile
@@ -257,24 +259,27 @@ profileGhcEventsAnalyze event action = do
257259 liftIO $ traceEventIO (" STOP " ++ List. intercalate " /" event)
258260 return a
259261
260- instance (MonadProfiler m ) => MonadProfiler (ReaderT thing m )
261-
262- instance MonadProfiler m => MonadProfiler (Strict. StateT s m )
262+ instance (MonadProfiler m , Monoid w ) => MonadProfiler (AccumT w m )
263+ where
264+ profile a = mapAccumT (profile a)
265+ {-# INLINE profile #-}
263266
264- instance MonadProfiler m => MonadProfiler (MaybeT m )
267+ instance MonadProfiler m => MonadProfiler (CatchT m ) where
268+ profile a = mapCatchT (profile a)
269+ {-# INLINE profile #-}
265270
266- instance MonadProfiler m => MonadProfiler (IdentityT m )
271+ instance MonadProfiler m => MonadProfiler (CounterT m )
267272
268273instance MonadProfiler m => MonadProfiler (ExceptT e m )
269274
275+ instance MonadProfiler m => MonadProfiler (IdentityT m )
276+
270277instance MonadProfiler m => MonadProfiler (ListT m ) where
271- profile a action =
272- ListT. mapListT (profile a) action
278+ profile a = mapListT (profile a)
273279 {-# INLINE profile #-}
274280
275- instance (MonadProfiler m , Monoid w ) => MonadProfiler (AccumT w m )
276- where
277- profile a action = AccumT (profile a . runAccumT action)
278- {-# INLINE profile #-}
281+ instance MonadProfiler m => MonadProfiler (MaybeT m )
279282
280- instance MonadProfiler m => MonadProfiler (CounterT m )
283+ instance MonadProfiler m => MonadProfiler (ReaderT thing m )
284+
285+ instance MonadProfiler m => MonadProfiler (Strict. StateT s m )
0 commit comments