Skip to content
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

IOSim-1.5.0.0 #161

Merged
merged 3 commits into from
May 17, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["8.10", "9.2", "9.4", "9.6", "9.8"]
ghc: ["8.10", "9.2", "9.4", "9.6", "9.8", "9.10"]
os: [ubuntu-latest, macos-latest, windows-latest]

defaults:
Expand All @@ -27,7 +27,7 @@ jobs:
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: "3.10.1.0"
cabal-version: "3.10.3.0"

- name: Install LLVM (macOS)
if: runner.os == 'macOS'
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index-state: hackage.haskell.org 2023-11-06T00:00:00Z
index-state: hackage.haskell.org 2024-05-17T03:42:00Z

packages: ./io-sim
./io-classes
Expand Down
7 changes: 4 additions & 3 deletions io-classes-mtl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Revision history for io-classes-mtl

## new version
## 0.1.2.0

### Non breaking changes

- Added `writeTMVar` to `MonadSTM` instances.
* Added `writeTMVar` to `MonadSTM` instances.
* Support `io-classes-1.5.0.0`.

## 0.1.1.0

* Support `io-classes-1.4.1.0`
* Support `io-classes-1.4.1.0`.

## 0.1.0.2

Expand Down
8 changes: 4 additions & 4 deletions 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.1.0
version: 0.1.2.0
synopsis: Experimental MTL instances for io-classes
description:
MTL instances for
Expand All @@ -15,7 +15,7 @@ category: Control
build-type: Simple
extra-doc-files: README.md CHANGELOG.md
bug-reports: https://github.com/input-output-hk/io-sim/issues
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8 }
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8, 9.10 }

common warnings
ghc-options: -Wall
Expand All @@ -40,11 +40,11 @@ library
, Control.Monad.Class.MonadTime.SI.Trans
, Control.Monad.Class.MonadTimer.Trans
, Control.Monad.Class.MonadTimer.SI.Trans
build-depends: base >=4.9 && <4.20,
build-depends: base >=4.9 && <4.21,
array,
mtl,

io-classes ^>=1.4.1.0,
io-classes ^>=1.4.1.0 || ^>=1.5,
si-timers,


Expand Down
7 changes: 7 additions & 0 deletions io-classes-mtl/src/Control/Monad/Class/MonadSTM/Trans.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
Expand Down Expand Up @@ -51,6 +52,9 @@ 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 All @@ -64,6 +68,9 @@ instance ( MonadSTM m
, MonadThrow.MonadCatch (STM m)
) => MonadThrow.MonadThrow (ContTSTM r m) where
throwIO = ContTSTM . MonadThrow.throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (ContTSTM stm) = ContTSTM (MonadThrow.annotateIO ann stm)
#endif

