{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnicodeSyntax #-}
module Control.Monad.Allocate where
import Control.Exception.Safe
import Control.Monad.Cont
import Control.Monad.Except
import Control.Monad.RWS.Lazy
import qualified Control.Monad.RWS.Strict as Strict
import Control.Monad.Reader
import Control.Monad.State.Lazy
import qualified Control.Monad.State.Strict as Strict
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Resource hiding (throwM)
import Control.Monad.Trans.Resource.Internal
import Control.Monad.Writer.Lazy
import qualified Control.Monad.Writer.Strict as Strict
import Data.Acquire
import Data.Acquire.Internal
import Data.Exceptable
import Data.GeneralAllocate
import Data.Kind
class (Monad m, Monad (AllocationContext m)) ⇒ MonadAllocate m where
type AllocationContext m ∷ Type → Type
type GeneralReleaseKey m
type AllocationException m
type AllocationException m = SomeException
generalAllocate
∷ GeneralAllocate (AllocationContext m) (AllocationException m) () () a
→ m (GeneralReleaseKey m, a)
generalRegister
∷ (GeneralReleaseType (AllocationException m) () → AllocationContext m ())
→ m (GeneralReleaseKey m)
generalRegister GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ()
rel = (GeneralReleaseKey m, ()) -> GeneralReleaseKey m
forall a b. (a, b) -> a
fst ((GeneralReleaseKey m, ()) -> GeneralReleaseKey m)
-> m (GeneralReleaseKey m, ()) -> m (GeneralReleaseKey m)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GeneralAllocate
(AllocationContext m) (AllocationException m) () () ()
-> m (GeneralReleaseKey m, ())
forall a.
GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a)
forall (m :: * -> *) a.
MonadAllocate m =>
GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a)
generalAllocate (((forall x. AllocationContext m x -> AllocationContext m x)
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()))
-> GeneralAllocate
(AllocationContext m) (AllocationException m) () () ()
forall (m :: * -> *) e releaseReturn releaseArg a.
((forall x. m x -> m x)
-> m (GeneralAllocated m e releaseReturn releaseArg a))
-> GeneralAllocate m e releaseReturn releaseArg a
GeneralAllocate (forall x. AllocationContext m x -> AllocationContext m x)
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ())
alloc)
where
alloc ∷ (∀ x. AllocationContext m x → AllocationContext m x) → AllocationContext m (GeneralAllocated (AllocationContext m) (AllocationException m) () () ())
alloc :: (forall x. AllocationContext m x -> AllocationContext m x)
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ())
alloc forall x. AllocationContext m x -> AllocationContext m x
_ = GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ())
forall a. a -> AllocationContext m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()))
-> GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()
-> AllocationContext
m
(GeneralAllocated
(AllocationContext m) (AllocationException m) () () ())
forall a b. (a -> b) -> a -> b
$ ()
-> (GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ())
-> GeneralAllocated
(AllocationContext m) (AllocationException m) () () ()
forall (m :: * -> *) e releaseReturn releaseArg a.
a
-> (GeneralReleaseType e releaseArg -> m releaseReturn)
-> GeneralAllocated m e releaseReturn releaseArg a
GeneralAllocated () GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ()
rel
generalRelease
∷ GeneralReleaseKey m
→ AllocationContext m ()
type MonadAllocateExceptable m = (MonadAllocate m, Exceptable (AllocationException m))
newtype AllocateViaResource m a = AllocateViaResource (m a) deriving newtype ((forall a b.
(a -> b) -> AllocateViaResource m a -> AllocateViaResource m b)
-> (forall a b.
a -> AllocateViaResource m b -> AllocateViaResource m a)
-> Functor (AllocateViaResource m)
forall a b. a -> AllocateViaResource m b -> AllocateViaResource m a
forall a b.
(a -> b) -> AllocateViaResource m a -> AllocateViaResource m b
forall (m :: * -> *) a b.
Functor m =>
a -> AllocateViaResource m b -> AllocateViaResource m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> AllocateViaResource m a -> AllocateViaResource m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> AllocateViaResource m a -> AllocateViaResource m b
fmap :: forall a b.
(a -> b) -> AllocateViaResource m a -> AllocateViaResource m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> AllocateViaResource m b -> AllocateViaResource m a
<$ :: forall a b. a -> AllocateViaResource m b -> AllocateViaResource m a
Functor, Functor (AllocateViaResource m)
Functor (AllocateViaResource m) =>
(forall a. a -> AllocateViaResource m a)
-> (forall a b.
AllocateViaResource m (a -> b)
-> AllocateViaResource m a -> AllocateViaResource m b)
-> (forall a b c.
(a -> b -> c)
-> AllocateViaResource m a
-> AllocateViaResource m b
-> AllocateViaResource m c)
-> (forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b)
-> (forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m a)
-> Applicative (AllocateViaResource m)
forall a. a -> AllocateViaResource m a
forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m a
forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
forall a b.
AllocateViaResource m (a -> b)
-> AllocateViaResource m a -> AllocateViaResource m b
forall a b c.
(a -> b -> c)
-> AllocateViaResource m a
-> AllocateViaResource m b
-> AllocateViaResource 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 (AllocateViaResource m)
forall (m :: * -> *) a.
Applicative m =>
a -> AllocateViaResource m a
forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m a
forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m (a -> b)
-> AllocateViaResource m a -> AllocateViaResource m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> AllocateViaResource m a
-> AllocateViaResource m b
-> AllocateViaResource m c
$cpure :: forall (m :: * -> *) a.
Applicative m =>
a -> AllocateViaResource m a
pure :: forall a. a -> AllocateViaResource m a
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m (a -> b)
-> AllocateViaResource m a -> AllocateViaResource m b
<*> :: forall a b.
AllocateViaResource m (a -> b)
-> AllocateViaResource m a -> AllocateViaResource m b
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> AllocateViaResource m a
-> AllocateViaResource m b
-> AllocateViaResource m c
liftA2 :: forall a b c.
(a -> b -> c)
-> AllocateViaResource m a
-> AllocateViaResource m b
-> AllocateViaResource m c
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
*> :: forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m a
<* :: forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m a
Applicative, Applicative (AllocateViaResource m)
Applicative (AllocateViaResource m) =>
(forall a b.
AllocateViaResource m a
-> (a -> AllocateViaResource m b) -> AllocateViaResource m b)
-> (forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b)
-> (forall a. a -> AllocateViaResource m a)
-> Monad (AllocateViaResource m)
forall a. a -> AllocateViaResource m a
forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
forall a b.
AllocateViaResource m a
-> (a -> AllocateViaResource m b) -> AllocateViaResource m b
forall (m :: * -> *).
Monad m =>
Applicative (AllocateViaResource m)
forall (m :: * -> *) a. Monad m => a -> AllocateViaResource m a
forall (m :: * -> *) a b.
Monad m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
forall (m :: * -> *) a b.
Monad m =>
AllocateViaResource m a
-> (a -> AllocateViaResource m b) -> AllocateViaResource 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
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
AllocateViaResource m a
-> (a -> AllocateViaResource m b) -> AllocateViaResource m b
>>= :: forall a b.
AllocateViaResource m a
-> (a -> AllocateViaResource m b) -> AllocateViaResource m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
>> :: forall a b.
AllocateViaResource m a
-> AllocateViaResource m b -> AllocateViaResource m b
$creturn :: forall (m :: * -> *) a. Monad m => a -> AllocateViaResource m a
return :: forall a. a -> AllocateViaResource m a
Monad)
instance (MonadResource m) ⇒ MonadAllocate (AllocateViaResource m) where
type AllocationContext (AllocateViaResource m) = IO
type GeneralReleaseKey (AllocateViaResource m) = ReleaseKey
generalAllocate
∷ ∀ a
. GeneralAllocate (AllocationContext (AllocateViaResource m)) SomeException () () a
→ AllocateViaResource m (ReleaseKey, a)
generalAllocate :: forall a.
GeneralAllocate
(AllocationContext (AllocateViaResource m)) SomeException () () a
-> AllocateViaResource m (ReleaseKey, a)
generalAllocate (GeneralAllocate (forall x.
AllocationContext (AllocateViaResource m) x
-> AllocationContext (AllocateViaResource m) x)
-> AllocationContext
(AllocateViaResource m)
(GeneralAllocated
(AllocationContext (AllocateViaResource m)) SomeException () () a)
alloc) = m (ReleaseKey, a) -> AllocateViaResource m (ReleaseKey, a)
forall (m :: * -> *) a. m a -> AllocateViaResource m a
AllocateViaResource (m (ReleaseKey, a) -> AllocateViaResource m (ReleaseKey, a))
-> m (ReleaseKey, a) -> AllocateViaResource m (ReleaseKey, a)
forall a b. (a -> b) -> a -> b
$ do
let alloc' ∷ ((∀ b. IO b → IO b) → IO (Allocated a))
alloc' :: (forall b. IO b -> IO b) -> IO (Allocated a)
alloc' forall b. IO b -> IO b
restore = do
GeneralAllocated a
x GeneralReleaseType SomeException () -> IO ()
rel ← (forall x.
AllocationContext (AllocateViaResource m) x
-> AllocationContext (AllocateViaResource m) x)
-> AllocationContext
(AllocateViaResource m)
(GeneralAllocated
(AllocationContext (AllocateViaResource m)) SomeException () () a)
alloc IO x -> IO x
AllocationContext (AllocateViaResource m) x
-> AllocationContext (AllocateViaResource m) x
forall b. IO b -> IO b
forall x.
AllocationContext (AllocateViaResource m) x
-> AllocationContext (AllocateViaResource m) x
restore
let rel' :: ReleaseType -> IO ()
rel' (ReleaseExceptionWith SomeException
e) = GeneralReleaseType SomeException () -> IO ()
rel (GeneralReleaseType SomeException () -> IO ())
-> GeneralReleaseType SomeException () -> IO ()
forall a b. (a -> b) -> a -> b
$ SomeException -> GeneralReleaseType SomeException ()
forall e a. e -> GeneralReleaseType e a
ReleaseFailure SomeException
e
rel' ReleaseType
_ = GeneralReleaseType SomeException () -> IO ()
rel (GeneralReleaseType SomeException () -> IO ())
-> GeneralReleaseType SomeException () -> IO ()
forall a b. (a -> b) -> a -> b
$ () -> GeneralReleaseType SomeException ()
forall e a. a -> GeneralReleaseType e a
ReleaseSuccess ()
Allocated a -> IO (Allocated a)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Allocated a -> IO (Allocated a))
-> Allocated a -> IO (Allocated a)
forall a b. (a -> b) -> a -> b
$ a -> (ReleaseType -> IO ()) -> Allocated a
forall a. a -> (ReleaseType -> IO ()) -> Allocated a
Allocated a
x ReleaseType -> IO ()
rel'
(ReleaseKey
k, a
x) ← Acquire a -> m (ReleaseKey, a)
forall (m :: * -> *) a.
MonadResource m =>
Acquire a -> m (ReleaseKey, a)
allocateAcquire (Acquire a -> m (ReleaseKey, a)) -> Acquire a -> m (ReleaseKey, a)
forall a b. (a -> b) -> a -> b
$ ((forall b. IO b -> IO b) -> IO (Allocated a)) -> Acquire a
forall a.
((forall b. IO b -> IO b) -> IO (Allocated a)) -> Acquire a
Acquire (forall b. IO b -> IO b) -> IO (Allocated a)
alloc'
(ReleaseKey, a) -> m (ReleaseKey, a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ReleaseKey
k, a
x)
generalRegister :: (GeneralReleaseType
(AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ())
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m))
generalRegister GeneralReleaseType (AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ()
rel = m ReleaseKey -> AllocateViaResource m ReleaseKey
m ReleaseKey
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m))
forall (m :: * -> *) a. m a -> AllocateViaResource m a
AllocateViaResource (m ReleaseKey
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m)))
-> ((InternalState -> IO ReleaseKey) -> m ReleaseKey)
-> (InternalState -> IO ReleaseKey)
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ResourceT IO ReleaseKey -> m ReleaseKey
forall a. ResourceT IO a -> m a
forall (m :: * -> *) a. MonadResource m => ResourceT IO a -> m a
liftResourceT (ResourceT IO ReleaseKey -> m ReleaseKey)
-> ((InternalState -> IO ReleaseKey) -> ResourceT IO ReleaseKey)
-> (InternalState -> IO ReleaseKey)
-> m ReleaseKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (InternalState -> IO ReleaseKey) -> ResourceT IO ReleaseKey
forall (m :: * -> *) a. (InternalState -> m a) -> ResourceT m a
withInternalState ((InternalState -> IO ReleaseKey)
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m)))
-> (InternalState -> IO ReleaseKey)
-> AllocateViaResource
m (GeneralReleaseKey (AllocateViaResource m))
forall a b. (a -> b) -> a -> b
$ \InternalState
st → do
let rel' :: ReleaseType -> AllocationContext (AllocateViaResource m) ()
rel' (ReleaseExceptionWith SomeException
e) = GeneralReleaseType (AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ()
rel (GeneralReleaseType
(AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ())
-> GeneralReleaseType
(AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ()
forall a b. (a -> b) -> a -> b
$ SomeException -> GeneralReleaseType SomeException ()
forall e a. e -> GeneralReleaseType e a
ReleaseFailure SomeException
e
rel' ReleaseType
_ = GeneralReleaseType (AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ()
rel (GeneralReleaseType
(AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ())
-> GeneralReleaseType
(AllocationException (AllocateViaResource m)) ()
-> AllocationContext (AllocateViaResource m) ()
forall a b. (a -> b) -> a -> b
$ () -> GeneralReleaseType SomeException ()
forall e a. a -> GeneralReleaseType e a
ReleaseSuccess ()
InternalState -> (ReleaseType -> IO ()) -> IO ReleaseKey
registerType InternalState
st ReleaseType -> IO ()
ReleaseType -> AllocationContext (AllocateViaResource m) ()
rel'
generalRelease :: GeneralReleaseKey (AllocateViaResource m)
-> AllocationContext (AllocateViaResource m) ()
generalRelease = ReleaseKey -> IO ()
GeneralReleaseKey (AllocateViaResource m)
-> AllocationContext (AllocateViaResource m) ()
forall (m :: * -> *). MonadIO m => ReleaseKey -> m ()
release
deriving via AllocateViaResource (ResourceT m) instance (MonadIO m) ⇒ MonadAllocate (ResourceT m)
type AllocateViaLift ∷ ((Type → Type) → (Type → Type)) → (Type → Type) → Type → Type
newtype AllocateViaLift t m a = AllocateViaLift (t m a) deriving newtype ((forall a b.
(a -> b) -> AllocateViaLift t m a -> AllocateViaLift t m b)
-> (forall a b.
a -> AllocateViaLift t m b -> AllocateViaLift t m a)
-> Functor (AllocateViaLift t m)
forall a b. a -> AllocateViaLift t m b -> AllocateViaLift t m a
forall a b.
(a -> b) -> AllocateViaLift t m a -> AllocateViaLift t m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Functor (t m) =>
a -> AllocateViaLift t m b -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Functor (t m) =>
(a -> b) -> AllocateViaLift t m a -> AllocateViaLift t m b
$cfmap :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Functor (t m) =>
(a -> b) -> AllocateViaLift t m a -> AllocateViaLift t m b
fmap :: forall a b.
(a -> b) -> AllocateViaLift t m a -> AllocateViaLift t m b
$c<$ :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Functor (t m) =>
a -> AllocateViaLift t m b -> AllocateViaLift t m a
<$ :: forall a b. a -> AllocateViaLift t m b -> AllocateViaLift t m a
Functor, Functor (AllocateViaLift t m)
Functor (AllocateViaLift t m) =>
(forall a. a -> AllocateViaLift t m a)
-> (forall a b.
AllocateViaLift t m (a -> b)
-> AllocateViaLift t m a -> AllocateViaLift t m b)
-> (forall a b c.
(a -> b -> c)
-> AllocateViaLift t m a
-> AllocateViaLift t m b
-> AllocateViaLift t m c)
-> (forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b)
-> (forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m a)
-> Applicative (AllocateViaLift t m)
forall a. a -> AllocateViaLift t m a
forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m a
forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
forall a b.
AllocateViaLift t m (a -> b)
-> AllocateViaLift t m a -> AllocateViaLift t m b
forall a b c.
(a -> b -> c)
-> AllocateViaLift t m a
-> AllocateViaLift t m b
-> AllocateViaLift t 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 (t :: (* -> *) -> * -> *) (m :: * -> *).
Applicative (t m) =>
Functor (AllocateViaLift t m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative (t m) =>
a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m (a -> b)
-> AllocateViaLift t m a -> AllocateViaLift t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b c.
Applicative (t m) =>
(a -> b -> c)
-> AllocateViaLift t m a
-> AllocateViaLift t m b
-> AllocateViaLift t m c
$cpure :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative (t m) =>
a -> AllocateViaLift t m a
pure :: forall a. a -> AllocateViaLift t m a
$c<*> :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m (a -> b)
-> AllocateViaLift t m a -> AllocateViaLift t m b
<*> :: forall a b.
AllocateViaLift t m (a -> b)
-> AllocateViaLift t m a -> AllocateViaLift t m b
$cliftA2 :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b c.
Applicative (t m) =>
(a -> b -> c)
-> AllocateViaLift t m a
-> AllocateViaLift t m b
-> AllocateViaLift t m c
liftA2 :: forall a b c.
(a -> b -> c)
-> AllocateViaLift t m a
-> AllocateViaLift t m b
-> AllocateViaLift t m c
$c*> :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
*> :: forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
$c<* :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Applicative (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m a
<* :: forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m a
Applicative, Applicative (AllocateViaLift t m)
Applicative (AllocateViaLift t m) =>
(forall a b.
AllocateViaLift t m a
-> (a -> AllocateViaLift t m b) -> AllocateViaLift t m b)
-> (forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b)
-> (forall a. a -> AllocateViaLift t m a)
-> Monad (AllocateViaLift t m)
forall a. a -> AllocateViaLift t m a
forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
forall a b.
AllocateViaLift t m a
-> (a -> AllocateViaLift t m b) -> AllocateViaLift t 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
forall (t :: (* -> *) -> * -> *) (m :: * -> *).
Monad (t m) =>
Applicative (AllocateViaLift t m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad (t m) =>
a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Monad (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Monad (t m) =>
AllocateViaLift t m a
-> (a -> AllocateViaLift t m b) -> AllocateViaLift t m b
$c>>= :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Monad (t m) =>
AllocateViaLift t m a
-> (a -> AllocateViaLift t m b) -> AllocateViaLift t m b
>>= :: forall a b.
AllocateViaLift t m a
-> (a -> AllocateViaLift t m b) -> AllocateViaLift t m b
$c>> :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
Monad (t m) =>
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
>> :: forall a b.
AllocateViaLift t m a
-> AllocateViaLift t m b -> AllocateViaLift t m b
$creturn :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad (t m) =>
a -> AllocateViaLift t m a
return :: forall a. a -> AllocateViaLift t m a
Monad, (forall (m :: * -> *). Monad m => Monad (AllocateViaLift t m)) =>
(forall (m :: * -> *) a. Monad m => m a -> AllocateViaLift t m a)
-> MonadTrans (AllocateViaLift t)
forall (m :: * -> *). Monad m => Monad (AllocateViaLift t m)
forall (m :: * -> *) a. Monad m => m a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *).
(MonadTrans t, Monad m) =>
Monad (AllocateViaLift t m)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *). Monad m => Monad (t m)) =>
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
$clift :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> AllocateViaLift t m a
lift :: forall (m :: * -> *) a. Monad m => m a -> AllocateViaLift t m a
MonadTrans)
instance (MonadAllocate m, MonadTrans t, Monad (t m)) ⇒ MonadAllocate (AllocateViaLift t m) where
type AllocationContext (AllocateViaLift t m) = AllocationContext m
type GeneralReleaseKey (AllocateViaLift t m) = GeneralReleaseKey m
type AllocationException (AllocateViaLift t m) = AllocationException m
generalAllocate :: forall a.
GeneralAllocate
(AllocationContext (AllocateViaLift t m))
(AllocationException (AllocateViaLift t m))
()
()
a
-> AllocateViaLift t m (GeneralReleaseKey (AllocateViaLift t m), a)
generalAllocate = m (GeneralReleaseKey m, a)
-> AllocateViaLift t m (GeneralReleaseKey m, a)
forall (m :: * -> *) a. Monad m => m a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (GeneralReleaseKey m, a)
-> AllocateViaLift t m (GeneralReleaseKey m, a))
-> (GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a))
-> GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> AllocateViaLift t m (GeneralReleaseKey m, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a)
forall a.
GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a)
forall (m :: * -> *) a.
MonadAllocate m =>
GeneralAllocate
(AllocationContext m) (AllocationException m) () () a
-> m (GeneralReleaseKey m, a)
generalAllocate
generalRegister :: (GeneralReleaseType (AllocationException (AllocateViaLift t m)) ()
-> AllocationContext (AllocateViaLift t m) ())
-> AllocateViaLift t m (GeneralReleaseKey (AllocateViaLift t m))
generalRegister = m (GeneralReleaseKey m)
-> AllocateViaLift t m (GeneralReleaseKey m)
forall (m :: * -> *) a. Monad m => m a -> AllocateViaLift t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (GeneralReleaseKey m)
-> AllocateViaLift t m (GeneralReleaseKey m))
-> ((GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ())
-> m (GeneralReleaseKey m))
-> (GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ())
-> AllocateViaLift t m (GeneralReleaseKey m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ())
-> m (GeneralReleaseKey m)
forall (m :: * -> *).
MonadAllocate m =>
(GeneralReleaseType (AllocationException m) ()
-> AllocationContext m ())
-> m (GeneralReleaseKey m)
generalRegister
generalRelease :: GeneralReleaseKey (AllocateViaLift t m)
-> AllocationContext (AllocateViaLift t m) ()
generalRelease = forall (m :: * -> *).
MonadAllocate m =>
GeneralReleaseKey m -> AllocationContext m ()
generalRelease @m
deriving via AllocateViaLift MaybeT m instance (MonadAllocate m) ⇒ MonadAllocate (MaybeT m)
deriving via AllocateViaLift (ExceptT e) m instance (MonadAllocate m) ⇒ MonadAllocate (ExceptT e m)
deriving via AllocateViaLift (ReaderT r) m instance (MonadAllocate m) ⇒ MonadAllocate (ReaderT r m)
deriving via AllocateViaLift (StateT s) m instance (MonadAllocate m) ⇒ MonadAllocate (StateT s m)
deriving via AllocateViaLift (Strict.StateT s) m instance (MonadAllocate m) ⇒ MonadAllocate (Strict.StateT s m)
deriving via AllocateViaLift (WriterT w) m instance (Monoid w, MonadAllocate m) ⇒ MonadAllocate (WriterT w m)
deriving via AllocateViaLift (Strict.WriterT w) m instance (Monoid w, MonadAllocate m) ⇒ MonadAllocate (Strict.WriterT w m)
deriving via AllocateViaLift (ContT r) m instance (MonadAllocate m) ⇒ MonadAllocate (ContT r m)
deriving via AllocateViaLift (RWST r w s) m instance (Monoid w, MonadAllocate m) ⇒ MonadAllocate (RWST r w s m)
deriving via AllocateViaLift (Strict.RWST r w s) m instance (Monoid w, MonadAllocate m) ⇒ MonadAllocate (Strict.RWST r w s m)