Skip to content

Add various missing APIs to io-classes #24

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 24 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
19 changes: 2 additions & 17 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
mingw-w64-x86_64-jq

- name: Set cache version
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV
run: echo "CACHE_VERSION=pu4Aevoo_v1" >> $GITHUB_ENV

- name: "LINUX: Setup Haskell"
uses: haskell/actions/setup@v1
Expand Down Expand Up @@ -127,7 +127,6 @@ jobs:
- name: Set cache version
run: |
echo "CACHE_VERSION=hi5eTh3A" >> $GITHUB_ENV
echo "STYLISH_HASKELL_VERSION=0.13.0.0" >> $GITHUB_ENV

- name: "Install build environment (apt-get)"
run: |
Expand All @@ -151,22 +150,8 @@ jobs:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cache-dependencies-${{ env.CACHE_VERSION }}

- uses: actions/cache@v3
name: "Cache `stylish-haskell`"
with:
path: ~/.cabal/bin/stylish-haskell
key: cabal-path-${{ env.STYLISH_HASKELL_VERSION }}

# Install stylish-haskell unless the right version is already available
# from the cache
- name: "Install `stylish-haskell`"
run: |
if [[ -x $(which stylish-haskell) && $(stylish-haskell --version) == "stylish-haskell ${{ env.STYLISH_HASKELL_VERSION }}" ]];
then
echo "Using cached `stylish-haskell`"
else
cabal install stylish-haskell-${{ env.STYLISH_HASKELL_VERSION }}
fi
run: cabal install stylish-haskell-0.13.0.0

- name: "`stylish-haskell` version"
run: |
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Change Log

# Circa 2022.09.27 (pre release)

- Module structure of `MonadSTM` changed to follow `stm` package structure.
- default `MonadSTM` api implementations inlined into the type class
- Added `TQueue` and `TBQueue` to `strct-stm` package
- Added `unGetTQueue` and `unGetTBQueue`
- Fixed input-output-hk/ouroboros-network#issues2650
- Added `link2` and `link2Only` and removed `linkTo` and `linkToOnly` to `MonadAsync`
- Added `TChan`, `TSem` and `TArray`
- `MonadTraceSTM`: removed proxy argument from `trace.*IO` functions
- Split `MonadSTM` and `MonadSTM.Strict` into submodules
- Added `flushTQueue` to `MonadSTM`
- Added `cast{TQueue,TBQueue,TChan}` to `strict-stm` package
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ ones that come from `base`, `async`, or `excpetions` packages:
* `Handler` (origin: `base`)
* `MaskingState` (origin: `base`)
* `Concurrently` (origin: `async`)
* `ExceptionInLinkedThread` (origin: `async`)
* `ExceptionInLinkedThread` (origin: `async`): `io-class`es version does not
store `Async`
* `ExitCase` (origin: `exceptions`)


Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package strict-stm
source-repository-package
type: git
location: https://github.com/input-output-hk/typed-protocols
tag: b00ba45ed0c81284378ddea9a42c96e8ccb855e0
--sha256: 1qdp1wbvbmcs8z0c8phjz58w1zfwb1lkb0bjh7ksfy3hyrzcs07i
tag: aa570239bf1ed7303b730317e89d9a80d214ad38
--sha256: 0vfn0cdschyfc9j7cbbmxls0yq588xg2vmsf10bx6wgpxf9wkd2m
subdir:
typed-protocols
typed-protocols-cborg
Expand Down
10 changes: 10 additions & 0 deletions io-classes/io-classes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ library
Control.Monad.Class.MonadSay
Control.Monad.Class.MonadST
Control.Monad.Class.MonadSTM
Control.Concurrent.Class.MonadSTM
Control.Concurrent.Class.MonadSTM.TArray
Control.Concurrent.Class.MonadSTM.TBQueue
Control.Concurrent.Class.MonadSTM.TChan
Control.Concurrent.Class.MonadSTM.TMVar
Control.Concurrent.Class.MonadSTM.TQueue
Control.Concurrent.Class.MonadSTM.TSem
Control.Concurrent.Class.MonadSTM.TVar
Control.Monad.Class.MonadSTM.Internal
Control.Monad.Class.MonadThrow
Control.Monad.Class.MonadTime
Control.Monad.Class.MonadTimer
Expand All @@ -52,6 +61,7 @@ library
ScopedTypeVariables
RankNTypes
build-depends: base >=4.9 && <4.18,
array,
async >=2.1,
bytestring,
deque,
Expand Down
14 changes: 14 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- | This module corresponds to `Control.Concurrent.STM` in "stm" package
--
module Control.Concurrent.Class.MonadSTM
(module STM)
where

