{-# options_haddock prune #-}
module Polysemy.Conc.Interpreter.Stack where
import Polysemy.Conc.Effect.Gate (Gates)
import Polysemy.Conc.Effect.Mask (Mask, UninterruptibleMask)
import Polysemy.Conc.Effect.Race (Race)
import Polysemy.Conc.Interpreter.Gate (interpretGates)
import Polysemy.Conc.Interpreter.Mask (interpretMaskFinal, interpretUninterruptibleMaskFinal)
import Polysemy.Conc.Interpreter.Race (interpretRace)
type ConcStack =
[
UninterruptibleMask,
Mask,
Gates,
Race,
Async,
Resource,
Embed IO,
Final IO
]
runConc ::
Sem ConcStack a ->
IO a
runConc :: forall a. Sem ConcStack a -> IO a
runConc =
Sem '[Final IO] a -> IO a
forall (m :: * -> *) a. Monad m => Sem '[Final m] a -> m a
runFinal (Sem '[Final IO] a -> IO a)
-> (Sem ConcStack a -> Sem '[Final IO] a)
-> Sem ConcStack a
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall (m :: * -> *) (r :: [(* -> *) -> * -> *]) a.
(Member (Final m) r, Functor m) =>
Sem (Embed m : r) a -> Sem r a
embedToFinal @IO (Sem '[Embed IO, Final IO] a -> Sem '[Final IO] a)
-> (Sem ConcStack a -> Sem '[Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem '[Resource, Embed IO, Final IO] a
-> Sem '[Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]) a.
Member (Final IO) r =>
Sem (Resource : r) a -> Sem r a
resourceToIOFinal (Sem '[Resource, Embed IO, Final IO] a
-> Sem '[Embed IO, Final IO] a)
-> (Sem ConcStack a -> Sem '[Resource, Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Embed IO, Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem '[Async, Resource, Embed IO, Final IO] a
-> Sem '[Resource, Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]) a.
Member (Final IO) r =>
Sem (Async : r) a -> Sem r a
asyncToIOFinal (Sem '[Async, Resource, Embed IO, Final IO] a
-> Sem '[Resource, Embed IO, Final IO] a)
-> (Sem ConcStack a
-> Sem '[Async, Resource, Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Resource, Embed IO, Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem '[Race, Async, Resource, Embed IO, Final IO] a
-> Sem '[Async, Resource, Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]).
Member (Final IO) r =>
InterpreterFor Race r
interpretRace (Sem '[Race, Async, Resource, Embed IO, Final IO] a
-> Sem '[Async, Resource, Embed IO, Final IO] a)
-> (Sem ConcStack a
-> Sem '[Race, Async, Resource, Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Async, Resource, Embed IO, Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem '[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
-> Sem '[Race, Async, Resource, Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]).
Member (Embed IO) r =>
InterpreterFor (Scoped_ Gate) r
interpretGates (Sem '[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
-> Sem '[Race, Async, Resource, Embed IO, Final IO] a)
-> (Sem ConcStack a
-> Sem
'[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Race, Async, Resource, Embed IO, Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem
'[Mask, Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
-> Sem '[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]).
Member (Final IO) r =>
InterpreterFor Mask r
interpretMaskFinal (Sem
'[Mask, Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
-> Sem
'[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a)
-> (Sem ConcStack a
-> Sem
'[Mask, Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a)
-> Sem ConcStack a
-> Sem '[Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem ConcStack a
-> Sem
'[Mask, Scoped_ Gate, Race, Async, Resource, Embed IO, Final IO] a
forall (r :: [(* -> *) -> * -> *]).
Member (Final IO) r =>
InterpreterFor Mask r
interpretUninterruptibleMaskFinal