Skip to content

coot/MArray instance fix #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
- name: Install LLVM (macOS)
if: runner.os == 'macOS'
run: |
brew install llvm@13
echo "LLVM_CONFIG=$(brew --prefix llvm@13)/bin/llvm-config" >> $GITHUB_ENV
echo "$(brew --prefix llvm@13)/bin" >> $GITHUB_PATH
brew install llvm@14
echo "LLVM_CONFIG=$(brew --prefix llvm@14)/bin/llvm-config" >> $GITHUB_ENV
echo "$(brew --prefix llvm@14)/bin" >> $GITHUB_PATH

- name: Verify LLVM installation
if: runner.os == 'macOS'
Expand Down
7 changes: 7 additions & 0 deletions io-classes-mtl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Revision history for io-classes-mtl

## 0.1.2.1

### Non breaking changes

* Added `newArray` to `MArray ContTSTM` instance (all GHC versions `9.10` were
affected).

## 0.1.2.0

### Non breaking changes
Expand Down
2 changes: 1 addition & 1 deletion io-classes-mtl/io-classes-mtl.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: io-classes-mtl
version: 0.1.2.0
version: 0.1.2.1
synopsis: Experimental MTL instances for io-classes
description:
MTL instances for
Expand Down
2 changes: 0 additions & 2 deletions io-classes-mtl/src/Control/Monad/Class/MonadSTM/Trans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ instance ( MonadSTM m, MArray e a (STM m) ) => MArray e a (ContTSTM r m) where
getNumElements = ContTSTM . getNumElements
unsafeRead arr = ContTSTM . unsafeRead arr
unsafeWrite arr i = ContTSTM . unsafeWrite arr i
#if __GLASGOW_HASKELL__ >= 910
newArray idxs = ContTSTM . newArray idxs
#endif


-- note: this (and the following) instance requires 'UndecidableInstances'
Expand Down
30 changes: 23 additions & 7 deletions io-sim/test/Test/Control/Monad/IOSimPOR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,31 @@ doit n = do
threadDelay 1
readTVarIO r


traceNoDuplicates :: (Testable prop1, Show a1) => ((a1 -> a2 -> a2) -> prop1) -> Property
traceNoDuplicates k = r `pseq` (k addTrace .&&. maximum (traceCounts ()) == 1)
traceNoDuplicates :: forall a b.
(Show a)
=> ((a -> b -> b) -> Property)
-> Property
-- this NOINLINE pragma is useful for debugging if `r` didn't flow outside of
-- `traceNoDuplicate`.
{-# NOINLINE traceNoDuplicates #-}
traceNoDuplicates k = unsafePerformIO $ do
r <- newIORef (Map.empty :: Map String Int)
return $ r `pseq`
(k (addTrace r) .&&. counterexample "trace counts" (maximum (Map.elems (traceCounts r)) === 1))
where
r = unsafePerformIO $ newIORef (Map.empty :: Map String Int)
addTrace t x = unsafePerformIO $ do
atomicModifyIORef r (\m->(Map.insertWith (+) (show t) 1 m,()))
addTrace :: IORef (Map String Int) -> a -> b -> b
addTrace r t x = unsafePerformIO $ do
let s = show t
atomicModifyIORef r
(\m->
let m' = Map.insertWith (+) s 1 m
in (m', ())
)
return x
traceCounts () = unsafePerformIO $ Map.elems <$> readIORef r

traceCounts :: IORef (Map String Int) -> Map String Int
traceCounts r = unsafePerformIO $ readIORef r


-- | Checks that IOSimPOR is capable of analysing an infinite simulation
-- lazily.
Expand Down
2 changes: 1 addition & 1 deletion si-timers/si-timers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description:
license: Apache-2.0
license-files: LICENSE NOTICE
copyright: 2022-2024 Input Output Global Inc (IOG)
author: Duncan Coutts, Neil Davis, Marcin Szamotulski
author: Duncan Coutts, Neil Davies, Marcin Szamotulski
maintainer: Duncan Coutts [email protected], Marcin Szamotulski [email protected]
category: Time
build-type: Simple
Expand Down
Loading