on master help sign in
Add the STME effect
commit1c9dced197408ab684070c28fb45845955bdd500 authorAndrzej Rybczak <andrzej@rybczak.net> dateThu 24 Jun 2021, 02:12 (5 years ago) parentb5e29e1
2 files changed+22
effectful.cabal+2 src/Effectful/STM.hs+20
effectful.cabal+2
@@ -59,6 +59,7 @@ library
5959 , monad-control
6060 , primitive
6161 , resourcet
62+ , stm
6263 , transformers
6364 , transformers-base
6465 , unliftio-core
@@ -81,6 +82,7 @@ library
8182 Effectful.State
8283 Effectful.State.Dynamic
8384 Effectful.State.MVar
85+ Effectful.STM
8486 Effectful.Writer
8587
8688test-suite test
src/Effectful/STM.hsnew file+20
@@ -0,0 +1,20 @@
1+module Effectful.STM
2+ ( STME
3+ , runSTME
4+ , atomically
5+ ) where
6+
7+import qualified Control.Monad.STM as S
8+
9+import Effectful.Internal.Effect
10+import Effectful.Internal.Monad
11+
12+-- | Run 'S.STM' computations using the @stm@ library.
13+data STME :: Effect where
14+ STME :: STME m r
15+
16+runSTME :: IOE :> es => Eff (STME : es) a -> Eff es a
17+runSTME = evalEffect (IdE STME)
18+
19+atomically :: STME :> es => S.STM a -> Eff es a
20+atomically = unsafeEff_ . S.atomically