instance ( MonadSTM m
, MonadThrow.MonadThrow (STM m)
Expand Down
24 changes: 24 additions & 0 deletions io-classes-mtl/src/Control/Monad/Class/MonadThrow/Trans.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Control.Monad.Class.MonadThrow.Trans () where
Expand All @@ -21,6 +22,10 @@ import Control.Monad.Class.MonadThrow

instance MonadCatch m => MonadThrow (ExceptT e m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (ExceptT io) = ExceptT (annotateIO ann io)
#endif


instance MonadCatch m => MonadCatch (ExceptT e m) where
catch (ExceptT m) f = ExceptT $ catch m (runExceptT . f)
Expand Down Expand Up @@ -63,6 +68,10 @@ instance MonadMask m => MonadMask (ExceptT e m) where
instance (Monoid w, MonadCatch m) => MonadThrow (Lazy.WriterT w m) where
throwIO = lift . throwIO

#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Lazy.WriterT io) = Lazy.WriterT (annotateIO ann io)
#endif

-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadCatch (Lazy.WriterT w m) where
catch (Lazy.WriterT m) f = Lazy.WriterT $ catch m (Lazy.runWriterT . f)
Expand Down Expand Up @@ -102,6 +111,9 @@ instance (Monoid w, MonadMask m) => MonadMask (Lazy.WriterT w m) where
-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadThrow (Strict.WriterT w m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Strict.WriterT io) = Strict.WriterT (annotateIO ann io)
#endif

-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadCatch (Strict.WriterT w m) where
Expand Down Expand Up @@ -143,6 +155,9 @@ instance (Monoid w, MonadMask m) => MonadMask (Strict.WriterT w m) where
-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadThrow (Lazy.RWST r w s m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Lazy.RWST io) = Lazy.RWST (\r s -> annotateIO ann (io r s))
#endif

-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadCatch (Lazy.RWST r w s m) where
Expand Down Expand Up @@ -186,6 +201,9 @@ instance (Monoid w, MonadMask m) => MonadMask (Lazy.RWST r w s m) where
-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadThrow (Strict.RWST r w s m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Strict.RWST io) = Strict.RWST (\r s -> annotateIO ann (io r s))
#endif

-- | @since 1.0.0.0
instance (Monoid w, MonadCatch m) => MonadCatch (Strict.RWST r w s m) where
Expand Down Expand Up @@ -229,6 +247,9 @@ instance (Monoid w, MonadMask m) => MonadMask (Strict.RWST r w s m) where
-- | @since 1.0.0.0
instance MonadCatch m => MonadThrow (Lazy.StateT s m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Lazy.StateT io) = Lazy.StateT (\s -> annotateIO ann (io s))
#endif

-- | @since 1.0.0.0
instance MonadCatch m => MonadCatch (Lazy.StateT s m) where
Expand Down Expand Up @@ -270,6 +291,9 @@ instance MonadMask m => MonadMask (Lazy.StateT s m) where
-- | @since 1.0.0.0
instance MonadCatch m => MonadThrow (Strict.StateT s m) where
throwIO = lift . throwIO
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann (Strict.StateT io) = Strict.StateT (\s -> annotateIO ann (io s))
#endif

-- | @since 1.0.0.0
instance MonadCatch m => MonadCatch (Strict.StateT s m) where
Expand Down
11 changes: 6 additions & 5 deletions io-classes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Revsion history of io-classes

## next release

### Non breaking change

* Add `writeTMVar` to `MonadSTM`.
## 1.5.0.0

### Breaking changes

* `MonadST` depends on `PrimMonad`.
* Provide a default implementation of `withLiftST`.
* Added `annotateIO` to `MonadThrow` (only supported for ghc-9.10 or newer).

### Non-breaking change

* Add `writeTMVar` to `MonadSTM`.

## 1.4.1.0

Expand Down
10 changes: 6 additions & 4 deletions io-classes/io-classes.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: io-classes
version: 1.4.1.0
version: 1.5.0.0
synopsis: Type classes for concurrency with STM, ST and timing
description:
IO Monad class hierarchy compatible with
Expand All @@ -19,7 +19,7 @@ category: Control
build-type: Simple
extra-doc-files: CHANGELOG.md README.md
bug-reports: https://github.com/input-output-hk/io-sim/issues
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8 }
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8, 9.10 }

source-repository head
type: git
Expand Down Expand Up @@ -93,14 +93,16 @@ library
TypeFamilyDependencies
TypeOperators
UndecidableInstances
build-depends: base >=4.9 && <4.20,
build-depends: base >=4.9 && <4.21,
array,
async >=2.1,
bytestring,
mtl >=2.2 && <2.4,
primitive >= 0.7 && <0.10,
primitive >= 0.7 && <0.11,
stm >=2.5 && <2.6,
time >=1.9.1 && <1.13
if impl(ghc >= 9.10)
build-depends: ghc-internal

if flag(asserts)
ghc-options: -fno-ignore-asserts
31 changes: 27 additions & 4 deletions io-classes/src/Control/Monad/Class/MonadThrow.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ExistentialQuantification #-}
Expand Down Expand Up @@ -34,18 +35,30 @@ import Control.Monad.Reader (ReaderT (..), lift, runReaderT)
import Control.Monad.STM (STM)
import Control.Monad.STM qualified as STM

#if __GLASGOW_HASKELL__ >= 910
import GHC.Internal.Exception.Context (ExceptionAnnotation)
#endif

-- | Throwing exceptions, and resource handling in the presence of exceptions.
--
-- Does not include the ability to respond to exceptions.
--
class Monad m => MonadThrow m where

