Skip to content

Commit 611f62e

Browse files
committed
io-sim: ppDebug helper function
1 parent 1c036f9 commit 611f62e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

io-sim/src/Control/Monad/IOSim.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module Control.Monad.IOSim
3939
, ppTrace_
4040
, ppEvents
4141
, ppSimEvent
42+
, ppDebug
4243
-- ** Selectors
4344
, traceEvents
4445
, traceResult

io-sim/src/Control/Monad/IOSim/Types.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module Control.Monad.IOSim.Types
5858
, ppTrace
5959
, ppTrace_
6060
, ppSimEvent
61+
, ppDebug
6162
, TraceEvent
6263
, Labelled (..)
6364

@@ -624,6 +625,14 @@ ppTrace_ tr = Trace.ppTrace
624625
(ppSimEvent (bimaximum (bimap (const 0) (maybe 0 length . seThreadLabel') tr)))
625626
tr
626627

628+
-- | Trace each event using 'Debug.trace'; this is useful when a trace ends with
629+
-- a pure error, e.g. an assertion.
630+
--
631+
ppDebug :: SimTrace a -> x -> x
632+
ppDebug = appEndo
633+
. foldMap (Endo . Debug.trace . show)
634+
. Trace.toList
635+
627636
pattern Trace :: Time -> ThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a
628637
-> SimTrace a
629638
pattern Trace time threadId threadLabel traceEvent trace =

0 commit comments

Comments
 (0)