import Control.Monad.Class.MonadSTM as STM
import Control.Concurrent.Class.MonadSTM.TVar as STM
import Control.Concurrent.Class.MonadSTM.TMVar as STM
import Control.Concurrent.Class.MonadSTM.TChan as STM
import Control.Concurrent.Class.MonadSTM.TQueue as STM
import Control.Concurrent.Class.MonadSTM.TBQueue as STM
import Control.Concurrent.Class.MonadSTM.TArray as STM

7 changes: 7 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TArray.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TArray` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TArray (type TArray) where

import Control.Monad.Class.MonadSTM.Internal
28 changes: 28 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TBQueue.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TVar` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TBQueue
( -- * MonadSTM
type TBQueue
, newTBQueue
, newTBQueueIO
, readTBQueue
, tryReadTBQueue
, peekTBQueue
, tryPeekTBQueue
, flushTBQueue
, writeTBQueue
, lengthTBQueue
, isEmptyTBQueue
, isFullTBQueue
, unGetTBQueue
-- * MonadLabelledSTM
, labelTBQueue
, labelTBQueueIO
-- * MonadTraceSTM
, traceTBQueue
, traceTBQueueIO
) where

import Control.Monad.Class.MonadSTM.Internal
26 changes: 26 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TChan.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TChan` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TChan
( -- * MonadSTM
-- ** TChans
type TChan
-- * Construction
, newTChan
, newBroadcastTChan
, newTChanIO
, newBroadcastTChanIO
, dupTChan
, cloneTChan
-- ** Reading and writing
, readTChan
, tryReadTChan
, peekTChan
, tryPeekTChan
, writeTChan
, unGetTChan
, isEmptyTChan
) where

import Control.Monad.Class.MonadSTM.Internal
28 changes: 28 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TMVar.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TMVar` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TMVar
( -- * MonadSTM
type TMVar
, newTMVar
, newEmptyTMVar
, newTMVarIO
, newEmptyTMVarIO
, takeTMVar
, tryTakeTMVar
, putTMVar
, tryPutTMVar
, readTMVar
, tryReadTMVar
, swapTMVar
, isEmptyTMVar
-- * MonadLabelledSTM
, labelTMVar
, labelTMVarIO
-- * MonadTraceSTM
, traceTMVar
, traceTMVarIO
) where

import Control.Monad.Class.MonadSTM.Internal
26 changes: 26 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TQueue.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrnet.STM.TVar` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TQueue
( -- * MonadSTM
type TQueue
, newTQueue
, newTQueueIO
, readTQueue
, tryReadTQueue
, peekTQueue
, tryPeekTQueue
, flushTQueue
, writeTQueue
, unGetTQueue
, isEmptyTQueue
-- * MonadLabelledSTM
, labelTQueue
, labelTQueueIO
-- * MonadTraceSTM
, traceTQueue
, traceTQueueIO
) where

import Control.Monad.Class.MonadSTM.Internal
20 changes: 20 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TSem.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TSem` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TSem
( -- * MonadSTM
type TSem
, newTSem
, waitTSem
, signalTSem
, signalTSemN
-- * MonadLabelledSTM
, labelTSem
, labelTSemIO
-- * MonadTraceSTM
, traceTSem
, traceTSemIO
) where

import Control.Monad.Class.MonadSTM.Internal
26 changes: 26 additions & 0 deletions io-classes/src/Control/Concurrent/Class/MonadSTM/TVar.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE ExplicitNamespaces #-}

-- | This module corresponds to `Control.Concurrent.STM.TVar` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.TVar
( -- * MonadSTM
type TVar
, newTVar
, newTVarIO
, readTVar
, readTVarIO
, writeTVar
, modifyTVar
, modifyTVar'
, stateTVar
, swapTVar
, check
-- * MonadLabelSTM
, labelTVar
, labelTVarIO
-- * MonadTraceSTM
, traceTVar
, traceTVarIO
) where

import Control.Monad.Class.MonadSTM.Internal
Loading