Skip to content

Commit 5ae98b7

Browse files
authored
Merge pull request #202 from input-output-hk/coot/ppTrace_
io-sim: more general ppTrace_ type signature
2 parents 573aa8d + c035dea commit 5ae98b7

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

.github/workflows/haskell.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
- name: Install LLVM (macOS)
3333
if: runner.os == 'macOS' && matrix.ghc == '8.10'
3434
run: |
35-
brew install llvm@13
36-
echo "LLVM_CONFIG=$(brew --prefix llvm@13)/bin/llvm-config" >> $GITHUB_ENV
37-
echo "$(brew --prefix llvm@13)/bin" >> $GITHUB_PATH
35+
brew install llvm@14
36+
echo "LLVM_CONFIG=$(brew --prefix llvm@14)/bin/llvm-config" >> $GITHUB_ENV
37+
echo "$(brew --prefix llvm@14)/bin" >> $GITHUB_PATH
3838
3939
- name: Verify LLVM installation
4040
if: runner.os == 'macOS' && matrix.ghc == '8.10'

io-classes/mtl/Control/Monad/Class/MonadSTM/Trans.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ instance ( MonadSTM m, MArray e a (STM m) ) => MArray e a (ContTSTM r m) where
5454
getNumElements = ContTSTM . getNumElements
5555
unsafeRead arr = ContTSTM . unsafeRead arr
5656
unsafeWrite arr i = ContTSTM . unsafeWrite arr i
57-
#if __GLASGOW_HASKELL__ >= 910
5857
newArray idxs = ContTSTM . newArray idxs
59-
#endif
6058

6159

6260
-- note: this (and the following) instance requires 'UndecidableInstances'

io-sim/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- `selectTraceEventsSayWithTime'`
2323
is more general. These functions now accepts trace with any result, rather
2424
than one that finishes with `SimResult`.
25+
- More polymorphic `ppTrace_` type signature.
2526

2627
## 1.6.0.0
2728

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ ppTrace tr = Trace.ppTrace
938938

939939
-- | Like 'ppTrace' but does not show the result value.
940940
--
941-
ppTrace_ :: SimTrace a -> String
941+
ppTrace_ :: Trace.Trace a SimEvent -> String
942942
ppTrace_ tr = Trace.ppTrace
943943
(const "")
944944
(ppSimEvent timeWidth tidWidth labelWidth)

io-sim/test/Test/Control/Monad/IOSimPOR.hs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,31 @@ doit n = do
434434
threadDelay 1
435435
readTVarIO r
436436

437-
438-
traceNoDuplicates :: (Testable prop1, Show a1) => ((a1 -> a2 -> a2) -> prop1) -> Property
439-
traceNoDuplicates k = r `pseq` (k addTrace .&&. maximum (traceCounts ()) == 1)
437+
traceNoDuplicates :: forall a b.
438+
(Show a)
439+
=> ((a -> b -> b) -> Property)
440+
-> Property
441+
-- this NOINLINE pragma is useful for debugging if `r` didn't flow outside of
442+
-- `traceNoDuplicate`.
443+
{-# NOINLINE traceNoDuplicates #-}
444+
traceNoDuplicates k = unsafePerformIO $ do
445+
r <- newIORef (Map.empty :: Map String Int)
446+
return $ r `pseq`
447+
(k (addTrace r) .&&. counterexample "trace counts" (maximum (Map.elems (traceCounts r)) === 1))
440448
where
441-
r = unsafePerformIO $ newIORef (Map.empty :: Map String Int)
442-
addTrace t x = unsafePerformIO $ do
443-
atomicModifyIORef r (\m->(Map.insertWith (+) (show t) 1 m,()))
449+
addTrace :: IORef (Map String Int) -> a -> b -> b
450+
addTrace r t x = unsafePerformIO $ do
451+
let s = show t
452+
atomicModifyIORef r
453+
(\m->
454+
let m' = Map.insertWith (+) s 1 m
455+
in (m', ())
456+
)
444457
return x
445-
traceCounts () = unsafePerformIO $ Map.elems <$> readIORef r
458+
459+
traceCounts :: IORef (Map String Int) -> Map String Int
460+
traceCounts r = unsafePerformIO $ readIORef r
461+
446462

447463
-- | Checks that IOSimPOR is capable of analysing an infinite simulation
448464
-- lazily.

0 commit comments

Comments
 (0)