@@ -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,49 +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.
91−data AsyncE :: Effect where
94−runAsyncE :: IOE :> es => Eff (AsyncE : es) a -> Eff es a
95−runAsyncE = evalEffect (IdE AsyncE)
97−----------------------------------------
100-- | Lifted 'A.async'.
88-- | Lifted 'A.async'.
101−async :: AsyncE :> es => Eff es a -> Eff es (Async a)
89+async :: Concurrent :> es => Eff es a -> Eff es (Async a)
102async = liftAsync A.async
90async = liftAsync A.async
104-- | Lifted 'A.asyncBound'.
92-- | Lifted 'A.asyncBound'.
105−asyncBound :: AsyncE :> es => Eff es a -> Eff es (Async a)
93+asyncBound :: Concurrent :> es => Eff es a -> Eff es (Async a)
106asyncBound = liftAsync A.asyncBound
94asyncBound = liftAsync A.asyncBound
108-- | Lifted 'A.asyncOn'.
96-- | Lifted 'A.asyncOn'.
109−asyncOn :: AsyncE :> es => Int -> Eff es a -> Eff es (Async a)
97+asyncOn :: Concurrent :> es => Int -> Eff es a -> Eff es (Async a)
110asyncOn cpu = liftAsync (A.asyncOn cpu)
98asyncOn cpu = liftAsync (A.asyncOn cpu)
112-- | Lifted 'A.asyncWithUnmask'.
100-- | Lifted 'A.asyncWithUnmask'.
113asyncWithUnmask
101asyncWithUnmask
114− :: AsyncE :> es
102+ :: Concurrent :> es
115 => ((forall b. Eff es b -> Eff es b) -> Eff es a)
103 => ((forall b. Eff es b -> Eff es b) -> Eff es a)
116 -> Eff es (Async a)
104 -> Eff es (Async a)
117asyncWithUnmask = liftAsyncWithUnmask A.asyncWithUnmask
105asyncWithUnmask = liftAsyncWithUnmask A.asyncWithUnmask
119-- | Lifted 'A.asyncOnWithUnmask'.
107-- | Lifted 'A.asyncOnWithUnmask'.
120asyncOnWithUnmask
108asyncOnWithUnmask
121− :: AsyncE :> es
109+ :: Concurrent :> es
123 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
111 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
124 -> Eff es (Async a)
112 -> Eff es (Async a)
@@ -126,7 +114,7 @@ asyncOnWithUnmask cpu = liftAsyncWithUnmask (A.asyncOnWithUnmask cpu)
127-- | Lifted 'A.withAsync'.
115-- | Lifted 'A.withAsync'.
129− :: AsyncE :> es
117+ :: Concurrent :> es
130 => Eff es a
118 => Eff es a
131 -> (Async a -> Eff es b)
119 -> (Async a -> Eff es b)
132 -> Eff es b
120 -> Eff es b
@@ -134,7 +122,7 @@ withAsync = liftWithAsync A.withAsync
135-- | Lifted 'A.withAsyncBound'.
123-- | Lifted 'A.withAsyncBound'.
136withAsyncBound
124withAsyncBound
137− :: AsyncE :> es
125+ :: Concurrent :> es
138 => Eff es a
126 => Eff es a
139 -> (Async a -> Eff es b)
127 -> (Async a -> Eff es b)
140 -> Eff es b
128 -> Eff es b
@@ -142,7 +130,7 @@ withAsyncBound = liftWithAsync A.withAsyncBound
143-- | Lifted 'A.withAsyncOn'.
131-- | Lifted 'A.withAsyncOn'.
144withAsyncOn
132withAsyncOn
145− :: AsyncE :> es
133+ :: Concurrent :> es
147 -> Eff es a
135 -> Eff es a
148 -> (Async a -> Eff es b)
136 -> (Async a -> Eff es b)
@@ -151,7 +139,7 @@ withAsyncOn cpu = liftWithAsync (A.withAsyncOn cpu)
152-- | Lifted 'A.withAsyncWithUnmask'.
140-- | Lifted 'A.withAsyncWithUnmask'.
153withAsyncWithUnmask
141withAsyncWithUnmask
154− :: AsyncE :> es
142+ :: Concurrent :> es
155 => ((forall c. Eff es c -> Eff es c) -> Eff es a)
143 => ((forall c. Eff es c -> Eff es c) -> Eff es a)
156 -> (Async a -> Eff es b)
144 -> (Async a -> Eff es b)
157 -> Eff es b
145 -> Eff es b
@@ -159,7 +147,7 @@ withAsyncWithUnmask = liftWithAsyncWithUnmask A.withAsyncWithUnmask
160-- | Lifted 'A.withAsyncOnWithUnmask'.
148-- | Lifted 'A.withAsyncOnWithUnmask'.
161withAsyncOnWithUnmask
149withAsyncOnWithUnmask
162− :: AsyncE :> es
150+ :: Concurrent :> es
164 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
152 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
165 -> (Async a -> Eff es b)
153 -> (Async a -> Eff es b)
@@ -167,60 +155,60 @@ withAsyncOnWithUnmask
167withAsyncOnWithUnmask cpu = liftWithAsyncWithUnmask (A.withAsyncOnWithUnmask cpu)
155withAsyncOnWithUnmask cpu = liftWithAsyncWithUnmask (A.withAsyncOnWithUnmask cpu)
169-- | Lifted 'A.wait'.
157-- | Lifted 'A.wait'.
170−wait :: AsyncE :> es => Async a -> Eff es a
158+wait :: Concurrent :> es => Async a -> Eff es a
171wait = unsafeEff_ . A.wait
159wait = unsafeEff_ . A.wait
173-- | Lifted 'A.poll'.
161-- | Lifted 'A.poll'.
175− :: AsyncE :> es
163+ :: Concurrent :> es
176 => Async a
164 => Async a
177 -> Eff es (Maybe (Either SomeException a))
165 -> Eff es (Maybe (Either SomeException a))
178poll = unsafeEff_ . A.poll
166poll = unsafeEff_ . A.poll
180-- | Lifted 'A.cancel'.
168-- | Lifted 'A.cancel'.
181−cancel :: AsyncE :> es => Async a -> Eff es ()
169+cancel :: Concurrent :> es => Async a -> Eff es ()
182cancel = unsafeEff_ . A.cancel
170cancel = unsafeEff_ . A.cancel
184-- | Lifted 'A.cancelWith'.
172-- | Lifted 'A.cancelWith'.
185−cancelWith :: (Exception e, AsyncE :> es) => Async a -> e -> Eff es ()
173+cancelWith :: (Exception e, Concurrent :> es) => Async a -> e -> Eff es ()
186cancelWith a = unsafeEff_ . A.cancelWith a
174cancelWith a = unsafeEff_ . A.cancelWith a
188-- | Lifted 'A.uninterruptibleCancel'.
176-- | Lifted 'A.uninterruptibleCancel'.
189−uninterruptibleCancel :: AsyncE :> es => Async a -> Eff es ()
177+uninterruptibleCancel :: Concurrent :> es => Async a -> Eff es ()
190uninterruptibleCancel = unsafeEff_ . A.uninterruptibleCancel
178uninterruptibleCancel = unsafeEff_ . A.uninterruptibleCancel
192-- | Lifted 'A.waitCatch'.
180-- | Lifted 'A.waitCatch'.
194− :: AsyncE :> es
182+ :: Concurrent :> es
195 => Async a
183 => Async a
196 -> Eff es (Either SomeException a)
184 -> Eff es (Either SomeException a)
197waitCatch = unsafeEff_ . A.waitCatch
185waitCatch = unsafeEff_ . A.waitCatch
199-- | Lifted 'A.waitAny'.
187-- | Lifted 'A.waitAny'.
200−waitAny :: AsyncE :> es => [Async a] -> Eff es (Async a, a)
188+waitAny :: Concurrent :> es => [Async a] -> Eff es (Async a, a)
201waitAny = unsafeEff_ . A.waitAny
189waitAny = unsafeEff_ . A.waitAny
203-- | Lifted 'A.waitAnyCatch'.
191-- | Lifted 'A.waitAnyCatch'.
204waitAnyCatch
192waitAnyCatch
205− :: AsyncE :> es
193+ :: Concurrent :> es
206 => [Async a]
194 => [Async a]
207 -> Eff es (Async a, Either SomeException a)
195 -> Eff es (Async a, Either SomeException a)
208waitAnyCatch = unsafeEff_ . A.waitAnyCatch
196waitAnyCatch = unsafeEff_ . A.waitAnyCatch
210-- | Lifted 'A.waitAnyCancel'.
198-- | Lifted 'A.waitAnyCancel'.
211−waitAnyCancel :: AsyncE :> es => [Async a] -> Eff es (Async a, a)
199+waitAnyCancel :: Concurrent :> es => [Async a] -> Eff es (Async a, a)
212waitAnyCancel = unsafeEff_ . A.waitAnyCancel
200waitAnyCancel = unsafeEff_ . A.waitAnyCancel
214-- | Lifted 'A.waitAnyCatchCancel'.
202-- | Lifted 'A.waitAnyCatchCancel'.
215waitAnyCatchCancel
203waitAnyCatchCancel
216− :: AsyncE :> es
204+ :: Concurrent :> es
217 => [Async a]
205 => [Async a]
218 -> Eff es (Async a, Either SomeException a)
206 -> Eff es (Async a, Either SomeException a)
219waitAnyCatchCancel = unsafeEff_ . A.waitAnyCatchCancel
207waitAnyCatchCancel = unsafeEff_ . A.waitAnyCatchCancel
221-- | Lifted 'A.waitEither'.
209-- | Lifted 'A.waitEither'.
222waitEither
210waitEither
223− :: AsyncE :> es
211+ :: Concurrent :> es
224 => Async a
212 => Async a
225 -> Async b
213 -> Async b
226 -> Eff es (Either a b)
214 -> Eff es (Either a b)
@@ -228,7 +216,7 @@ waitEither a b = unsafeEff_ $ A.waitEither a b
229-- | Lifted 'A.waitEitherCatch'.
217-- | Lifted 'A.waitEitherCatch'.
230waitEitherCatch
218waitEitherCatch
231− :: AsyncE :> es
219+ :: Concurrent :> es
232 => Async a
220 => Async a
233 -> Async b
221 -> Async b
234 -> Eff es (Either (Either SomeException a) (Either SomeException b))
222 -> Eff es (Either (Either SomeException a) (Either SomeException b))
@@ -236,7 +224,7 @@ waitEitherCatch a b = unsafeEff_ $ A.waitEitherCatch a b
237-- | Lifted 'A.waitEitherCancel'.
225-- | Lifted 'A.waitEitherCancel'.
238waitEitherCancel
226waitEitherCancel
239− :: AsyncE :> es
227+ :: Concurrent :> es
240 => Async a
228 => Async a
241 -> Async b
229 -> Async b
242 -> Eff es (Either a b)
230 -> Eff es (Either a b)
@@ -244,53 +232,53 @@ waitEitherCancel a b = unsafeEff_ $ A.waitEitherCancel a b
245-- | Lifted 'A.waitEitherCatchCancel'.
233-- | Lifted 'A.waitEitherCatchCancel'.
246waitEitherCatchCancel
234waitEitherCatchCancel
247− :: AsyncE :> es
235+ :: Concurrent :> es
248 => Async a
236 => Async a
249 -> Async b
237 -> Async b
250 -> Eff es (Either (Either SomeException a) (Either SomeException b))
238 -> Eff es (Either (Either SomeException a) (Either SomeException b))
251waitEitherCatchCancel a b = unsafeEff_ $ A.waitEitherCatch a b
239waitEitherCatchCancel a b = unsafeEff_ $ A.waitEitherCatch a b
253-- | Lifted 'A.waitEither_'.
241-- | Lifted 'A.waitEither_'.
254−waitEither_ :: AsyncE :> es => Async a -> Async b -> Eff es ()
242+waitEither_ :: Concurrent :> es => Async a -> Async b -> Eff es ()
255waitEither_ a b = unsafeEff_ $ A.waitEither_ a b
243waitEither_ a b = unsafeEff_ $ A.waitEither_ a b
257-- | Lifted 'A.waitBoth'.
245-- | Lifted 'A.waitBoth'.
258−waitBoth :: AsyncE :> es => Async a -> Async b -> Eff es (a, b)
246+waitBoth :: Concurrent :> es => Async a -> Async b -> Eff es (a, b)
259waitBoth a b = unsafeEff_ $ A.waitBoth a b
247waitBoth a b = unsafeEff_ $ A.waitBoth a b
261-- | Lifted 'A.link'.
249-- | Lifted 'A.link'.
262−link :: AsyncE :> es => Async a -> Eff es ()
250+link :: Concurrent :> es => Async a -> Eff es ()
263link = unsafeEff_ . A.link
251link = unsafeEff_ . A.link
265-- | Lifted 'A.linkOnly'.
253-- | Lifted 'A.linkOnly'.
266−linkOnly :: AsyncE :> es => (SomeException -> Bool) -> Async a -> Eff es ()
254+linkOnly :: Concurrent :> es => (SomeException -> Bool) -> Async a -> Eff es ()
267linkOnly f = unsafeEff_ . A.linkOnly f
255linkOnly f = unsafeEff_ . A.linkOnly f
269-- | Lifted 'A.link2'.
257-- | Lifted 'A.link2'.
270−link2 :: AsyncE :> es => Async a -> Async b -> Eff es ()
258+link2 :: Concurrent :> es => Async a -> Async b -> Eff es ()
271link2 a b = unsafeEff_ $ A.link2 a b
259link2 a b = unsafeEff_ $ A.link2 a b
273-- | Lifted 'A.link2Only'.
261-- | Lifted 'A.link2Only'.
274−link2Only :: AsyncE :> es => (SomeException -> Bool) -> Async a -> Async b -> Eff es ()
262+link2Only :: Concurrent :> es => (SomeException -> Bool) -> Async a -> Async b -> Eff es ()
275link2Only f a b = unsafeEff_ $ A.link2Only f a b
263link2Only f a b = unsafeEff_ $ A.link2Only f a b
277-- | Lifted 'A.race'.
265-- | Lifted 'A.race'.
278−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)
279race ma mb = unsafeEff $ \es -> do
267race ma mb = unsafeEff $ \es -> do
280 A.race (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
268 A.race (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
282-- | Lifted 'A.race_'.
270-- | Lifted 'A.race_'.
283−race_ :: AsyncE :> es => Eff es a -> Eff es b -> Eff es ()
271+race_ :: Concurrent :> es => Eff es a -> Eff es b -> Eff es ()
284race_ ma mb = unsafeEff $ \es -> do
272race_ ma mb = unsafeEff $ \es -> do
285 A.race_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
273 A.race_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
287-- | Lifted 'A.concurrently'.
275-- | Lifted 'A.concurrently'.
288−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)
289concurrently ma mb = unsafeEff $ \es -> do
277concurrently ma mb = unsafeEff $ \es -> do
290 A.concurrently (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
278 A.concurrently (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
292-- | Lifted 'A.concurrently_'.
280-- | Lifted 'A.concurrently_'.
293−concurrently_ :: AsyncE :> es => Eff es a -> Eff es b -> Eff es ()
281+concurrently_ :: Concurrent :> es => Eff es a -> Eff es b -> Eff es ()
294concurrently_ ma mb = unsafeEff $ \es -> do
282concurrently_ ma mb = unsafeEff $ \es -> do
295 A.concurrently_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
283 A.concurrently_ (unEff ma =<< cloneEnv es) (unEff mb =<< cloneEnv es)
@@ -300,7 +288,7 @@ concurrently_ ma mb = unsafeEff $ \es -> do
301-- | Lifted 'A.mapConcurrently'.
289-- | Lifted 'A.mapConcurrently'.
302mapConcurrently
290mapConcurrently
303− :: (Traversable f, AsyncE :> es)
291+ :: (Traversable f, Concurrent :> es)
304 => (a -> Eff es b)
292 => (a -> Eff es b)
306 -> Eff es (f b)
294 -> Eff es (f b)
@@ -309,7 +297,7 @@ mapConcurrently f t = unsafeEff $ \es -> do
310-- | Lifted 'A.mapConcurrently_'.
298-- | Lifted 'A.mapConcurrently_'.
311mapConcurrently_
299mapConcurrently_
312− :: (Foldable f, AsyncE :> es)
300+ :: (Foldable f, Concurrent :> es)
313 => (a -> Eff es b)
301 => (a -> Eff es b)
315 -> Eff es ()
303 -> Eff es ()
@@ -318,7 +306,7 @@ mapConcurrently_ f t = unsafeEff $ \es -> do
319-- | Lifted 'A.forConcurrently'.
307-- | Lifted 'A.forConcurrently'.
320forConcurrently
308forConcurrently
321− :: (Traversable f, AsyncE :> es)
309+ :: (Traversable f, Concurrent :> es)
323 -> (a -> Eff es b)
311 -> (a -> Eff es b)
324 -> Eff es (f b)
312 -> Eff es (f b)
@@ -327,7 +315,7 @@ forConcurrently t f = unsafeEff $ \es -> do
328-- | Lifted 'A.forConcurrently_'.
316-- | Lifted 'A.forConcurrently_'.
329forConcurrently_
317forConcurrently_
330− :: (Foldable f, AsyncE :> es)
318+ :: (Foldable f, Concurrent :> es)
332 -> (a -> Eff es b)
320 -> (a -> Eff es b)
333 -> Eff es ()
321 -> Eff es ()
@@ -335,12 +323,12 @@ forConcurrently_ t f = unsafeEff $ \es -> do
335 U.forConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
323 U.forConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
337-- | Lifted 'A.replicateConcurrently'.
325-- | Lifted 'A.replicateConcurrently'.
338−replicateConcurrently :: AsyncE :> es => Int -> Eff es a -> Eff es [a]
326+replicateConcurrently :: Concurrent :> es => Int -> Eff es a -> Eff es [a]
339replicateConcurrently n f = unsafeEff $ \es -> do
327replicateConcurrently n f = unsafeEff $ \es -> do
340 U.replicateConcurrently n (unEff f =<< cloneEnv es)
328 U.replicateConcurrently n (unEff f =<< cloneEnv es)
342-- | Lifted 'A.replicateConcurrently_'.
330-- | Lifted 'A.replicateConcurrently_'.
343−replicateConcurrently_ :: AsyncE :> es => Int -> Eff es a -> Eff es ()
331+replicateConcurrently_ :: Concurrent :> es => Int -> Eff es a -> Eff es ()
344replicateConcurrently_ n f = unsafeEff $ \es -> do
332replicateConcurrently_ n f = unsafeEff $ \es -> do
345 U.replicateConcurrently_ n (unEff f =<< cloneEnv es)
333 U.replicateConcurrently_ n (unEff f =<< cloneEnv es)
@@ -349,7 +337,7 @@ replicateConcurrently_ n f = unsafeEff $ \es -> do
350-- | Lifted 'U.pooledMapConcurrentlyN'.
338-- | Lifted 'U.pooledMapConcurrentlyN'.
351pooledMapConcurrentlyN
339pooledMapConcurrentlyN
352− :: (AsyncE :> es, Traversable t)
340+ :: (Concurrent :> es, Traversable t)
354 -> (a -> Eff es b)
342 -> (a -> Eff es b)
@@ -359,7 +347,7 @@ pooledMapConcurrentlyN threads f t = unsafeEff $ \es -> do
360-- | Lifted 'U.pooledMapConcurrently'.
348-- | Lifted 'U.pooledMapConcurrently'.
361pooledMapConcurrently
349pooledMapConcurrently
362− :: (AsyncE :> es, Traversable t)
350+ :: (Concurrent :> es, Traversable t)
363 => (a -> Eff es b)
351 => (a -> Eff es b)
365 -> Eff es (t b)
353 -> Eff es (t b)
@@ -368,7 +356,7 @@ pooledMapConcurrently f t = unsafeEff $ \es -> do
369-- | Lifted 'U.pooledMapConcurrentlyN'.
357-- | Lifted 'U.pooledMapConcurrentlyN'.
370pooledMapConcurrentlyN_
358pooledMapConcurrentlyN_
371− :: (AsyncE :> es, Foldable f)
359+ :: (Concurrent :> es, Foldable f)
373 -> (a -> Eff es b)
361 -> (a -> Eff es b)
@@ -378,7 +366,7 @@ pooledMapConcurrentlyN_ threads f t = unsafeEff $ \es -> do
379-- | Lifted 'U.pooledMapConcurrently_'.
367-- | Lifted 'U.pooledMapConcurrently_'.
380pooledMapConcurrently_
368pooledMapConcurrently_
381− :: (AsyncE :> es, Foldable f)
369+ :: (Concurrent :> es, Foldable f)
382 => (a -> Eff es b)
370 => (a -> Eff es b)
384 -> Eff es ()
372 -> Eff es ()
@@ -387,7 +375,7 @@ pooledMapConcurrently_ f t = unsafeEff $ \es -> do
388-- | Lifted 'U.pooledForConcurrentlyN'.
376-- | Lifted 'U.pooledForConcurrentlyN'.
389pooledForConcurrentlyN
377pooledForConcurrentlyN
390− :: (AsyncE :> es, Traversable t)
378+ :: (Concurrent :> es, Traversable t)
393 -> (a -> Eff es b)
381 -> (a -> Eff es b)
@@ -397,7 +385,7 @@ pooledForConcurrentlyN threads t f = unsafeEff $ \es -> do
398-- | Lifted 'U.pooledForConcurrently'.
386-- | Lifted 'U.pooledForConcurrently'.
399pooledForConcurrently
387pooledForConcurrently
400− :: (AsyncE :> es, Traversable t)
388+ :: (Concurrent :> es, Traversable t)
402 -> (a -> Eff es b)
390 -> (a -> Eff es b)
403 -> Eff es (t b)
391 -> Eff es (t b)
@@ -406,7 +394,7 @@ pooledForConcurrently t f = unsafeEff $ \es -> do
407-- | Lifted 'U.pooledForConcurrentlyN'.
395-- | Lifted 'U.pooledForConcurrentlyN'.
408pooledForConcurrentlyN_
396pooledForConcurrentlyN_
409− :: (AsyncE :> es, Foldable f)
397+ :: (Concurrent :> es, Foldable f)
412 -> (a -> Eff es b)
400 -> (a -> Eff es b)
@@ -416,7 +404,7 @@ pooledForConcurrentlyN_ threads t f = unsafeEff $ \es -> do
417-- | Lifted 'U.pooledForConcurrently_'.
405-- | Lifted 'U.pooledForConcurrently_'.
418pooledForConcurrently_
406pooledForConcurrently_
419− :: (AsyncE :> es, Foldable f)
407+ :: (Concurrent :> es, Foldable f)
421 -> (a -> Eff es b)
409 -> (a -> Eff es b)
422 -> Eff es ()
410 -> Eff es ()
@@ -424,22 +412,22 @@ pooledForConcurrently_ t f = unsafeEff $ \es -> do
424 U.pooledForConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
412 U.pooledForConcurrently_ t (\a -> unEff (f a) =<< cloneEnv es)
426-- | Lifted 'U.pooledReplicateConcurrentlyN'.
414-- | Lifted 'U.pooledReplicateConcurrentlyN'.
427−pooledReplicateConcurrentlyN :: AsyncE :> es => Int -> Int -> Eff es a -> Eff es [a]
415+pooledReplicateConcurrentlyN :: Concurrent :> es => Int -> Int -> Eff es a -> Eff es [a]
428pooledReplicateConcurrentlyN threads n f = unsafeEff $ \es -> do
416pooledReplicateConcurrentlyN threads n f = unsafeEff $ \es -> do
429 U.pooledReplicateConcurrentlyN threads n (unEff f =<< cloneEnv es)
417 U.pooledReplicateConcurrentlyN threads n (unEff f =<< cloneEnv es)
431-- | Lifted 'U.pooledReplicateConcurrently'.
419-- | Lifted 'U.pooledReplicateConcurrently'.
432−pooledReplicateConcurrently :: AsyncE :> es => Int -> Eff es a -> Eff es [a]
420+pooledReplicateConcurrently :: Concurrent :> es => Int -> Eff es a -> Eff es [a]
433pooledReplicateConcurrently n f = unsafeEff $ \es -> do
421pooledReplicateConcurrently n f = unsafeEff $ \es -> do
434 U.pooledReplicateConcurrently n (unEff f =<< cloneEnv es)
422 U.pooledReplicateConcurrently n (unEff f =<< cloneEnv es)
436-- | Lifted 'U.pooledReplicateConcurrentlyN_'.
424-- | Lifted 'U.pooledReplicateConcurrentlyN_'.
437−pooledReplicateConcurrentlyN_ :: AsyncE :> es => Int -> Int -> Eff es a -> Eff es ()
425+pooledReplicateConcurrentlyN_ :: Concurrent :> es => Int -> Int -> Eff es a -> Eff es ()
438pooledReplicateConcurrentlyN_ threads n f = unsafeEff $ \es -> do
426pooledReplicateConcurrentlyN_ threads n f = unsafeEff $ \es -> do
439 U.pooledReplicateConcurrentlyN_ threads n (unEff f =<< cloneEnv es)
427 U.pooledReplicateConcurrentlyN_ threads n (unEff f =<< cloneEnv es)
441-- | Lifted 'U.pooledReplicateConcurrently_'.
429-- | Lifted 'U.pooledReplicateConcurrently_'.
442−pooledReplicateConcurrently_ :: AsyncE :> es => Int -> Eff es a -> Eff es ()
430+pooledReplicateConcurrently_ :: Concurrent :> es => Int -> Eff es a -> Eff es ()
443pooledReplicateConcurrently_ n f = unsafeEff $ \es -> do
431pooledReplicateConcurrently_ n f = unsafeEff $ \es -> do
444 U.pooledReplicateConcurrently_ n (unEff f =<< cloneEnv es)
432 U.pooledReplicateConcurrently_ n (unEff f =<< cloneEnv es)
@@ -447,7 +435,7 @@ pooledReplicateConcurrently_ n f = unsafeEff $ \es -> do
449-- | Lifted 'U.Conc'.
437-- | Lifted 'U.Conc'.
450−data Conc es a where
438+data Conc :: [Effect] -> Type -> Type where
451 Action :: Eff es a -> Conc es a
439 Action :: Eff es a -> Conc es a
452 Apply :: Conc es (v -> a) -> Conc es v -> Conc es a
440 Apply :: Conc es (v -> a) -> Conc es v -> Conc es a
453 LiftA2 :: (x -> y -> a) -> Conc es x -> Conc es y -> Conc es a
441 LiftA2 :: (x -> y -> a) -> Conc es x -> Conc es y -> Conc es a
@@ -479,7 +467,7 @@ conc :: Eff es a -> Conc es a
479conc = Action
467conc = Action
481-- | Lifted 'U.runConc'.
469-- | Lifted 'U.runConc'.
482−runConc :: AsyncE :> es => Conc es a -> Eff es a
470+runConc :: Concurrent :> es => Conc es a -> Eff es a
483runConc m = unsafeEff $ \es -> U.runConc (unliftConc es m)
471runConc m = unsafeEff $ \es -> U.runConc (unliftConc es m)
485 unliftConc :: Env es -> Conc es a -> U.Conc IO a
473 unliftConc :: Env es -> Conc es a -> U.Conc IO a
@@ -500,20 +488,20 @@ newtype Concurrently es a = Concurrently { runConcurrently :: Eff es a }
500instance Functor (Concurrently es) where
488instance Functor (Concurrently es) where
501 fmap f (Concurrently a) = Concurrently (fmap f a)
489 fmap f (Concurrently a) = Concurrently (fmap f a)
503−instance AsyncE :> es => Applicative (Concurrently es) where
491+instance Concurrent :> es => Applicative (Concurrently es) where
504 pure = Concurrently . pure
492 pure = Concurrently . pure
505 Concurrently fs <*> Concurrently as =
493 Concurrently fs <*> Concurrently as =
506 Concurrently ((\(f, a) -> f a) <$> concurrently fs as)
494 Concurrently ((\(f, a) -> f a) <$> concurrently fs as)
508−instance AsyncE :> es => Alternative (Concurrently es) where
496+instance Concurrent :> es => Alternative (Concurrently es) where
509 empty = Concurrently . unsafeEff_ . forever $ threadDelay maxBound
497 empty = Concurrently . unsafeEff_ . forever $ threadDelay maxBound
510 Concurrently as <|> Concurrently bs =
498 Concurrently as <|> Concurrently bs =
511 Concurrently (either id id <$> race as bs)
499 Concurrently (either id id <$> race as bs)
513−instance (AsyncE :> es, Semigroup a) => Semigroup (Concurrently es a) where
501+instance (Concurrent :> es, Semigroup a) => Semigroup (Concurrently es a) where
514 (<>) = liftA2 (<>)
502 (<>) = liftA2 (<>)
516−instance (AsyncE :> es, Monoid a) => Monoid (Concurrently es a) where
504+instance (Concurrent :> es, Monoid a) => Monoid (Concurrently es a) where
517 mempty = pure mempty
505 mempty = pure mempty
519----------------------------------------
507----------------------------------------
@@ -531,10 +519,9 @@ liftAsyncWithUnmask
531 :: (((forall b. IO b -> IO b) -> IO a) -> IO (Async a))
519 :: (((forall b. IO b -> IO b) -> IO a) -> IO (Async a))
532 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
520 -> ((forall b. Eff es b -> Eff es b) -> Eff es a)
533 -> Eff es (Async a)
521 -> Eff es (Async a)
534−liftAsyncWithUnmask fork action = do
522+liftAsyncWithUnmask fork action = unsafeEff $ \es -> do
535− unsafeWithLiftMapIO $ \liftMap -> unsafeEff $ \es -> do
536− esA <- cloneEnv es
523+ esA <- cloneEnv es
537− fork $ \unmask -> unEff (action $ liftMap unmask) esA
524+ fork $ \unmask -> unEff (action $ unsafeLiftMapIO unmask) esA
539liftWithAsync
526liftWithAsync
540 :: (IO a -> (Async a -> IO b) -> IO b)
527 :: (IO a -> (Async a -> IO b) -> IO b)
@@ -551,8 +538,7 @@ liftWithAsyncWithUnmask
551 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
538 -> ((forall c. Eff es c -> Eff es c) -> Eff es a)
552 -> (Async a -> Eff es b)
539 -> (Async a -> Eff es b)
553 -> Eff es b
540 -> Eff es b
554−liftWithAsyncWithUnmask withA action k = do
541+liftWithAsyncWithUnmask withA action k = unsafeEff $ \es -> do
555− unsafeWithLiftMapIO $ \liftMap -> unsafeEff $ \es -> do
556− esA <- cloneEnv es
542+ esA <- cloneEnv es
557− withA (\unmask -> unEff (action $ liftMap unmask) esA)
543+ withA (\unmask -> unEff (action $ unsafeLiftMapIO unmask) esA)
558− (\a -> unEff (k a) es)
544+ (\a -> unEff (k a) es)