Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Debug.TimeStats.Unsafe
Description
A module with time measuring primitives that might not work in all monads that building allows.
Measures are collected only if the environment variable
DEBUG_TIMESTATS_ENABLE
is set to any value ahead of invoking any function
in this module.
Synopsis
- unsafeMeasureM :: Monad m => String -> m a -> m a
Documentation
unsafeMeasureM :: Monad m => String -> m a -> m a Source #
Like measureM
but can measure other monads.
This function relies on a hack to perform IO in any monad, which does not always work. In particular, we can expect it to miss time in monads where
seq (m >>= \_ -> undefined) () == undefined -- for some computation m
An example of such a monad is the list monad
seq ([()] >>= \_ -> undefined) () == undefined
Another example is the monad Control.Monad.Free.Free f
.
seq (return () >>= \_ -> undefined :: Free IO ()) () == undefined
But it seems to work in monads with state like IO
, ReaderT IO
, and
Control.Monad.State.State s
.
seq (return () >>= \_ -> undefined :: YourMonadHere ()) () == ()