@@ -1,8 +1,8 @@
1{-# LANGUAGE UndecidableInstances #-}
1{-# LANGUAGE UndecidableInstances #-}
2+-- | Lifted version of "Control.Concurrent.Async".
2−module Effectful.Async
3+module Effectful.Concurrent.Async
3− ( -- * Async effect
4+ ( Concurrent
4− AsyncE
5+ , runConcurrent
7 -- * Asynchronous actions
7 -- * Asynchronous actions
@@ -76,52 +76,37 @@ import Control.Concurrent (threadDelay)
76import Control.Concurrent.Async (Async)
76import Control.Concurrent.Async (Async)
77import Control.Exception (Exception, SomeException)
77import Control.Exception (Exception, SomeException)
78import Control.Monad (forever)
78import Control.Monad (forever)
79−import Data.Kind
79+import Data.Kind (Type)
80import qualified Control.Concurrent.Async as A
80import qualified Control.Concurrent.Async as A
81import qualified UnliftIO.Async as U
81import qualified UnliftIO.Async as U
82import qualified UnliftIO.Internals.Async as I
82import qualified UnliftIO.Internals.Async as I
84−import Effectful.Internal.Effect
84+import Effectful.Concurrent.Effect
85−import Effectful.Internal.Env
85+import Effectful.Dispatch.Static
86−import Effectful.Internal.Monad
86+import Effectful.Monad
88−-- | Run 'Eff' operations asynchronously via the @async@ library.
90−-- /Note:/ thread local state changes in 'Eff' operations run asynchronously
91−-- will not affect the parent thread.
93−-- /TODO:/ write about 'AsyncE' not respecting scoped operations.
94−data AsyncE :: Effect where
97−runAsyncE :: IOE :> es => Eff (AsyncE : es) a -> Eff es a
98−runAsyncE = evalEffect (IdE AsyncE)
100−----------------------------------------
103-- | Lifted 'A.async'.
88-- | Lifted 'A.async'.
104−async :: AsyncE :> es => Eff es a -> Eff es (Async a)
89+async :: Concurrent :> es => Eff es a -> Eff es (Async a)
105async = liftAsync A.async
90async = liftAsync A.async
107-- | Lifted 'A.asyncBound'.
92-- | Lifted 'A.asyncBound'.
108−asyncBound :: AsyncE :> es => Eff es a -> Eff es (Async a)
93+asyncBound :: Concurrent :> es => Eff es a -> Eff es (Async a)
109asyncBound = liftAsync A.asyncBound
94asyncBound = liftAsync A.asyncBound
111-- | Lifted 'A.asyncOn'.
96-- | Lifted 'A.asyncOn'.
112−asyncOn :: AsyncE :> es => Int -> Eff es a -> Eff es (Async a)
97+asyncOn :: Concurrent :> es => Int -> Eff es a -> Eff es (Async a)
113asyncOn cpu = liftAsync (A.asyncOn cpu)
98asyncOn cpu = liftAsync (A.asyncOn cpu)
115-- | Lifted 'A.asyncWithUnmask'.
100-- | Lifted 'A.asyncWithUnmask'.
116asyncWithUnmask
101asyncWithUnmask
117− :: AsyncE :> es
102+ :: Concurrent :> es
118 => ((forall b. Eff es b -> Eff es b) -> Eff es a)
103 => ((forall b. Eff es b -> Eff es b) -> Eff es a)
119 -> Eff es (Async a)
104 -> Eff es (Async a)
120asyncWithUnmask = liftAsyncWithUnmask A.asyncWithUnmask
105asyncWithUnmask = liftAsyncWithUnmask A.asyncWithUnmask
122-- | Lifted 'A.asyncOnWithUnmask'.
107-- | Lifted 'A.asyncOnWithUnmask'.
123asyncOnWithUnmask
108asyncOnWithUnmask
124− :: AsyncE :> es
109+ :: Concurrent :> es
126 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
111 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
127 -> Eff es (Async a)
112 -> Eff es (Async a)
@@ -129,7 +114,7 @@ asyncOnWithUnmask cpu = liftAsyncWithUnmask (A.asyncOnWithUnmask cpu)
130-- | Lifted 'A.withAsync'.
115-- | Lifted 'A.withAsync'.
132− :: AsyncE :> es
117+ :: Concurrent :> es
133 => Eff es a
118 => Eff es a
134 -> (Async a -> Eff es b)
119 -> (Async a -> Eff es b)
135 -> Eff es b
120 -> Eff es b
@@ -137,7 +122,7 @@ withAsync = liftWithAsync A.withAsync
138-- | Lifted 'A.withAsyncBound'.
123-- | Lifted 'A.withAsyncBound'.
139withAsyncBound
124withAsyncBound
140− :: AsyncE :> es
125+ :: Concurrent :> es
141 => Eff es a
126 => Eff es a
142 -> (Async a -> Eff es b)
127 -> (Async a -> Eff es b)
143 -> Eff es b
128 -> Eff es b
@@ -145,7 +130,7 @@ withAsyncBound = liftWithAsync A.withAsyncBound
146-- | Lifted 'A.withAsyncOn'.
131-- | Lifted 'A.withAsyncOn'.
147withAsyncOn
132withAsyncOn
148− :: AsyncE :> es
133+ :: Concurrent :> es
150 -> Eff es a
135 -> Eff es a
151 -> (Async a -> Eff es b)
136 -> (Async a -> Eff es b)
@@ -154,7 +139,7 @@ withAsyncOn cpu = liftWithAsync (A.withAsyncOn cpu)
155-- | Lifted 'A.withAsyncWithUnmask'.
140-- | Lifted 'A.withAsyncWithUnmask'.
156withAsyncWithUnmask
141withAsyncWithUnmask
157− :: AsyncE :> es
142+ :: Concurrent :> es
158 => ((forall c. Eff es c -> Eff es c) -> Eff es a)
143 => ((forall c. Eff es c -> Eff es c) -> Eff es a)
159 -> (Async a -> Eff es b)
144 -> (Async a -> Eff es b)
160 -> Eff es b
145 -> Eff es b
@@ -162,7 +147,7 @@ withAsyncWithUnmask = liftWithAsyncWithUnmask A.withAsyncWithUnmask
163-- | Lifted 'A.withAsyncOnWithUnmask'.
148-- | Lifted 'A.withAsyncOnWithUnmask'.
164withAsyncOnWithUnmask
149withAsyncOnWithUnmask
165− :: AsyncE :> es
150+ :: Concurrent :> es
167 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
152 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
168 -> (Async a -> Eff es b)
153 -> (Async a -> Eff es b)
@@ -170,60 +155,60 @@ withAsyncOnWithUnmask
170withAsyncOnWithUnmask cpu = liftWithAsyncWithUnmask (A.withAsyncOnWithUnmask cpu)
155withAsyncOnWithUnmask cpu = liftWithAsyncWithUnmask (A.withAsyncOnWithUnmask cpu)
172-- | Lifted 'A.wait'.
157-- | Lifted 'A.wait'.
173−wait :: AsyncE :> es => Async a -> Eff es a
158+wait :: Concurrent :> es => Async a -> Eff es a
174wait = unsafeEff_ . A.wait
159wait = unsafeEff_ . A.wait
176-- | Lifted 'A.poll'.
161-- | Lifted 'A.poll'.
178− :: AsyncE :> es
163+ :: Concurrent :> es
179 => Async a
164 => Async a
180 -> Eff es (Maybe (Either SomeException a))
165 -> Eff es (Maybe (Either SomeException a))
181poll = unsafeEff_ . A.poll
166poll = unsafeEff_ . A.poll
183-- | Lifted 'A.cancel'.
168-- | Lifted 'A.cancel'.
184−cancel :: AsyncE :> es => Async a -> Eff es ()
169+cancel :: Concurrent :> es => Async a -> Eff es ()
185cancel = unsafeEff_ . A.cancel
170cancel = unsafeEff_ . A.cancel
187-- | Lifted 'A.cancelWith'.
172-- | Lifted 'A.cancelWith'.
188−cancelWith :: (Exception e, AsyncE :> es) => Async a -> e -> Eff es ()
173+cancelWith :: (Exception e, Concurrent :> es) => Async a -> e -> Eff es ()
189cancelWith a = unsafeEff_ . A.cancelWith a
174cancelWith a = unsafeEff_ . A.cancelWith a
191-- | Lifted 'A.uninterruptibleCancel'.
176-- | Lifted 'A.uninterruptibleCancel'.
192−uninterruptibleCancel :: AsyncE :> es => Async a -> Eff es ()
177+uninterruptibleCancel :: Concurrent :> es => Async a -> Eff es ()
193uninterruptibleCancel = unsafeEff_ . A.uninterruptibleCancel
178uninterruptibleCancel = unsafeEff_ . A.uninterruptibleCancel
195-- | Lifted 'A.waitCatch'.
180-- | Lifted 'A.waitCatch'.
197− :: AsyncE :> es
182+ :: Concurrent :> es
198 => Async a
183 => Async a
199 -> Eff es (Either SomeException a)
184 -> Eff es (Either SomeException a)
200waitCatch = unsafeEff_ . A.waitCatch
185waitCatch = unsafeEff_ . A.waitCatch
202-- | Lifted 'A.waitAny'.
187-- | Lifted 'A.waitAny'.
203−waitAny :: AsyncE :> es => [Async a] -> Eff es (Async a, a)
188+waitAny :: Concurrent :> es => [Async a] -> Eff es (Async a, a)
204waitAny = unsafeEff_ . A.waitAny
189waitAny = unsafeEff_ . A.waitAny
206-- | Lifted 'A.waitAnyCatch'.
191-- | Lifted 'A.waitAnyCatch'.
207waitAnyCatch
192waitAnyCatch
208− :: AsyncE :> es
193+ :: Concurrent :> es
209 => [Async a]
194 => [Async a]
210 -> Eff es (Async a, Either SomeException a)
195 -> Eff es (Async a, Either SomeException a)
211waitAnyCatch = unsafeEff_ . A.waitAnyCatch
196waitAnyCatch = unsafeEff_ . A.waitAnyCatch
213-- | Lifted 'A.waitAnyCancel'.
198-- | Lifted 'A.waitAnyCancel'.
214−waitAnyCancel :: AsyncE :> es => [Async a] -> Eff es (Async a, a)
199+waitAnyCancel :: Concurrent :> es => [Async a] -> Eff es (Async a, a)
215waitAnyCancel = unsafeEff_ . A.waitAnyCancel
200waitAnyCancel = unsafeEff_ . A.waitAnyCancel
217-- | Lifted 'A.waitAnyCatchCancel'.
202-- | Lifted 'A.waitAnyCatchCancel'.
218waitAnyCatchCancel
203waitAnyCatchCancel
219− :: AsyncE :> es
204+ :: Concurrent :> es
220 => [Async a]
205 => [Async a]
221 -> Eff es (Async a, Either SomeException a)
206 -> Eff es (Async a, Either SomeException a)
222waitAnyCatchCancel = unsafeEff_ . A.waitAnyCatchCancel
207waitAnyCatchCancel = unsafeEff_ . A.waitAnyCatchCancel
224-- | Lifted 'A.waitEither'.
209-- | Lifted 'A.waitEither'.
225waitEither
210waitEither
226− :: AsyncE :> es
211+ :: Concurrent :> es
227 => Async a
212 => Async a
228 -> Async b
213 -> Async b
229 -> Eff es (Either a b)
214 -> Eff es (Either a b)
@@ -231,7 +216,7 @@ waitEither a b = unsafeEff_ $ A.waitEither a b
232-- | Lifted 'A.waitEitherCatch'.
217-- | Lifted 'A.waitEitherCatch'.
233waitEitherCatch
218waitEitherCatch
234− :: AsyncE :> es
219+ :: Concurrent :> es
235 => Async a
220 => Async a
236 -> Async b
221 -> Async b
237 -> Eff es (Either (Either SomeException a) (Either SomeException b))
222 -> Eff es (Either (Either SomeException a) (Either SomeException b))
@@ -239,7 +224,7 @@ waitEitherCatch a b = unsafeEff_ $ A.waitEitherCatch a b
240-- | Lifted 'A.waitEitherCancel'.
225-- | Lifted 'A.waitEitherCancel'.
241waitEitherCancel
226waitEitherCancel
242− :: AsyncE :> es
227+ :: Concurrent :> es
243 => Async a
228 => Async a
244 -> Async b
229 -> Async b
245 -> Eff es (Either a b)
230 -> Eff es (Either a b)
@@ -247,53 +232,53 @@ waitEitherCancel a b = unsafeEff_ $ A.waitEitherCancel a b
248-- | Lifted 'A.waitEitherCatchCancel'.
233-- | Lifted 'A.waitEitherCatchCancel'.
249waitEitherCatchCancel
234waitEitherCatchCancel
250− :: AsyncE :> es
235+ :: Concurrent :> es
251 => Async a
236 => Async a
252 -> Async b
237 -> Async b
253 -> Eff es (Either (Either SomeException a) (Either SomeException b))
238 -> Eff es (Either (Either SomeException a) (Either SomeException b))
254waitEitherCatchCancel a b = unsafeEff_ $ A.waitEitherCatch a b
239waitEitherCatchCancel a b = unsafeEff_ $ A.waitEitherCatch a b
256-- | Lifted 'A.waitEither_'.
241-- | Lifted 'A.waitEither_'.
257−waitEither_ :: AsyncE :> es => Async a -> Async b -> Eff es ()
242+waitEither_ :: Concurrent :> es => Async a -> Async b -> Eff es ()
258waitEither_ a b = unsafeEff_ $ A.waitEither_ a b
243waitEither_ a b = unsafeEff_ $ A.waitEither_ a b
260-- | Lifted 'A.waitBoth'.
245-- | Lifted 'A.waitBoth'.
261−waitBoth :: AsyncE :> es => Async a -> Async b -> Eff es (a, b)
246+waitBoth :: Concurrent :> es => Async a -> Async b -> Eff es (a, b)
262waitBoth a b = unsafeEff_ $ A.waitBoth a b
247waitBoth a b = unsafeEff_ $ A.waitBoth a b
264-- | Lifted 'A.link'.
249-- | Lifted 'A.link'.
265−link :: AsyncE :> es => Async a -> Eff es ()
250+link :: Concurrent :> es => Async a -> Eff es ()
266link = unsafeEff_ . A.link
251link = unsafeEff_ . A.link
268-- | Lifted 'A.linkOnly'.
253-- | Lifted 'A.linkOnly'.
269−linkOnly :: AsyncE :> es => (SomeException -> Bool) -> Async a -> Eff es ()
254+linkOnly :: Concurrent :> es => (SomeException -> Bool) -> Async a -> Eff es ()
270linkOnly f = unsafeEff_ . A.linkOnly f
255linkOnly f = unsafeEff_ . A.linkOnly f
272-- | Lifted 'A.link2'.
257-- | Lifted 'A.link2'.
273−link2 :: AsyncE :> es => Async a -> Async b -> Eff es ()
258+link2 :: Concurrent :> es => Async a -> Async b -> Eff es ()
274link2 a b = unsafeEff_ $ A.link2 a b
259link2 a b = unsafeEff_ $ A.link2 a b
276-- | Lifted 'A.link2Only'.
261-- | Lifted 'A.link2Only'.
277−link2Only :: AsyncE :> es => (SomeException -> Bool) -> Async a -> Async b -> Eff es ()
262+link2Only :: Concurrent :> es => (SomeException -> Bool) -> Async a -> Async b -> Eff es ()
278link2Only f a b = unsafeEff_ $ A.link2Only f a b
263link2Only f a b = unsafeEff_ $ A.link2Only f a b
280-- | Lifted 'A.race'.
265-- | Lifted 'A.race'.
281−race :: AsyncE :> es => Eff es a -> Eff es b -> Eff es (Either a b)
266+race :: Concurrent :> es => Eff es a -> Eff es b -> Eff es (Either a b)
282race ma mb = unsafeEff $ \es -> do
267race ma mb = unsafeEff $ \es -> do
283 A.race (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
268 A.race (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
285-- | Lifted 'A.race_'.
270-- | Lifted 'A.race_'.
286−race_ :: AsyncE :> es => Eff es a -> Eff es b -> Eff es ()
271+race_ :: Concurrent :> es => Eff es a -> Eff es b -> Eff es ()
287race_ ma mb = unsafeEff $ \es -> do
272race_ ma mb = unsafeEff $ \es -> do
288 A.race_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
273 A.race_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
290-- | Lifted 'A.concurrently'.
275-- | Lifted 'A.concurrently'.
291−concurrently :: AsyncE :> es => Eff es a -> Eff es b -> Eff es (a, b)
276+concurrently :: Concurrent :> es => Eff es a -> Eff es b -> Eff es (a, b)
292concurrently ma mb = unsafeEff $ \es -> do
277concurrently ma mb = unsafeEff $ \es -> do
293 A.concurrently (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
278 A.concurrently (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
295-- | Lifted 'A.concurrently_'.
280-- | Lifted 'A.concurrently_'.
296−concurrently_ :: AsyncE :> es => Eff es a -> Eff es b -> Eff es ()
281+concurrently_ :: Concurrent :> es => Eff es a -> Eff es b -> Eff es ()
297concurrently_ ma mb = unsafeEff $ \es -> do
282concurrently_ ma mb = unsafeEff $ \es -> do
298 A.concurrently_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
283 A.concurrently_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
@@ -303,7 +288,7 @@ concurrently_ ma mb = unsafeEff $ \es -> do
304-- | Lifted 'A.mapConcurrently'.
289-- | Lifted 'A.mapConcurrently'.
305mapConcurrently
290mapConcurrently
306− :: (Traversable f, AsyncE :> es)
291+ :: (Traversable f, Concurrent :> es)
307 => (a -> Eff es b)
292 => (a -> Eff es b)
309 -> Eff es (f b)
294 -> Eff es (f b)
@@ -312,7 +297,7 @@ mapConcurrently f t = unsafeEff $ \es -> do
313-- | Lifted 'A.mapConcurrently_'.
298-- | Lifted 'A.mapConcurrently_'.
314mapConcurrently_
299mapConcurrently_
315− :: (Foldable f, AsyncE :> es)
300+ :: (Foldable f, Concurrent :> es)
316 => (a -> Eff es b)
301 => (a -> Eff es b)
318 -> Eff es ()
303 -> Eff es ()
@@ -321,7 +306,7 @@ mapConcurrently_ f t = unsafeEff $ \es -> do
322-- | Lifted 'A.forConcurrently'.
307-- | Lifted 'A.forConcurrently'.
323forConcurrently
308forConcurrently
324− :: (Traversable f, AsyncE :> es)
309+ :: (Traversable f, Concurrent :> es)
326 -> (a -> Eff es b)
311 -> (a -> Eff es b)
327 -> Eff es (f b)
312 -> Eff es (f b)
@@ -330,7 +315,7 @@ forConcurrently t f = unsafeEff $ \es -> do
331-- | Lifted 'A.forConcurrently_'.
316-- | Lifted 'A.forConcurrently_'.
332forConcurrently_
317forConcurrently_
333− :: (Foldable f, AsyncE :> es)
318+ :: (Foldable f, Concurrent :> es)
335 -> (a -> Eff es b)
320 -> (a -> Eff es b)
336 -> Eff es ()
321 -> Eff es ()
@@ -338,12 +323,12 @@ forConcurrently_ t f = unsafeEff $ \es -> do
338 U.forConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
323 U.forConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
340-- | Lifted 'A.replicateConcurrently'.
325-- | Lifted 'A.replicateConcurrently'.
341−replicateConcurrently :: AsyncE :> es => Int -> Eff es a -> Eff es [a]
326+replicateConcurrently :: Concurrent :> es => Int -> Eff es a -> Eff es [a]
342replicateConcurrently n f = unsafeEff $ \es -> do
327replicateConcurrently n f = unsafeEff $ \es -> do
343 U.replicateConcurrently n (unEff f =<< cloneEnv es)
328 U.replicateConcurrently n (unEff f =<< cloneEnv es)
345-- | Lifted 'A.replicateConcurrently_'.
330-- | Lifted 'A.replicateConcurrently_'.
346−replicateConcurrently_ :: AsyncE :> es => Int -> Eff es a -> Eff es ()
331+replicateConcurrently_ :: Concurrent :> es => Int -> Eff es a -> Eff es ()
347replicateConcurrently_ n f = unsafeEff $ \es -> do
332replicateConcurrently_ n f = unsafeEff $ \es -> do
348 U.replicateConcurrently_ n (unEff f =<< cloneEnv es)
333 U.replicateConcurrently_ n (unEff f =<< cloneEnv es)
@@ -352,7 +337,7 @@ replicateConcurrently_ n f = unsafeEff $ \es -> do
353-- | Lifted 'U.pooledMapConcurrentlyN'.
338-- | Lifted 'U.pooledMapConcurrentlyN'.
354pooledMapConcurrentlyN
339pooledMapConcurrentlyN
355− :: (AsyncE :> es, Traversable t)
340+ :: (Concurrent :> es, Traversable t)
357 -> (a -> Eff es b)
342 -> (a -> Eff es b)
@@ -362,7 +347,7 @@ pooledMapConcurrentlyN threads f t = unsafeEff $ \es -> do
363-- | Lifted 'U.pooledMapConcurrently'.
348-- | Lifted 'U.pooledMapConcurrently'.
364pooledMapConcurrently
349pooledMapConcurrently
365− :: (AsyncE :> es, Traversable t)
350+ :: (Concurrent :> es, Traversable t)
366 => (a -> Eff es b)
351 => (a -> Eff es b)
368 -> Eff es (t b)
353 -> Eff es (t b)
@@ -371,7 +356,7 @@ pooledMapConcurrently f t = unsafeEff $ \es -> do
372-- | Lifted 'U.pooledMapConcurrentlyN'.
357-- | Lifted 'U.pooledMapConcurrentlyN'.
373pooledMapConcurrentlyN_
358pooledMapConcurrentlyN_
374− :: (AsyncE :> es, Foldable f)
359+ :: (Concurrent :> es, Foldable f)
376 -> (a -> Eff es b)
361 -> (a -> Eff es b)
@@ -381,7 +366,7 @@ pooledMapConcurrentlyN_ threads f t = unsafeEff $ \es -> do
382-- | Lifted 'U.pooledMapConcurrently_'.
367-- | Lifted 'U.pooledMapConcurrently_'.
383pooledMapConcurrently_
368pooledMapConcurrently_
384− :: (AsyncE :> es, Foldable f)
369+ :: (Concurrent :> es, Foldable f)
385 => (a -> Eff es b)
370 => (a -> Eff es b)
387 -> Eff es ()
372 -> Eff es ()
@@ -390,7 +375,7 @@ pooledMapConcurrently_ f t = unsafeEff $ \es -> do
391-- | Lifted 'U.pooledForConcurrentlyN'.
376-- | Lifted 'U.pooledForConcurrentlyN'.
392pooledForConcurrentlyN
377pooledForConcurrentlyN
393− :: (AsyncE :> es, Traversable t)
378+ :: (Concurrent :> es, Traversable t)
396 -> (a -> Eff es b)
381 -> (a -> Eff es b)
@@ -400,7 +385,7 @@ pooledForConcurrentlyN threads t f = unsafeEff $ \es -> do
401-- | Lifted 'U.pooledForConcurrently'.
386-- | Lifted 'U.pooledForConcurrently'.
402pooledForConcurrently
387pooledForConcurrently
403− :: (AsyncE :> es, Traversable t)
388+ :: (Concurrent :> es, Traversable t)
405 -> (a -> Eff es b)
390 -> (a -> Eff es b)
406 -> Eff es (t b)
391 -> Eff es (t b)
@@ -409,7 +394,7 @@ pooledForConcurrently t f = unsafeEff $ \es -> do
410-- | Lifted 'U.pooledForConcurrentlyN'.
395-- | Lifted 'U.pooledForConcurrentlyN'.
411pooledForConcurrentlyN_
396pooledForConcurrentlyN_
412− :: (AsyncE :> es, Foldable f)
397+ :: (Concurrent :> es, Foldable f)
415 -> (a -> Eff es b)
400 -> (a -> Eff es b)
@@ -419,7 +404,7 @@ pooledForConcurrentlyN_ threads t f = unsafeEff $ \es -> do
420-- | Lifted 'U.pooledForConcurrently_'.
405-- | Lifted 'U.pooledForConcurrently_'.
421pooledForConcurrently_
406pooledForConcurrently_
422− :: (AsyncE :> es, Foldable f)
407+ :: (Concurrent :> es, Foldable f)
424 -> (a -> Eff es b)
409 -> (a -> Eff es b)
425 -> Eff es ()
410 -> Eff es ()
@@ -427,22 +412,22 @@ pooledForConcurrently_ t f = unsafeEff $ \es -> do
427 U.pooledForConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
412 U.pooledForConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
429-- | Lifted 'U.pooledReplicateConcurrentlyN'.
414-- | Lifted 'U.pooledReplicateConcurrentlyN'.
430−pooledReplicateConcurrentlyN :: AsyncE :> es => Int -> Int -> Eff es a -> Eff es [a]
415+pooledReplicateConcurrentlyN :: Concurrent :> es => Int -> Int -> Eff es a -> Eff es [a]
431pooledReplicateConcurrentlyN threads n f = unsafeEff $ \es -> do
416pooledReplicateConcurrentlyN threads n f = unsafeEff $ \es -> do
432 U.pooledReplicateConcurrentlyN threads n (unEff f =<< cloneEnv es)
417 U.pooledReplicateConcurrentlyN threads n (unEff f =<< cloneEnv es)
434-- | Lifted 'U.pooledReplicateConcurrently'.
419-- | Lifted 'U.pooledReplicateConcurrently'.
435−pooledReplicateConcurrently :: AsyncE :> es => Int -> Eff es a -> Eff es [a]
420+pooledReplicateConcurrently :: Concurrent :> es => Int -> Eff es a -> Eff es [a]
436pooledReplicateConcurrently n f = unsafeEff $ \es -> do
421pooledReplicateConcurrently n f = unsafeEff $ \es -> do
437 U.pooledReplicateConcurrently n (unEff f =<< cloneEnv es)
422 U.pooledReplicateConcurrently n (unEff f =<< cloneEnv es)
439-- | Lifted 'U.pooledReplicateConcurrentlyN_'.
424-- | Lifted 'U.pooledReplicateConcurrentlyN_'.
440−pooledReplicateConcurrentlyN_ :: AsyncE :> es => Int -> Int -> Eff es a -> Eff es ()
425+pooledReplicateConcurrentlyN_ :: Concurrent :> es => Int -> Int -> Eff es a -> Eff es ()
441pooledReplicateConcurrentlyN_ threads n f = unsafeEff $ \es -> do
426pooledReplicateConcurrentlyN_ threads n f = unsafeEff $ \es -> do
442 U.pooledReplicateConcurrentlyN_ threads n (unEff f =<< cloneEnv es)
427 U.pooledReplicateConcurrentlyN_ threads n (unEff f =<< cloneEnv es)
444-- | Lifted 'U.pooledReplicateConcurrently_'.
429-- | Lifted 'U.pooledReplicateConcurrently_'.
445−pooledReplicateConcurrently_ :: AsyncE :> es => Int -> Eff es a -> Eff es ()
430+pooledReplicateConcurrently_ :: Concurrent :> es => Int -> Eff es a -> Eff es ()
446pooledReplicateConcurrently_ n f = unsafeEff $ \es -> do
431pooledReplicateConcurrently_ n f = unsafeEff $ \es -> do
447 U.pooledReplicateConcurrently_ n (unEff f =<< cloneEnv es)
432 U.pooledReplicateConcurrently_ n (unEff f =<< cloneEnv es)
@@ -482,7 +467,7 @@ conc :: Eff es a -> Conc es a
482conc = Action
467conc = Action
484-- | Lifted 'U.runConc'.
469-- | Lifted 'U.runConc'.
485−runConc :: AsyncE :> es => Conc es a -> Eff es a
470+runConc :: Concurrent :> es => Conc es a -> Eff es a
486runConc m = unsafeEff $ \es -> U.runConc (unliftConc es m)
471runConc m = unsafeEff $ \es -> U.runConc (unliftConc es m)
488 unliftConc :: Env es -> Conc es a -> U.Conc IO a
473 unliftConc :: Env es -> Conc es a -> U.Conc IO a
@@ -503,20 +488,20 @@ newtype Concurrently es a = Concurrently { runConcurrently :: Eff es a }
503instance Functor (Concurrently es) where
488instance Functor (Concurrently es) where
504 fmap f (Concurrently a) = Concurrently (fmap f a)
489 fmap f (Concurrently a) = Concurrently (fmap f a)
506−instance AsyncE :> es => Applicative (Concurrently es) where
491+instance Concurrent :> es => Applicative (Concurrently es) where
507 pure = Concurrently . pure
492 pure = Concurrently . pure
508 Concurrently fs <*> Concurrently as =
493 Concurrently fs <*> Concurrently as =
509 Concurrently ((\(f, a) -> f a) <$> concurrently fs as)
494 Concurrently ((\(f, a) -> f a) <$> concurrently fs as)
511−instance AsyncE :> es => Alternative (Concurrently es) where
496+instance Concurrent :> es => Alternative (Concurrently es) where
512 empty = Concurrently . unsafeEff_ . forever $ threadDelay maxBound
497 empty = Concurrently . unsafeEff_ . forever $ threadDelay maxBound
513 Concurrently as <|> Concurrently bs =
498 Concurrently as <|> Concurrently bs =
514 Concurrently (either id id <$> race as bs)
499 Concurrently (either id id <$> race as bs)
516−instance (AsyncE :> es, Semigroup a) => Semigroup (Concurrently es a) where
501+instance (Concurrent :> es, Semigroup a) => Semigroup (Concurrently es a) where
517 (<>) = liftA2 (<>)
502 (<>) = liftA2 (<>)
519−instance (AsyncE :> es, Monoid a) => Monoid (Concurrently es a) where
504+instance (Concurrent :> es, Monoid a) => Monoid (Concurrently es a) where
520 mempty = pure mempty
505 mempty = pure mempty
522----------------------------------------
507----------------------------------------
@@ -534,10 +519,9 @@ liftAsyncWithUnmask
534 :: (((forall b. IO b -> IO b) -> IO a) -> IO (Async a))
519 :: (((forall b. IO b -> IO b) -> IO a) -> IO (Async a))
535 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
520 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
536 -> Eff es (Async a)
521 -> Eff es (Async a)
537−liftAsyncWithUnmask fork action = do
522+liftAsyncWithUnmask fork action = unsafeEff $ \es -> do
538− unsafeWithLiftMapIO $ \liftMap -> unsafeEff $ \es -> do
539− esA <- cloneEnv es
523+ esA <- cloneEnv es
540− fork $ \unmask -> unEff (action $ liftMap unmask) esA
524+ fork $ \unmask -> unEff (action $ unsafeLiftMapIO unmask) esA
542liftWithAsync
526liftWithAsync
543 :: (IO a -> (Async a -> IO b) -> IO b)
527 :: (IO a -> (Async a -> IO b) -> IO b)
@@ -554,8 +538,7 @@ liftWithAsyncWithUnmask
554 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
538 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
555 -> (Async a -> Eff es b)
539 -> (Async a -> Eff es b)
556 -> Eff es b
540 -> Eff es b
557−liftWithAsyncWithUnmask withA action k = do
541+liftWithAsyncWithUnmask withA action k = unsafeEff $ \es -> do
558− unsafeWithLiftMapIO $ \liftMap -> unsafeEff $ \es -> do
559− esA <- cloneEnv es
542+ esA <- cloneEnv es
560− withA (\unmask -> unEff (action $ liftMap unmask) esA)
543+ withA (\unmask -> unEff (action $ unsafeLiftMapIO unmask) esA)
561− (\a -> unEff (k a) es)
544+ (\a -> unEff (k a) es)