#if __GLASGOW_HASKELL__ >= 910
{-# MINIMAL throwIO, annotateIO #-}
#else
{-# MINIMAL throwIO #-}
#endif

throwIO :: Exception e => e -> m a

bracket :: m a -> (a -> m b) -> (a -> m c) -> m c
bracket_ :: m a -> m b -> m c -> m c
finally :: m a -> m b -> m a
#if __GLASGOW_HASKELL__ >= 910
annotateIO :: forall e a. ExceptionAnnotation e => e -> m a -> m a
#endif

default bracket :: MonadCatch m => m a -> (a -> m b) -> (a -> m c) -> m c

Expand Down Expand Up @@ -206,11 +219,14 @@ class MonadThrow m => MonadEvaluate m where

instance MonadThrow IO where

throwIO = IO.throwIO
throwIO = IO.throwIO

bracket = IO.bracket
bracket_ = IO.bracket_
finally = IO.finally
bracket = IO.bracket
bracket_ = IO.bracket_
finally = IO.finally
#if __GLASGOW_HASKELL__ >= 910
annotateIO = IO.annotateIO
#endif


instance MonadCatch IO where
Expand Down Expand Up @@ -249,6 +265,9 @@ instance MonadEvaluate IO where

instance MonadThrow STM where
throwIO = STM.throwSTM
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann io = io `catch` \e -> throwIO (IO.addExceptionContext ann e)
#endif

instance MonadCatch STM where
catch = STM.catchSTM
Expand All @@ -273,6 +292,10 @@ instance MonadThrow m => MonadThrow (ReaderT r m) where
( runReaderT acquire env)
(\a -> runReaderT (release a) env)
(\a -> runReaderT (use a) env)
#if __GLASGOW_HASKELL__ >= 910
annotateIO ann io = ReaderT $ \env ->
annotateIO ann (runReaderT io env)
#endif

instance MonadCatch m => MonadCatch (ReaderT r m) where
catch act handler = ReaderT $ \env ->
Expand Down
9 changes: 3 additions & 6 deletions io-sim/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# Revision history of io-sim

## new version

### Non breaking changes

- Added `writeTMVar` to `MonadSTM` instance for `(IOSim s)`.
- Fixes IOSimPOR test failure (see issue #154).
## 1.5.0.0

### Breaking changes

- Generalised the type of `traceSelectTraceEvents` & co.

### Non-breaking changes

- Added `writeTMVar` to `MonadSTM` instance for `(IOSim s)`.
- Fixes IOSimPOR test failure (see issue #154).
- Reverted commit 4534b6eae64072a87bd81584f479a123681358a3 which uses
`unsafePerformIO` instead of ST, to regain lazyness on infinite simulations.
- Added a test to check for lazyness on infinite simulations
Expand Down
16 changes: 8 additions & 8 deletions io-sim/io-sim.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: io-sim
version: 1.4.1.0
version: 1.5.0.0
synopsis: A pure simulator for monadic concurrency with STM.
description:
A pure simulator monad with support of concurency (base & async style), stm,
Expand All @@ -15,7 +15,7 @@ category: Testing
build-type: Simple
extra-doc-files: CHANGELOG.md README.md
bug-reports: https://github.com/input-output-hk/io-sim/issues
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8 }
tested-with: GHC == { 8.10, 9.2, 9.4, 9.6, 9.8, 9.10 }

flag asserts
description: Enable assertions
Expand Down Expand Up @@ -75,16 +75,16 @@ library
RankNTypes,
ScopedTypeVariables,
TypeFamilies
build-depends: base >=4.9 && <4.20,
io-classes ^>=1.4.1,
build-depends: base >=4.9 && <4.21,
io-classes ^>=1.5,
exceptions >=0.10,
containers,
deepseq,
nothunks,
primitive >=0.7 && <0.10,
primitive >=0.7 && <0.11,
psqueues >=0.2 && <0.3,
strict-stm ^>=1.4,
si-timers ^>=1.4,
strict-stm ^>=1.5,
si-timers ^>=1.5,
time >=1.9.1 && <1.13,
quiet,
QuickCheck,
Expand Down Expand Up @@ -131,7 +131,7 @@ benchmark bench
default-language: Haskell2010
default-extensions: ImportQualifiedPost
build-depends: base,
criterion,
criterion ^>= 1.6,

io-classes,
io-sim,
Expand Down
Loading
Loading