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