{-# LANGUAGE DerivingVia #-}
{-# OPTIONS_HADDOCK not-home #-}
module Control.Effect.Internal.Conc where

import Control.Effect
import Control.Effect.Unlift
import Control.Effect.Newtype
import Control.Effect.Internal.Newtype
import Control.Effect.Internal.Utils

-- For coercion purposes

import Control.Effect.Internal.Derive
import Control.Effect.Carrier.Internal.Interpret
import Control.Effect.Carrier.Internal.Compose

-- | An effect for concurrent execution.

newtype Conc m a = Conc (Unlift IO m a)
  deriving Conc z x -> UnwrappedEff Conc z x
(forall (z :: * -> *) x. Conc z x -> UnwrappedEff Conc z x)
-> EffNewtype Conc
forall (z :: * -> *) x. Conc z x -> UnwrappedEff Conc z x
forall (e :: Effect).
(forall (z :: * -> *) x. e z x -> UnwrappedEff e z x)
-> EffNewtype e
unwrapped :: Conc z x -> UnwrappedEff Conc z x
$cunwrapped :: forall (z :: * -> *) x. Conc z x -> UnwrappedEff Conc z x
EffNewtype via Conc `WrapperOf` Unlift IO

unliftConc :: Eff Conc m => ((forall x. m x -> IO x) -> IO a) -> m a
unliftConc :: ((forall x. m x -> IO x) -> IO a) -> m a
unliftConc (forall x. m x -> IO x) -> IO a
main = (Unlift IO Any Any -> Conc Any Any)
-> WrapC (Unlift IO) Conc m a -> m a
forall (e :: Effect) (m :: * -> *) (unwrappedE :: Effect)
       (z :: * -> *) x a.
(Member e (Derivs m), Carrier m, Coercible unwrappedE e) =>
(unwrappedE z x -> e z x) -> WrapC unwrappedE e m a -> m a
wrapWith Unlift IO Any Any -> Conc Any Any
forall (m :: * -> *) a. Unlift IO m a -> Conc m a
Conc (WrapC (Unlift IO) Conc m a -> m a)
-> WrapC (Unlift IO) Conc m a -> m a
forall a b. (a -> b) -> a -> b
$ ((forall x. WrapC (Unlift IO) Conc m x -> IO x) -> IO a)
-> WrapC (Unlift IO) Conc m a
forall (b :: * -> *) (m :: * -> *) a.
Eff (Unlift b) m =>
((forall x. m x -> b x) -> b a) -> m a
unlift (\forall x. WrapC (Unlift IO) Conc m x -> IO x
lower -> (forall x. m x -> IO x) -> IO a
main (WrapC (Unlift IO) Conc m x -> IO x
forall x. WrapC (Unlift IO) Conc m x -> IO x
lower (WrapC (Unlift IO) Conc m x -> IO x)
-> (m x -> WrapC (Unlift IO) Conc m x) -> m x -> IO x
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# m x -> WrapC (Unlift IO) Conc m x
forall (t :: Effect) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift))
{-# INLINE unliftConc #-}

newtype ConcToIOC m a = ConcToIOC {
    ConcToIOC m a -> UnwrapTopC Conc (UnliftToFinalC IO m) a
unConcToIOC ::
        UnwrapTopC Conc
      ( UnliftToFinalC IO
      ( m
      )) a
  } deriving ( a -> ConcToIOC m b -> ConcToIOC m a
(a -> b) -> ConcToIOC m a -> ConcToIOC m b
(forall a b. (a -> b) -> ConcToIOC m a -> ConcToIOC m b)
-> (forall a b. a -> ConcToIOC m b -> ConcToIOC m a)
-> Functor (ConcToIOC m)
forall a b. a -> ConcToIOC m b -> ConcToIOC m a
forall a b. (a -> b) -> ConcToIOC m a -> ConcToIOC m b
forall (m :: * -> *) a b.
Functor m =>
a -> ConcToIOC m b -> ConcToIOC m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> ConcToIOC m a -> ConcToIOC m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> ConcToIOC m b -> ConcToIOC m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> ConcToIOC m b -> ConcToIOC m a
fmap :: (a -> b) -> ConcToIOC m a -> ConcToIOC m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> ConcToIOC m a -> ConcToIOC m b
Functor, Functor (ConcToIOC m)
a -> ConcToIOC m a
Functor (ConcToIOC m)
-> (forall a. a -> ConcToIOC m a)
-> (forall a b.
    ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b)
-> (forall a b c.
    (a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c)
-> (forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b)
-> (forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a)
-> Applicative (ConcToIOC m)
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a
ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b
(a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c
forall a. a -> ConcToIOC m a
forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a
forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
forall a b. ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b
forall a b c.
(a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (ConcToIOC m)
forall (m :: * -> *) a. Applicative m => a -> ConcToIOC m a
forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a
forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c
<* :: ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m a
*> :: ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
liftA2 :: (a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m c
<*> :: ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
ConcToIOC m (a -> b) -> ConcToIOC m a -> ConcToIOC m b
pure :: a -> ConcToIOC m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> ConcToIOC m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (ConcToIOC m)
Applicative, Applicative (ConcToIOC m)
a -> ConcToIOC m a
Applicative (ConcToIOC m)
-> (forall a b.
    ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b)
-> (forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b)
-> (forall a. a -> ConcToIOC m a)
-> Monad (ConcToIOC m)
ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
forall a. a -> ConcToIOC m a
forall a b. ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
forall a b. ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b
forall (m :: * -> *). Monad m => Applicative (ConcToIOC m)
forall (m :: * -> *) a. Monad m => a -> ConcToIOC m a
forall (m :: * -> *) a b.
Monad m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
forall (m :: * -> *) a b.
Monad m =>
ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> ConcToIOC m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> ConcToIOC m a
>> :: ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
ConcToIOC m a -> ConcToIOC m b -> ConcToIOC m b
>>= :: ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
ConcToIOC m a -> (a -> ConcToIOC m b) -> ConcToIOC m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (ConcToIOC m)
Monad
             , Applicative (ConcToIOC m)
ConcToIOC m a
Applicative (ConcToIOC m)
-> (forall a. ConcToIOC m a)
-> (forall a. ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a)
-> (forall a. ConcToIOC m a -> ConcToIOC m [a])
-> (forall a. ConcToIOC m a -> ConcToIOC m [a])
-> Alternative (ConcToIOC m)
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
ConcToIOC m a -> ConcToIOC m [a]
ConcToIOC m a -> ConcToIOC m [a]
forall a. ConcToIOC m a
forall a. ConcToIOC m a -> ConcToIOC m [a]
forall a. ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall (m :: * -> *). Alternative m => Applicative (ConcToIOC m)
forall (m :: * -> *) a. Alternative m => ConcToIOC m a
forall (m :: * -> *) a.
Alternative m =>
ConcToIOC m a -> ConcToIOC m [a]
forall (m :: * -> *) a.
Alternative m =>
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
many :: ConcToIOC m a -> ConcToIOC m [a]
$cmany :: forall (m :: * -> *) a.
Alternative m =>
ConcToIOC m a -> ConcToIOC m [a]
some :: ConcToIOC m a -> ConcToIOC m [a]
$csome :: forall (m :: * -> *) a.
Alternative m =>
ConcToIOC m a -> ConcToIOC m [a]
<|> :: ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
$c<|> :: forall (m :: * -> *) a.
Alternative m =>
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
empty :: ConcToIOC m a
$cempty :: forall (m :: * -> *) a. Alternative m => ConcToIOC m a
$cp1Alternative :: forall (m :: * -> *). Alternative m => Applicative (ConcToIOC m)
Alternative, Monad (ConcToIOC m)
Alternative (ConcToIOC m)
ConcToIOC m a
Alternative (ConcToIOC m)
-> Monad (ConcToIOC m)
-> (forall a. ConcToIOC m a)
-> (forall a. ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a)
-> MonadPlus (ConcToIOC m)
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
forall a. ConcToIOC m a
forall a. ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall (m :: * -> *). MonadPlus m => Monad (ConcToIOC m)
forall (m :: * -> *). MonadPlus m => Alternative (ConcToIOC m)
forall (m :: * -> *) a. MonadPlus m => ConcToIOC m a
forall (m :: * -> *) a.
MonadPlus m =>
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
mplus :: ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
$cmplus :: forall (m :: * -> *) a.
MonadPlus m =>
ConcToIOC m a -> ConcToIOC m a -> ConcToIOC m a
mzero :: ConcToIOC m a
$cmzero :: forall (m :: * -> *) a. MonadPlus m => ConcToIOC m a
$cp2MonadPlus :: forall (m :: * -> *). MonadPlus m => Monad (ConcToIOC m)
$cp1MonadPlus :: forall (m :: * -> *). MonadPlus m => Alternative (ConcToIOC m)
MonadPlus
             , Monad (ConcToIOC m)
Monad (ConcToIOC m)
-> (forall a. (a -> ConcToIOC m a) -> ConcToIOC m a)
-> MonadFix (ConcToIOC m)
(a -> ConcToIOC m a) -> ConcToIOC m a
forall a. (a -> ConcToIOC m a) -> ConcToIOC m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
forall (m :: * -> *). MonadFix m => Monad (ConcToIOC m)
forall (m :: * -> *) a.
MonadFix m =>
(a -> ConcToIOC m a) -> ConcToIOC m a
mfix :: (a -> ConcToIOC m a) -> ConcToIOC m a
$cmfix :: forall (m :: * -> *) a.
MonadFix m =>
(a -> ConcToIOC m a) -> ConcToIOC m a
$cp1MonadFix :: forall (m :: * -> *). MonadFix m => Monad (ConcToIOC m)
MonadFix, Monad (ConcToIOC m)
Monad (ConcToIOC m)
-> (forall a. String -> ConcToIOC m a) -> MonadFail (ConcToIOC m)
String -> ConcToIOC m a
forall a. String -> ConcToIOC m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall (m :: * -> *). MonadFail m => Monad (ConcToIOC m)
forall (m :: * -> *) a. MonadFail m => String -> ConcToIOC m a
fail :: String -> ConcToIOC m a
$cfail :: forall (m :: * -> *) a. MonadFail m => String -> ConcToIOC m a
$cp1MonadFail :: forall (m :: * -> *). MonadFail m => Monad (ConcToIOC m)
MonadFail, Monad (ConcToIOC m)
Monad (ConcToIOC m)
-> (forall a. IO a -> ConcToIOC m a) -> MonadIO (ConcToIOC m)
IO a -> ConcToIOC m a
forall a. IO a -> ConcToIOC m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (ConcToIOC m)
forall (m :: * -> *) a. MonadIO m => IO a -> ConcToIOC m a
liftIO :: IO a -> ConcToIOC m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> ConcToIOC m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (ConcToIOC m)
MonadIO
             , Monad (ConcToIOC m)
e -> ConcToIOC m a
Monad (ConcToIOC m)
-> (forall e a. Exception e => e -> ConcToIOC m a)
-> MonadThrow (ConcToIOC m)
forall e a. Exception e => e -> ConcToIOC m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
forall (m :: * -> *). MonadThrow m => Monad (ConcToIOC m)
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ConcToIOC m a
throwM :: e -> ConcToIOC m a
$cthrowM :: forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ConcToIOC m a
$cp1MonadThrow :: forall (m :: * -> *). MonadThrow m => Monad (ConcToIOC m)
MonadThrow, MonadThrow (ConcToIOC m)
MonadThrow (ConcToIOC m)
-> (forall e a.
    Exception e =>
    ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a)
-> MonadCatch (ConcToIOC m)
ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a
forall e a.
Exception e =>
ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
forall (m :: * -> *). MonadCatch m => MonadThrow (ConcToIOC m)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a
catch :: ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a
$ccatch :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ConcToIOC m a -> (e -> ConcToIOC m a) -> ConcToIOC m a
$cp1MonadCatch :: forall (m :: * -> *). MonadCatch m => MonadThrow (ConcToIOC m)
MonadCatch, MonadCatch (ConcToIOC m)
MonadCatch (ConcToIOC m)
-> (forall b.
    ((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
    -> ConcToIOC m b)
-> (forall b.
    ((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
    -> ConcToIOC m b)
-> (forall a b c.
    ConcToIOC m a
    -> (a -> ExitCase b -> ConcToIOC m c)
    -> (a -> ConcToIOC m b)
    -> ConcToIOC m (b, c))
-> MonadMask (ConcToIOC m)
ConcToIOC m a
-> (a -> ExitCase b -> ConcToIOC m c)
-> (a -> ConcToIOC m b)
-> ConcToIOC m (b, c)
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
forall b.
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
forall a b c.
ConcToIOC m a
-> (a -> ExitCase b -> ConcToIOC m c)
-> (a -> ConcToIOC m b)
-> ConcToIOC m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
forall (m :: * -> *). MonadMask m => MonadCatch (ConcToIOC m)
forall (m :: * -> *) b.
MonadMask m =>
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
forall (m :: * -> *) a b c.
MonadMask m =>
ConcToIOC m a
-> (a -> ExitCase b -> ConcToIOC m c)
-> (a -> ConcToIOC m b)
-> ConcToIOC m (b, c)
generalBracket :: ConcToIOC m a
-> (a -> ExitCase b -> ConcToIOC m c)
-> (a -> ConcToIOC m b)
-> ConcToIOC m (b, c)
$cgeneralBracket :: forall (m :: * -> *) a b c.
MonadMask m =>
ConcToIOC m a
-> (a -> ExitCase b -> ConcToIOC m c)
-> (a -> ConcToIOC m b)
-> ConcToIOC m (b, c)
uninterruptibleMask :: ((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
$cuninterruptibleMask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
mask :: ((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
$cmask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. ConcToIOC m a -> ConcToIOC m a) -> ConcToIOC m b)
-> ConcToIOC m b
$cp1MonadMask :: forall (m :: * -> *). MonadMask m => MonadCatch (ConcToIOC m)
MonadMask
             , MonadBase b, MonadBaseControl b
             )
    deriving m a -> ConcToIOC m a
(forall (m :: * -> *) a. Monad m => m a -> ConcToIOC m a)
-> MonadTrans ConcToIOC
forall (m :: * -> *) a. Monad m => m a -> ConcToIOC m a
forall (t :: Effect).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> ConcToIOC m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> ConcToIOC m a
MonadTrans
    via CompositionBaseT
     '[ UnwrapTopC Conc
      , UnliftToFinalC IO
      ]

deriving instance (Carrier m, MonadBaseControlPure IO m)
               => Carrier (ConcToIOC m)