-
I'm trying to write an interpretable (i.e. dynamic) concurrent effect. The effect type should be parametric on synchronization types, like So far I have this: data Concurrent' threadHandle m a where
Async :: m a -> Concurrent' threadHandle m (threadHandle a)
Await :: threadHandle a -> Concurrent' threadHandle m a
type instance DispatchOf (Concurrent' threadHandle) = Dynamic
async' :: Concurrent' threadHandle :> es => Eff es a -> Eff es (threadHandle a)
async' = send . Async
await' :: Concurrent' threadHandle :> es => threadHandle a -> Eff es a
await' = send . Await To handle this, I think I need runConcurrent'IO :: IOE :> es => Eff (Concurrent' Async : es) a -> Eff es a
runConcurrent'IO = reinterpret runConcurrent'IO $ \_ -> \case
Async action -> undefined
Await handle -> liftIO (A.wait handle) But I can't figure out what to put in the Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You need to use localUnliftIO with ConcUnlift strategy (Ephemeral with Limited 1 will work). Have a look at haddock if these for more info. There's also an example of a higher order effect in the introduction section of Effectful.Dispatch.Dynamic. |
Beta Was this translation helpful? Give feedback.
You need to use localUnliftIO with ConcUnlift strategy (Ephemeral with Limited 1 will work).
Have a look at haddock if these for more info. There's also an example of a higher order effect in the introduction section of Effectful.Dispatch.Dynamic.