polysemy-conc 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+25/−15 lines, 2 filesdep ~polysemy-timedep ~reludedep ~stm-chansPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: polysemy-time, relude, stm-chans, string-interpolate
API changes (from Hackage documentation)
Files
polysemy-conc.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: polysemy-conc-version: 0.1.0.1+version: 0.1.0.2 synopsis: Polysemy Effects for Concurrency description: See <https://hackage.haskell.org/package/polysemy-conc/docs/Polysemy-Conc.html> category: Concurrency@@ -115,11 +115,11 @@ , base ==4.* , containers , polysemy >=1.3 && <1.6- , polysemy-time >=0.1.1.0 && <0.2- , relude >=0.5 && <0.8+ , polysemy-time >=0.1.2.1 && <0.2+ , relude >=0.7 && <1.2 , stm- , stm-chans- , string-interpolate >=0.2.1+ , stm-chans >=2 && <3.1+ , string-interpolate >=0.2 && <0.4 , template-haskell , text , time@@ -205,11 +205,11 @@ , polysemy >=1.3 && <1.6 , polysemy-conc , polysemy-test- , polysemy-time >=0.1.1.0 && <0.2- , relude >=0.5 && <0.8+ , polysemy-time >=0.1.2.1 && <0.2+ , relude >=0.7 && <1.2 , stm- , stm-chans- , string-interpolate >=0.2.1+ , stm-chans >=2 && <3.1+ , string-interpolate >=0.2 && <0.4 , tasty , tasty-hedgehog , template-haskell
test/Polysemy/Conc/Test/SyncTest.hs view
@@ -9,36 +9,46 @@ import Polysemy.Conc.Race (interpretRace) import Polysemy.Conc.Sync (interpretSync) +data Thread1 = Thread1+data Thread2 = Thread2+ thread1 ::- Member (Sync Int) r =>+ Members [Sync Int, Sync Thread1, Sync Thread2] r => Sem r Int thread1 = do a <- Sync.takeBlock @Int Sync.putBlock (a + 1)+ Sync.putBlock Thread2+ Sync.takeBlock @Thread1 Sync.takeBlock thread2 ::- Member (Sync Int) r =>+ Members [Sync Int, Sync Thread1, Sync Thread2] r => Sem r Int-thread2 =+thread2 = do Sync.takeTry @Int >>= \case Just a -> pure a Nothing -> do Sync.putBlock @Int 1+ Sync.takeBlock @Thread2 a <- Sync.takeBlock Sync.putBlock (a + 1)+ Sync.putBlock Thread1 pure a run :: Members [Embed IO, Final IO] r =>- Sem (Race : Async : r) a ->+ Sem (Sync Int : Sync Thread2 : Sync Thread1 : Race : Async : r) a -> Sem r a run = asyncToIOFinal .- interpretRace+ interpretRace .+ interpretSync @Thread1 .+ interpretSync @Thread2 .+ interpretSync @Int test_sync :: UnitTest test_sync = runTestAuto do- result <- run $ interpretSync @Int $ sequenceConcurrently @[] [thread1, thread2]+ result <- run $ sequenceConcurrently @[] [thread1, thread2] assertEq @_ @IO [Just 3, Just 2] result