-- Copyright 2020 Evan Laforge
-- This program is distributed under the terms of the GNU General Public
-- License 3.0, see COPYING or http://www.gnu.org/licenses/gpl-3.0.txt

-- | Utils for trace-oriented logging.
module Util.Trace where
import qualified Control.DeepSeq as DeepSeq
import qualified Control.Exception as Exception
import qualified Debug.Trace as Trace
import Global


force :: (MonadIO m, DeepSeq.NFData a) => a -> m ()
force :: forall (m :: * -> *) a. (MonadIO m, NFData a) => a -> m ()
force = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> IO a
Exception.evaluate forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NFData a => a -> ()
DeepSeq.rnf
{-# INLINABLE force #-}

-- | Write a trace entry.  This goes in the eventlog, and can be read by
-- threadscope or chrome, after App.ConvertEventLog
trace :: MonadIO m => String -> m ()
trace :: forall (m :: * -> *). MonadIO m => String -> m ()
trace = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ()
Trace.traceMarkerIO
{-# INLINABLE trace #-}