{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE UndecidableInstances #-}

-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.

{- |
Copyright   :  (c) 2023 Yamada Ryo
License     :  MPL-2.0 (see the file LICENSE)
Maintainer  :  ymdfield@outlook.jp
Stability   :  experimental
Portability :  portable

A Heftia carrier that can be used as a handler for effect systems based
on [@classy-effects@](https://hackage.haskell.org/package/classy-effects).
-}
module Control.Effect.Heftia where

import Control.Applicative (Alternative)
import Control.Arrow ((>>>))
import Control.Effect.Class (
    EffectDataHandler,
    EffectsVia (EffectsVia),
    LiftIns (LiftIns),
    SendIns,
    SendSig,
    Signature,
    TagH,
    getTagH,
    runEffectsVia,
    sendIns,
    sendSig,
    unliftIns,
    type (~>),
 )
import Control.Effect.Class.Machinery.HFunctor (HFunctor, hfmap)
import Control.Effect.Freer (FreerEffects, freerEffects, interpose, unFreerEffects)
import Control.Freer.Trans (TransFreer, interpretFT, liftInsT, liftLowerFT)
import Control.Heftia.Trans (
    TransHeftia,
    elaborateHT,
    hoistHeftia,
    interpretLowerHT,
    liftLowerHT,
    liftSigT,
    reelaborateHT,
    runElaborateH,
    transformHT,
    translateT,
 )
import Control.Monad (MonadPlus)
import Control.Monad.Cont (ContT (ContT), MonadTrans, runContT)
import Control.Monad.Trans.Heftia (MonadTransHeftia, elaborateMK, elaborateMT)
import Control.Monad.Trans.Heftia.Church (HeftiaChurchT)
import Data.Extensible.Class (Forall)
import Data.Free.Union (Member, Union, project)
import Data.Hefty.Extensible (ExtensibleUnionH)
import Data.Hefty.Union (
    IsMemberH,
    MemberH,
    UnionH (
        absurdUnionH,
        bundleUnion2H,
        bundleUnion3H,
        bundleUnion4H,
        decompH,
        flipUnion3H,
        flipUnionH,
        flipUnionUnderH,
        inject0H,
        injectH,
        projectH,
        rot3H,
        rot3H',
        unbundleUnion2H,
        unbundleUnion3H,
        unbundleUnion4H,
        weaken2H,
        weaken2Under2H,
        weaken2UnderH,
        weaken3H,
        weaken3UnderH,
        weaken4H,
        weakenH,
        weakenUnder2H,
        weakenUnder3H,
        weakenUnderH
    ),
    (|+:),
 )
import Data.Kind (Type)

{- |
A data type that wraps Heftia with any encoding to become an instance of 'SendIns'/'SendSig' based
on the `liftInsT` or `liftSigT` from the `TransFreer` or `TransHeftia` type class.
-}
newtype
    HeftiaUnion
        (h :: Signature -> (Type -> Type) -> Type -> Type)
        u
        (es :: [Signature])
        f
        a = HeftiaUnion {forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnion h u es f a -> h (u es) f a
runHeftiaUnion :: h (u es) f a}
    deriving newtype (forall a b. a -> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
forall a b.
(a -> b) -> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
a -> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
(a -> b) -> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
<$ :: forall a b. a -> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
$c<$ :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
a -> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
fmap :: forall a b.
(a -> b) -> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
$cfmap :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
(a -> b) -> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
Functor, forall a. a -> HeftiaUnion h u es f a
forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
forall a b.
HeftiaUnion h u es f (a -> b)
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
forall a b c.
(a -> b -> c)
-> HeftiaUnion h u es f a
-> HeftiaUnion h u es f b
-> HeftiaUnion h u es f 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 {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Applicative (h (u es) f) =>
Functor (HeftiaUnion h u es f)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Applicative (h (u es) f) =>
a -> HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f (a -> b)
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b c.
Applicative (h (u es) f) =>
(a -> b -> c)
-> HeftiaUnion h u es f a
-> HeftiaUnion h u es f b
-> HeftiaUnion h u es f c
<* :: forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
$c<* :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f a
*> :: forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
$c*> :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
liftA2 :: forall a b c.
(a -> b -> c)
-> HeftiaUnion h u es f a
-> HeftiaUnion h u es f b
-> HeftiaUnion h u es f c
$cliftA2 :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b c.
Applicative (h (u es) f) =>
(a -> b -> c)
-> HeftiaUnion h u es f a
-> HeftiaUnion h u es f b
-> HeftiaUnion h u es f c
<*> :: forall a b.
HeftiaUnion h u es f (a -> b)
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
$c<*> :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnion h u es f (a -> b)
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f b
pure :: forall a. a -> HeftiaUnion h u es f a
$cpure :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Applicative (h (u es) f) =>
a -> HeftiaUnion h u es f a
Applicative, forall a. HeftiaUnion h u es f a
forall a. HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
forall a.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f 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 {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Alternative (h (u es) f) =>
Applicative (HeftiaUnion h u es f)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
many :: forall a. HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
$cmany :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
some :: forall a. HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
$csome :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a -> HeftiaUnion h u es f [a]
<|> :: forall a.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
$c<|> :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
empty :: forall a. HeftiaUnion h u es f a
$cempty :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnion h u es f a
Alternative, forall a. a -> HeftiaUnion h u es f a
forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
forall a b.
HeftiaUnion h u es f a
-> (a -> HeftiaUnion h u es f b) -> HeftiaUnion h u es f 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 {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Monad (h (u es) f) =>
Applicative (HeftiaUnion h u es f)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Monad (h (u es) f) =>
a -> HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnion h u es f a
-> (a -> HeftiaUnion h u es f b) -> HeftiaUnion h u es f b
return :: forall a. a -> HeftiaUnion h u es f a
$creturn :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Monad (h (u es) f) =>
a -> HeftiaUnion h u es f a
>> :: forall a b.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
$c>> :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f b -> HeftiaUnion h u es f b
>>= :: forall a b.
HeftiaUnion h u es f a
-> (a -> HeftiaUnion h u es f b) -> HeftiaUnion h u es f b
$c>>= :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnion h u es f a
-> (a -> HeftiaUnion h u es f b) -> HeftiaUnion h u es f b
Monad, forall a. HeftiaUnion h u es f a
forall a.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
MonadPlus (h (u es) f) =>
Monad (HeftiaUnion h u es f)
forall {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
MonadPlus (h (u es) f) =>
Alternative (HeftiaUnion h u es f)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnion h u es f a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
mplus :: forall a.
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
$cmplus :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnion h u es f a
-> HeftiaUnion h u es f a -> HeftiaUnion h u es f a
mzero :: forall a. HeftiaUnion h u es f a
$cmzero :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnion h u es f a
MonadPlus)
    deriving stock (forall a. HeftiaUnion h u es f a -> Bool
forall m a. Monoid m => (a -> m) -> HeftiaUnion h u es f a -> m
forall a b. (a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Eq a) =>
a -> HeftiaUnion h u es f a -> Bool
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnion h u es f a -> a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnion h u es f a -> a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       m.
(Foldable (h (u es) f), Monoid m) =>
HeftiaUnion h u es f m -> m
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> Bool
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> Int
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> [a]
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnion h u es f a -> a
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnion h u es f a -> m
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b) -> b -> HeftiaUnion h u es f a -> b
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
product :: forall a. Num a => HeftiaUnion h u es f a -> a
$cproduct :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnion h u es f a -> a
sum :: forall a. Num a => HeftiaUnion h u es f a -> a
$csum :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnion h u es f a -> a
minimum :: forall a. Ord a => HeftiaUnion h u es f a -> a
$cminimum :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnion h u es f a -> a
maximum :: forall a. Ord a => HeftiaUnion h u es f a -> a
$cmaximum :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnion h u es f a -> a
elem :: forall a. Eq a => a -> HeftiaUnion h u es f a -> Bool
$celem :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Eq a) =>
a -> HeftiaUnion h u es f a -> Bool
length :: forall a. HeftiaUnion h u es f a -> Int
$clength :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> Int
null :: forall a. HeftiaUnion h u es f a -> Bool
$cnull :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> Bool
toList :: forall a. HeftiaUnion h u es f a -> [a]
$ctoList :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnion h u es f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> HeftiaUnion h u es f a -> a
$cfoldl1 :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnion h u es f a -> a
foldr1 :: forall a. (a -> a -> a) -> HeftiaUnion h u es f a -> a
$cfoldr1 :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnion h u es f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> HeftiaUnion h u es f a -> b
$cfoldl' :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b) -> b -> HeftiaUnion h u es f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> HeftiaUnion h u es f a -> b
$cfoldl :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b) -> b -> HeftiaUnion h u es f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
$cfoldr' :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
$cfoldr :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b) -> b -> HeftiaUnion h u es f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> HeftiaUnion h u es f a -> m
$cfoldMap' :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnion h u es f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> HeftiaUnion h u es f a -> m
$cfoldMap :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnion h u es f a -> m
fold :: forall m. Monoid m => HeftiaUnion h u es f m -> m
$cfold :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       m.
(Foldable (h (u es) f), Monoid m) =>
HeftiaUnion h u es f m -> m
Foldable, forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HeftiaUnion h u es f a -> f (HeftiaUnion h u es f b)
forall {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Traversable (h (u es) f) =>
Functor (HeftiaUnion h u es f)
forall {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Traversable (h (u es) f) =>
Foldable (HeftiaUnion h u es f)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a.
(Traversable (h (u es) f), Monad m) =>
HeftiaUnion h u es f (m a) -> m (HeftiaUnion h u es f a)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a.
(Traversable (h (u es) f), Applicative f) =>
HeftiaUnion h u es f (f a) -> f (HeftiaUnion h u es f a)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a b.
(Traversable (h (u es) f), Monad m) =>
(a -> m b) -> HeftiaUnion h u es f a -> m (HeftiaUnion h u es f b)
forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a b.
(Traversable (h (u es) f), Applicative f) =>
(a -> f b) -> HeftiaUnion h u es f a -> f (HeftiaUnion h u es f b)
sequence :: forall (m :: * -> *) a.
Monad m =>
HeftiaUnion h u es f (m a) -> m (HeftiaUnion h u es f a)
$csequence :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a.
(Traversable (h (u es) f), Monad m) =>
HeftiaUnion h u es f (m a) -> m (HeftiaUnion h u es f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HeftiaUnion h u es f a -> m (HeftiaUnion h u es f b)
$cmapM :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a b.
(Traversable (h (u es) f), Monad m) =>
(a -> m b) -> HeftiaUnion h u es f a -> m (HeftiaUnion h u es f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
HeftiaUnion h u es f (f a) -> f (HeftiaUnion h u es f a)
$csequenceA :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a.
(Traversable (h (u es) f), Applicative f) =>
HeftiaUnion h u es f (f a) -> f (HeftiaUnion h u es f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HeftiaUnion h u es f a -> f (HeftiaUnion h u es f b)
$ctraverse :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a b.
(Traversable (h (u es) f), Applicative f) =>
(a -> f b) -> HeftiaUnion h u es f a -> f (HeftiaUnion h u es f b)
Traversable)

{- |
A Heftia carrier that can be used as a handler for effect systems based
on [@classy-effects@](https://hackage.haskell.org/package/classy-effects).
-}
type HeftiaEffects h u es f = EffectsVia EffectDataHandler (HeftiaUnion h u es f)

-- | Unwrap the `HeftiaEffects` wrapper.
unHeftiaEffects :: HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnion h u es f a -> h (u es) f a
runHeftiaUnion forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (handlerSystem :: k) (f :: * -> *) a.
EffectsVia handlerSystem f a -> f a
runEffectsVia
{-# INLINE unHeftiaEffects #-}

-- | Wrap with `HeftiaEffects`.
heftiaEffects :: h (u es) f ~> HeftiaEffects h u es f
heftiaEffects :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects = forall {k} (handlerSystem :: k) (f :: * -> *) a.
f a -> EffectsVia handlerSystem f a
EffectsVia forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
h (u es) f a -> HeftiaUnion h u es f a
HeftiaUnion
{-# INLINE heftiaEffects #-}

{- |
A wrapper data type designed to induce instance resolution to delegate the search for first-order
effect classes to a lower carrier @f@ even when there are no target effect classes in the effect
class list @es@.

When a target effect class exists within @es@, @handleHere@ is induced to be @'True@; when it
doesn't exist, it's induced to be @'False@.
-}
newtype HeftiaUnionForSendIns handleHere h u es f a = HeftiaUnionForSendIns
    {forall {k} (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnion h u es f a
runHeftiaUnionForSendIns :: HeftiaUnion h u es f a}
    deriving newtype (forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
(a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
forall a b.
a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
forall a b.
(a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b.
a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
$c<$ :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
fmap :: forall a b.
(a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
$cfmap :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Functor (h (u es) f) =>
(a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
Functor, forall a. a -> HeftiaUnionForSendIns handleHere h u es f a
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Applicative (h (u es) f) =>
Functor (HeftiaUnionForSendIns handleHere h u es f)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Applicative (h (u es) f) =>
a -> HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f (a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b c.
Applicative (h (u es) f) =>
(a -> b -> c)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f c
forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
forall a b.
HeftiaUnionForSendIns handleHere h u es f (a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
forall a b c.
(a -> b -> c)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f 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 a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
$c<* :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f a
*> :: forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
$c*> :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
liftA2 :: forall a b c.
(a -> b -> c)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f c
$cliftA2 :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b c.
Applicative (h (u es) f) =>
(a -> b -> c)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f c
<*> :: forall a b.
HeftiaUnionForSendIns handleHere h u es f (a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
$c<*> :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Applicative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f (a -> b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
pure :: forall a. a -> HeftiaUnionForSendIns handleHere h u es f a
$cpure :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Applicative (h (u es) f) =>
a -> HeftiaUnionForSendIns handleHere h u es f a
Applicative, forall a. HeftiaUnionForSendIns handleHere h u es f a
forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Alternative (h (u es) f) =>
Applicative (HeftiaUnionForSendIns handleHere h u es f)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f 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
many :: forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
$cmany :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
some :: forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
$csome :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f [a]
<|> :: forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
$c<|> :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
empty :: forall a. HeftiaUnionForSendIns handleHere h u es f a
$cempty :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Alternative (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
Alternative, forall a. a -> HeftiaUnionForSendIns handleHere h u es f a
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Monad (h (u es) f) =>
Applicative (HeftiaUnionForSendIns handleHere h u es f)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Monad (h (u es) f) =>
a -> HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> (a -> HeftiaUnionForSendIns handleHere h u es f b)
-> HeftiaUnionForSendIns handleHere h u es f b
forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> (a -> HeftiaUnionForSendIns handleHere h u es f b)
-> HeftiaUnionForSendIns handleHere h u es f 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 :: forall a. a -> HeftiaUnionForSendIns handleHere h u es f a
$creturn :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Monad (h (u es) f) =>
a -> HeftiaUnionForSendIns handleHere h u es f a
>> :: forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
$c>> :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f b
-> HeftiaUnionForSendIns handleHere h u es f b
>>= :: forall a b.
HeftiaUnionForSendIns handleHere h u es f a
-> (a -> HeftiaUnionForSendIns handleHere h u es f b)
-> HeftiaUnionForSendIns handleHere h u es f b
$c>>= :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Monad (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> (a -> HeftiaUnionForSendIns handleHere h u es f b)
-> HeftiaUnionForSendIns handleHere h u es f b
Monad, forall a. HeftiaUnionForSendIns handleHere h u es f a
forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
MonadPlus (h (u es) f) =>
Monad (HeftiaUnionForSendIns handleHere h u es f)
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
MonadPlus (h (u es) f) =>
Alternative (HeftiaUnionForSendIns handleHere h u es f)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
mplus :: forall a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
$cmplus :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
mzero :: forall a. HeftiaUnionForSendIns handleHere h u es f a
$cmzero :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
MonadPlus (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a
MonadPlus)
    deriving stock (forall a. HeftiaUnionForSendIns handleHere h u es f a -> Bool
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Eq a) =>
a -> HeftiaUnionForSendIns handleHere h u es f a -> Bool
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       m.
(Foldable (h (u es) f), Monoid m) =>
HeftiaUnionForSendIns handleHere h u es f m -> m
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> Bool
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> Int
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> [a]
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnionForSendIns handleHere h u es f a -> a
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
forall m a.
Monoid m =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
forall a b.
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => HeftiaUnionForSendIns handleHere h u es f a -> a
$cproduct :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
sum :: forall a. Num a => HeftiaUnionForSendIns handleHere h u es f a -> a
$csum :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Num a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
minimum :: forall a. Ord a => HeftiaUnionForSendIns handleHere h u es f a -> a
$cminimum :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
maximum :: forall a. Ord a => HeftiaUnionForSendIns handleHere h u es f a -> a
$cmaximum :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Ord a) =>
HeftiaUnionForSendIns handleHere h u es f a -> a
elem :: forall a.
Eq a =>
a -> HeftiaUnionForSendIns handleHere h u es f a -> Bool
$celem :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
(Foldable (h (u es) f), Eq a) =>
a -> HeftiaUnionForSendIns handleHere h u es f a -> Bool
length :: forall a. HeftiaUnionForSendIns handleHere h u es f a -> Int
$clength :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> Int
null :: forall a. HeftiaUnionForSendIns handleHere h u es f a -> Bool
$cnull :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> Bool
toList :: forall a. HeftiaUnionForSendIns handleHere h u es f a -> [a]
$ctoList :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
HeftiaUnionForSendIns handleHere h u es f a -> [a]
foldl1 :: forall a.
(a -> a -> a) -> HeftiaUnionForSendIns handleHere h u es f a -> a
$cfoldl1 :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnionForSendIns handleHere h u es f a -> a
foldr1 :: forall a.
(a -> a -> a) -> HeftiaUnionForSendIns handleHere h u es f a -> a
$cfoldr1 :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
Foldable (h (u es) f) =>
(a -> a -> a) -> HeftiaUnionForSendIns handleHere h u es f a -> a
foldl' :: forall b a.
(b -> a -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
$cfoldl' :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
foldl :: forall b a.
(b -> a -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
$cfoldl :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) b
       a.
Foldable (h (u es) f) =>
(b -> a -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
foldr' :: forall a b.
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
$cfoldr' :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
foldr :: forall a b.
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
$cfoldr :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       b.
Foldable (h (u es) f) =>
(a -> b -> b)
-> b -> HeftiaUnionForSendIns handleHere h u es f a -> b
foldMap' :: forall m a.
Monoid m =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
$cfoldMap' :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
foldMap :: forall m a.
Monoid m =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
$cfoldMap :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) m
       a.
(Foldable (h (u es) f), Monoid m) =>
(a -> m) -> HeftiaUnionForSendIns handleHere h u es f a -> m
fold :: forall m.
Monoid m =>
HeftiaUnionForSendIns handleHere h u es f m -> m
$cfold :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       m.
(Foldable (h (u es) f), Monoid m) =>
HeftiaUnionForSendIns handleHere h u es f m -> m
Foldable, forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Traversable (h (u es) f) =>
Functor (HeftiaUnionForSendIns handleHere h u es f)
forall {k} {handleHere :: k} {h :: Signature -> Signature}
       {u :: [Signature] -> Signature} {es :: [Signature]} {f :: * -> *}.
Traversable (h (u es) f) =>
Foldable (HeftiaUnionForSendIns handleHere h u es f)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a.
(Traversable (h (u es) f), Monad m) =>
HeftiaUnionForSendIns handleHere h u es f (m a)
-> m (HeftiaUnionForSendIns handleHere h u es f a)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a.
(Traversable (h (u es) f), Applicative f) =>
HeftiaUnionForSendIns handleHere h u es f (f a)
-> f (HeftiaUnionForSendIns handleHere h u es f a)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a b.
(Traversable (h (u es) f), Monad m) =>
(a -> m b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> m (HeftiaUnionForSendIns handleHere h u es f b)
forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a b.
(Traversable (h (u es) f), Applicative f) =>
(a -> f b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> f (HeftiaUnionForSendIns handleHere h u es f b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> f (HeftiaUnionForSendIns handleHere h u es f b)
sequence :: forall (m :: * -> *) a.
Monad m =>
HeftiaUnionForSendIns handleHere h u es f (m a)
-> m (HeftiaUnionForSendIns handleHere h u es f a)
$csequence :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a.
(Traversable (h (u es) f), Monad m) =>
HeftiaUnionForSendIns handleHere h u es f (m a)
-> m (HeftiaUnionForSendIns handleHere h u es f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> m (HeftiaUnionForSendIns handleHere h u es f b)
$cmapM :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (m :: * -> *) a b.
(Traversable (h (u es) f), Monad m) =>
(a -> m b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> m (HeftiaUnionForSendIns handleHere h u es f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
HeftiaUnionForSendIns handleHere h u es f (f a)
-> f (HeftiaUnionForSendIns handleHere h u es f a)
$csequenceA :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a.
(Traversable (h (u es) f), Applicative f) =>
HeftiaUnionForSendIns handleHere h u es f (f a)
-> f (HeftiaUnionForSendIns handleHere h u es f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> f (HeftiaUnionForSendIns handleHere h u es f b)
$ctraverse :: forall k (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (f :: * -> *) a b.
(Traversable (h (u es) f), Applicative f) =>
(a -> f b)
-> HeftiaUnionForSendIns handleHere h u es f a
-> f (HeftiaUnionForSendIns handleHere h u es f b)
Traversable)

instance
    SendIns e (HeftiaUnionForSendIns (LiftIns e `IsMemberH` es) h u es f) =>
    SendIns e (HeftiaUnion h u es f)
    where
    sendIns :: forall a. e a -> HeftiaUnion h u es f a
sendIns = forall {k} (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnionForSendIns handleHere h u es f a
-> HeftiaUnion h u es f a
runHeftiaUnionForSendIns @(LiftIns e `IsMemberH` es) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ins :: * -> *) (f :: * -> *) a.
SendIns ins f =>
ins a -> f a
sendIns
    {-# INLINE sendIns #-}

instance
    (TransHeftia c h, UnionH u, MemberH u (LiftIns e) es, HFunctor (u es)) =>
    SendIns e (HeftiaUnionForSendIns 'True h u es f)
    where
    sendIns :: forall a. e a -> HeftiaUnionForSendIns 'True h u es f a
sendIns = forall {k} (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnion h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
HeftiaUnionForSendIns forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
h (u es) f a -> HeftiaUnion h u es f a
HeftiaUnion forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, HasMembershipH u h hs) =>
h f ~> u hs f
injectH forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ins :: * -> *) (f :: * -> *) a. ins a -> LiftIns ins f a
LiftIns
    {-# INLINE sendIns #-}

instance
    (TransHeftia c h, SendIns e f, c f, HFunctor (u es)) =>
    SendIns e (HeftiaUnionForSendIns 'False h u es f)
    where
    sendIns :: forall a. e a -> HeftiaUnionForSendIns 'False h u es f a
sendIns = forall {k} (handleHere :: k) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnion h u es f a
-> HeftiaUnionForSendIns handleHere h u es f a
HeftiaUnionForSendIns forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
h (u es) f a -> HeftiaUnion h u es f a
HeftiaUnion forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *).
(TransHeftia c h, c f, HFunctor sig) =>
f ~> h sig f
liftLowerHT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ins :: * -> *) (f :: * -> *) a.
SendIns ins f =>
ins a -> f a
sendIns
    {-# INLINE sendIns #-}

instance
    (TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es)) =>
    SendSig e (HeftiaUnion h u es f)
    where
    sendSig :: forall a. e (HeftiaUnion h u es f) a -> HeftiaUnion h u es f a
sendSig = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
h (u es) f a -> HeftiaUnion h u es f a
HeftiaUnion forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       a.
HeftiaUnion h u es f a -> h (u es) f a
runHeftiaUnion forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, HasMembershipH u h hs) =>
h f ~> u hs f
injectH
    {-# INLINE sendSig #-}

-- | Elaborate all effects in the effect class list at once.
runElaborate ::
    (TransHeftia c h, HFunctor (u es), c f, UnionH u) =>
    (u es f ~> f) ->
    HeftiaEffects h u es f ~> f
runElaborate :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
(TransHeftia c h, HFunctor (u es), c f, UnionH u) =>
(u es f ~> f) -> HeftiaEffects h u es f ~> f
runElaborate u es f ~> f
f = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, HFunctor sig) =>
(sig f ~> f) -> h sig f ~> f
runElaborateH u es f ~> f
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE runElaborate #-}

-- | Elaborate all effects in the effect class list using a delimited continuation.
runElaborateK ::
    (MonadTransHeftia h, HFunctor (u es), UnionH u, Monad m) =>
    (a -> m r) ->
    (forall x. (x -> m r) -> u es (ContT r m) x -> m r) ->
    HeftiaEffects h u es m a ->
    m r
runElaborateK :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (m :: * -> *) a
       r.
(MonadTransHeftia h, HFunctor (u es), UnionH u, Monad m) =>
(a -> m r)
-> (forall x. (x -> m r) -> u es (ContT r m) x -> m r)
-> HeftiaEffects h u es m a
-> m r
runElaborateK a -> m r
k forall x. (x -> m r) -> u es (ContT r m) x -> m r
f = (forall {k} (r :: k) (m :: k -> *) a.
ContT r m a -> (a -> m r) -> m r
`runContT` a -> m r
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (m :: * -> *)
       r.
(MonadTransHeftia h, HFunctor (u es), UnionH u, Monad m) =>
(u es (ContT r m) ~> ContT r m)
-> HeftiaEffects h u es m ~> ContT r m
runElaborateContT \u es (ContT r m) x
e -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall x. (x -> m r) -> u es (ContT r m) x -> m r
`f` u es (ContT r m) x
e)
{-# INLINE runElaborateK #-}

{- |
Elaborate all effects in the effect class list using a continuation monad transformer.
-}
runElaborateContT ::
    (MonadTransHeftia h, HFunctor (u es), UnionH u, Monad m) =>
    (u es (ContT r m) ~> ContT r m) ->
    HeftiaEffects h u es m ~> ContT r m
runElaborateContT :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (m :: * -> *)
       r.
(MonadTransHeftia h, HFunctor (u es), UnionH u, Monad m) =>
(u es (ContT r m) ~> ContT r m)
-> HeftiaEffects h u es m ~> ContT r m
runElaborateContT u es (ContT r m) ~> ContT r m
f = forall (h :: Signature -> Signature) (m :: * -> *)
       (sig :: Signature) r.
(MonadTransHeftia h, Monad m, HFunctor sig) =>
(sig (ContT r m) ~> ContT r m) -> h sig m ~> ContT r m
elaborateMK u es (ContT r m) ~> ContT r m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE runElaborateContT #-}

{- |
Elaborate all effects in the effect class list using a monad transformer.
-}
runElaborateT ::
    (MonadTransHeftia h, HFunctor (u es), UnionH u, MonadTrans t, Monad m, Monad (t m)) =>
    (u es (t m) ~> t m) ->
    HeftiaEffects h u es m ~> t m
runElaborateT :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature])
       (t :: Signature) (m :: * -> *).
(MonadTransHeftia h, HFunctor (u es), UnionH u, MonadTrans t,
 Monad m, Monad (t m)) =>
(u es (t m) ~> t m) -> HeftiaEffects h u es m ~> t m
runElaborateT u es (t m) ~> t m
f = forall (h :: Signature -> Signature) (m :: * -> *) (t :: Signature)
       (sig :: Signature).
(MonadTransHeftia h, Monad m, MonadTrans t, Monad (t m),
 HFunctor sig) =>
(sig (t m) ~> t m) -> h sig m ~> t m
elaborateMT u es (t m) ~> t m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE runElaborateT #-}

{- |
Elaborate all effects in the effect class list and the underlying carrier simultaneously,
transforming them into any carrier @g@.
-}
elaborate ::
    (TransHeftia c h, HFunctor (u es), c f, UnionH u, c g) =>
    (f ~> g) ->
    (u es g ~> g) ->
    HeftiaEffects h u es f ~> g
elaborate :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (g :: * -> *).
(TransHeftia c h, HFunctor (u es), c f, UnionH u, c g) =>
(f ~> g) -> (u es g ~> g) -> HeftiaEffects h u es f ~> g
elaborate f ~> g
f u es g ~> g
g = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (g :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, c g, HFunctor sig) =>
(f ~> g) -> (sig g ~> g) -> h sig f ~> g
elaborateHT f ~> g
f u es g ~> g
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE elaborate #-}

-- | Elaborate the leading effect class in the effect class list.
interpretH ::
    (TransHeftia c h, UnionH u, HFunctor (u es), HFunctor (u (e : es)), HFunctor e, c f) =>
    (e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f) ->
    HeftiaEffects h u (e ': es) f ~> HeftiaEffects h u es f
interpretH :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature])
       (e :: Signature) (f :: * -> *).
(TransHeftia c h, UnionH u, HFunctor (u es), HFunctor (u (e : es)),
 HFunctor e, c f) =>
(e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f)
-> HeftiaEffects h u (e : es) f ~> HeftiaEffects h u es f
interpretH e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f
i =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (g :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, c g, HFunctor sig) =>
(f ~> g) -> (sig g ~> g) -> h sig f ~> g
elaborateHT forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *).
(TransHeftia c h, c f, HFunctor sig) =>
f ~> h sig f
liftLowerHT \u (e : es) (h (u es) f) x
u ->
        case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
UnionH u =>
u (h : hs) f a -> Either (h f a) (u hs f a)
decompH u (e : es) (h (u es) f) x
u of
            Left e (h (u es) f) x
e -> forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall a b. (a -> b) -> a -> b
$ e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f
i forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects e (h (u es) f) x
e
            Right u es (h (u es) f) x
e -> forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT u es (h (u es) f) x
e

-- | Re-elaborate the leading effect class in the effect class list.
reinterpretH ::
    (TransHeftia c h, UnionH u, HFunctor (u (e : es)), HFunctor e, c f) =>
    (e (HeftiaEffects h u (e ': es) f) ~> HeftiaEffects h u (e ': es) f) ->
    HeftiaEffects h u (e ': es) f ~> HeftiaEffects h u (e ': es) f
reinterpretH :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (e :: Signature)
       (es :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, HFunctor (u (e : es)), HFunctor e,
 c f) =>
(e (HeftiaEffects h u (e : es) f) ~> HeftiaEffects h u (e : es) f)
-> HeftiaEffects h u (e : es) f ~> HeftiaEffects h u (e : es) f
reinterpretH e (HeftiaEffects h u (e : es) f) ~> HeftiaEffects h u (e : es) f
i =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, HFunctor sig) =>
(sig (h sig f) ~> h sig f) -> h sig f ~> h sig f
reelaborateHT \u (e : es) (h (u (e : es)) f) x
u ->
        case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
UnionH u =>
u (h : hs) f a -> Either (h f a) (u hs f a)
decompH u (e : es) (h (u (e : es)) f) x
u of
            Left e (h (u (e : es)) f) x
e -> forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall a b. (a -> b) -> a -> b
$ e (HeftiaEffects h u (e : es) f) ~> HeftiaEffects h u (e : es) f
i forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects e (h (u (e : es)) f) x
e
            Right u es (h (u (e : es)) f) x
e -> forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT forall a b. (a -> b) -> a -> b
$ forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h :: Signature).
UnionH u =>
u hs f ~> u (h : hs) f
weakenH u es (h (u (e : es)) f) x
e

-- | Transform all effect classes in the effect class list into another union of effect classes.
transformAllH ::
    ( TransHeftia c h
    , UnionH u
    , UnionH u'
    , HFunctor (u es)
    , HFunctor (u' es')
    , c f
    ) =>
    (forall g. u es g ~> u' es' g) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (g :: * -> *). u es g ~> u' es' g
f = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature) (sig' :: Signature).
(TransHeftia c h, c f, HFunctor sig, HFunctor sig') =>
(forall (g :: * -> *). sig g ~> sig' g) -> h sig f ~> h sig' f
transformHT forall (g :: * -> *). u es g ~> u' es' g
f
{-# INLINE transformAllH #-}

-- | Transform the leading effect class in the effect class list into another effect class.
transformH ::
    forall e' e h u r f c.
    ( TransHeftia c h
    , UnionH u
    , c f
    , HFunctor (u (e : r))
    , HFunctor (u (e' : r))
    ) =>
    (forall g. e g ~> e' g) ->
    HeftiaEffects h u (e ': r) f ~> HeftiaEffects h u (e' ': r) f
transformH :: forall (e' :: Signature) (e :: Signature)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (r :: [Signature]) (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, c f, HFunctor (u (e : r)),
 HFunctor (u (e' : r))) =>
(forall (g :: * -> *). e g ~> e' g)
-> HeftiaEffects h u (e : r) f ~> HeftiaEffects h u (e' : r) f
transformH forall (g :: * -> *). e g ~> e' g
f = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature) (sig' :: Signature).
(TransHeftia c h, c f, HFunctor sig, HFunctor sig') =>
(sig (h sig' f) ~> sig' (h sig' f)) -> h sig f ~> h sig' f
translateT \u (e : r) (h (u (e' : r)) f) x
u ->
    case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
UnionH u =>
u (h : hs) f a -> Either (h f a) (u hs f a)
decompH u (e : r) (h (u (e' : r)) f) x
u of
        Left e (h (u (e' : r)) f) x
e -> forall (u :: [Signature] -> Signature) (h :: Signature)
       (f :: * -> *) (hs :: [Signature]).
UnionH u =>
h f ~> u (h : hs) f
inject0H forall a b. (a -> b) -> a -> b
$ forall (g :: * -> *). e g ~> e' g
f e (h (u (e' : r)) f) x
e
        Right u r (h (u (e' : r)) f) x
e -> forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h :: Signature).
UnionH u =>
u hs f ~> u (h : hs) f
weakenH u r (h (u (e' : r)) f) x
e

-- | Remove the tag attached to the effect class.
untagH ::
    forall tag e h u r f c.
    ( TransHeftia c h
    , UnionH u
    , c f
    , HFunctor (u (e : r))
    , HFunctor (u (TagH e tag : r))
    ) =>
    HeftiaEffects h u (TagH e tag ': r) f ~> HeftiaEffects h u (e ': r) f
untagH :: forall {k} (tag :: k) (e :: Signature)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (r :: [Signature]) (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, c f, HFunctor (u (e : r)),
 HFunctor (u (TagH e tag : r))) =>
HeftiaEffects h u (TagH e tag : r) f ~> HeftiaEffects h u (e : r) f
untagH = forall (e' :: Signature) (e :: Signature)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (r :: [Signature]) (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, c f, HFunctor (u (e : r)),
 HFunctor (u (e' : r))) =>
(forall (g :: * -> *). e g ~> e' g)
-> HeftiaEffects h u (e : r) f ~> HeftiaEffects h u (e' : r) f
transformH forall {k} (sig :: Signature) (tag :: k) (f :: * -> *) a.
TagH sig tag f a -> sig f a
getTagH

-- | Transform the leading effect class in the effect class list into another effect class.
translate ::
    forall e' e h u r f c.
    ( TransHeftia c h
    , UnionH u
    , HFunctor (u (e : r))
    , HFunctor (u (e' : r))
    , HFunctor e
    , HFunctor e'
    , c f
    ) =>
    (e (HeftiaEffects h u (e' ': r) f) ~> e' (HeftiaEffects h u (e' ': r) f)) ->
    HeftiaEffects h u (e ': r) f ~> HeftiaEffects h u (e' ': r) f
translate :: forall (e' :: Signature) (e :: Signature)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (r :: [Signature]) (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, HFunctor (u (e : r)),
 HFunctor (u (e' : r)), HFunctor e, HFunctor e', c f) =>
(e (HeftiaEffects h u (e' : r) f)
 ~> e' (HeftiaEffects h u (e' : r) f))
-> HeftiaEffects h u (e : r) f ~> HeftiaEffects h u (e' : r) f
translate e (HeftiaEffects h u (e' : r) f)
~> e' (HeftiaEffects h u (e' : r) f)
f =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature) (sig' :: Signature).
(TransHeftia c h, c f, HFunctor sig, HFunctor sig') =>
(sig (h sig' f) ~> sig' (h sig' f)) -> h sig f ~> h sig' f
translateT \u (e : r) (h (u (e' : r)) f) x
u ->
        case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
UnionH u =>
u (h : hs) f a -> Either (h f a) (u hs f a)
decompH u (e : r) (h (u (e' : r)) f) x
u of
            Left e (h (u (e' : r)) f) x
e -> forall (u :: [Signature] -> Signature) (h :: Signature)
       (f :: * -> *) (hs :: [Signature]).
UnionH u =>
h f ~> u (h : hs) f
inject0H forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall a b. (a -> b) -> a -> b
$ e (HeftiaEffects h u (e' : r) f)
~> e' (HeftiaEffects h u (e' : r) f)
f forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects e (h (u (e' : r)) f) x
e
            Right u r (h (u (e' : r)) f) x
e -> forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h :: Signature).
UnionH u =>
u hs f ~> u (h : hs) f
weakenH u r (h (u (e' : r)) f) x
e

-- | Transform all effect classes in the effect class list into another union of effect classes.
translateAll ::
    ( TransHeftia c h
    , UnionH u
    , UnionH u'
    , HFunctor (u es)
    , HFunctor (u' es')
    , c f
    ) =>
    (u es (HeftiaEffects h u' es' f) ~> u' es' (HeftiaEffects h u' es' f)) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
translateAll :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(u es (HeftiaEffects h u' es' f)
 ~> u' es' (HeftiaEffects h u' es' f))
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
translateAll u es (HeftiaEffects h u' es' f)
~> u' es' (HeftiaEffects h u' es' f)
f =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature) (sig' :: Signature).
(TransHeftia c h, c f, HFunctor sig, HFunctor sig') =>
(sig (h sig' f) ~> sig' (h sig' f)) -> h sig f ~> h sig' f
translateT (forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. u es (HeftiaEffects h u' es' f)
~> u' es' (HeftiaEffects h u' es' f)
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects)
{-# INLINE translateAll #-}

-- | Interpose the effect class that exists within the effect class list using a monad transformer.
interposeH ::
    forall e h u es f c.
    (TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es), c f) =>
    (e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u es f
interposeH :: forall (e :: Signature) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es),
 c f) =>
(e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f)
-> HeftiaEffects h u es f ~> HeftiaEffects h u es f
interposeH e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f
f =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, HFunctor sig) =>
(sig (h sig f) ~> h sig f) -> h sig f ~> h sig f
reelaborateHT \u es (h (u es) f) x
u ->
        let u' :: u es (HeftiaEffects h u es f) x
u' = forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap (forall (e :: Signature) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es),
 c f) =>
(e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f)
-> HeftiaEffects h u es f ~> HeftiaEffects h u es f
interposeH e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects) u es (h (u es) f) x
u
         in case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
(UnionH u, HasMembershipH u h hs) =>
u hs f a -> Maybe (h f a)
projectH @_ @e u es (HeftiaEffects h u es f) x
u' of
                Just e (HeftiaEffects h u es f) x
e -> forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall a b. (a -> b) -> a -> b
$ e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f
f e (HeftiaEffects h u es f) x
e
                Maybe (e (HeftiaEffects h u es f) x)
Nothing -> forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects u es (HeftiaEffects h u es f) x
u'

-- | Transform the effect of the effect class that exists within the effect class list.
interceptH ::
    forall e h u es f c.
    (TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es), HFunctor e, c f) =>
    (e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f)) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u es f
interceptH :: forall (e :: Signature) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es),
 HFunctor e, c f) =>
(e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f))
-> HeftiaEffects h u es f ~> HeftiaEffects h u es f
interceptH e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f)
f =
    forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature) (sig' :: Signature).
(TransHeftia c h, c f, HFunctor sig, HFunctor sig') =>
(sig (h sig' f) ~> sig' (h sig' f)) -> h sig f ~> h sig' f
translateT \u es (h (u es) f) x
u ->
        let u' :: u es (HeftiaEffects h u es f) x
u' = forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap (forall (e :: Signature) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, UnionH u, MemberH u e es, HFunctor (u es),
 HFunctor e, c f) =>
(e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f))
-> HeftiaEffects h u es f ~> HeftiaEffects h u es f
interceptH e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f)
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects) u es (h (u es) f) x
u
         in case forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *) a.
(UnionH u, HasMembershipH u h hs) =>
u hs f a -> Maybe (h f a)
projectH @_ @e u es (HeftiaEffects h u es f) x
u' of
                Just e (HeftiaEffects h u es f) x
e -> forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, HasMembershipH u h hs) =>
h f ~> u hs f
injectH forall a b. (a -> b) -> a -> b
$ forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall a b. (a -> b) -> a -> b
$ e (HeftiaEffects h u es f) ~> e (HeftiaEffects h u es f)
f e (HeftiaEffects h u es f) x
e
                Maybe (e (HeftiaEffects h u es f) x)
Nothing -> forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects u es (HeftiaEffects h u es f) x
u'

-- | Insert an arbitrary effect class at the beginning of the effect class list.
raiseH ::
    forall e hs h u f c.
    ( TransHeftia c h
    , HFunctor (u hs)
    , HFunctor (u (e ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u hs f ~> HeftiaEffects h u (e ': hs) f
raiseH :: forall (e :: Signature) (hs :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u hs), HFunctor (u (e : hs)), c f,
 UnionH u) =>
HeftiaEffects h u hs f ~> HeftiaEffects h u (e : hs) f
raiseH = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h :: Signature).
UnionH u =>
u hs f ~> u (h : hs) f
weakenH
{-# INLINE raiseH #-}

-- | Insert two arbitrary effect classes at the beginning of the effect class list.
raise2H ::
    forall e1 e2 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u hs)
    , HFunctor (u (e1 ': e2 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u hs f ~> HeftiaEffects h u (e1 ': e2 ': hs) f
raise2H :: forall (e1 :: Signature) (e2 :: Signature) (hs :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u hs), HFunctor (u (e1 : e2 : hs)),
 c f, UnionH u) =>
HeftiaEffects h u hs f ~> HeftiaEffects h u (e1 : e2 : hs) f
raise2H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h1 :: Signature) (h2 :: Signature).
UnionH u =>
u hs f ~> u (h1 : h2 : hs) f
weaken2H
{-# INLINE raise2H #-}

-- | Insert three arbitrary effect classes at the beginning of the effect class list.
raise3H ::
    forall e1 e2 e3 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u hs)
    , HFunctor (u (e1 ': e2 ': e3 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u hs f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': hs) f
raise3H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u hs),
 HFunctor (u (e1 : e2 : e3 : hs)), c f, UnionH u) =>
HeftiaEffects h u hs f ~> HeftiaEffects h u (e1 : e2 : e3 : hs) f
raise3H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h1 :: Signature) (h2 :: Signature)
       (h3 :: Signature).
UnionH u =>
u hs f ~> u (h1 : h2 : h3 : hs) f
weaken3H
{-# INLINE raise3H #-}

-- | Insert four arbitrary effect classes at the beginning of the effect class list.
raise4H ::
    forall e1 e2 e3 e4 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u hs)
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u hs f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': hs) f
raise4H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (e4 :: Signature) (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u hs),
 HFunctor (u (e1 : e2 : e3 : e4 : hs)), c f, UnionH u) =>
HeftiaEffects h u hs f
~> HeftiaEffects h u (e1 : e2 : e3 : e4 : hs) f
raise4H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (hs :: [Signature])
       (f :: * -> *) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature)
       (h4 :: Signature).
UnionH u =>
u hs f ~> u (h1 : h2 : h3 : h4 : hs) f
weaken4H
{-# INLINE raise4H #-}

-- | Insert an arbitrary effect class below the leading effect class in the effect class list.
raiseUnderH ::
    forall e1 e2 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': hs))
    , HFunctor (u (e1 ': e2 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': hs) f
raiseUnderH :: forall (e1 :: Signature) (e2 :: Signature) (hs :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : hs)),
 HFunctor (u (e1 : e2 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : hs) f ~> HeftiaEffects h u (e1 : e2 : hs) f
raiseUnderH = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (hs :: [Signature]) (f :: * -> *) (h2 :: Signature).
UnionH u =>
u (h1 : hs) f ~> u (h1 : h2 : hs) f
weakenUnderH
{-# INLINE raiseUnderH #-}

{- |
Insert an arbitrary effect class below the first two leading effect classes in the effect class
list.
-}
raiseUnder2H ::
    forall e1 e2 e3 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': hs))
    , HFunctor (u (e1 ': e2 ': e3 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': hs) f
raiseUnder2H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : hs)),
 HFunctor (u (e1 : e2 : e3 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : hs) f
~> HeftiaEffects h u (e1 : e2 : e3 : hs) f
raiseUnder2H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (hs :: [Signature]) (f :: * -> *)
       (h3 :: Signature).
UnionH u =>
u (h1 : h2 : hs) f ~> u (h1 : h2 : h3 : hs) f
weakenUnder2H
{-# INLINE raiseUnder2H #-}

{- |
Insert an arbitrary effect class below the first three leading effect classes in the effect class list.
-}
raiseUnder3H ::
    forall e1 e2 e3 e4 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': hs))
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': hs) f
raiseUnder3H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (e4 :: Signature) (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : hs)),
 HFunctor (u (e1 : e2 : e3 : e4 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : e3 : hs) f
~> HeftiaEffects h u (e1 : e2 : e3 : e4 : hs) f
raiseUnder3H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *) (h4 :: Signature).
UnionH u =>
u (h1 : h2 : h3 : hs) f ~> u (h1 : h2 : h3 : h4 : hs) f
weakenUnder3H
{-# INLINE raiseUnder3H #-}

-- | Insert two arbitrary effect classes below the leading effect class in the effect class list.
raise2UnderH ::
    forall e1 e2 e3 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': hs))
    , HFunctor (u (e1 ': e2 ': e3 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': hs) f
raise2UnderH :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : hs)),
 HFunctor (u (e1 : e2 : e3 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : hs) f
~> HeftiaEffects h u (e1 : e2 : e3 : hs) f
raise2UnderH = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (hs :: [Signature]) (f :: * -> *) (h2 :: Signature)
       (h3 :: Signature).
UnionH u =>
u (h1 : hs) f ~> u (h1 : h2 : h3 : hs) f
weaken2UnderH
{-# INLINE raise2UnderH #-}

{- |
Insert two arbitrary effect classes below the first two leading effect classes in the effect class list.
-}
raise2Under2H ::
    forall e1 e2 e3 e4 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': hs))
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': hs) f
raise2Under2H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (e4 :: Signature) (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : hs)),
 HFunctor (u (e1 : e2 : e3 : e4 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : hs) f
~> HeftiaEffects h u (e1 : e2 : e3 : e4 : hs) f
raise2Under2H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (hs :: [Signature]) (f :: * -> *)
       (h3 :: Signature) (h4 :: Signature).
UnionH u =>
u (h1 : h2 : hs) f ~> u (h1 : h2 : h3 : h4 : hs) f
weaken2Under2H
{-# INLINE raise2Under2H #-}

-- | Inserts three arbitrary effect classes under the top effect class in the effect class list.
raise3UnderH ::
    forall e1 e2 e3 e4 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': hs))
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': hs) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': hs) f
raise3UnderH :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (e4 :: Signature) (hs :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : hs)),
 HFunctor (u (e1 : e2 : e3 : e4 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : hs) f
~> HeftiaEffects h u (e1 : e2 : e3 : e4 : hs) f
raise3UnderH = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (hs :: [Signature]) (f :: * -> *) (h2 :: Signature)
       (h3 :: Signature) (h4 :: Signature).
UnionH u =>
u (h1 : hs) f ~> u (h1 : h2 : h3 : h4 : hs) f
weaken3UnderH
{-# INLINE raise3UnderH #-}

-- | Swaps the top two effect classes in the effect class list.
flipHeftia ::
    forall e1 e2 hs h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': hs))
    , HFunctor (u (e2 ': e1 ': hs))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': hs) f ~> HeftiaEffects h u (e2 ': e1 ': hs) f
flipHeftia :: forall (e1 :: Signature) (e2 :: Signature) (hs :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : hs)),
 HFunctor (u (e2 : e1 : hs)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : hs) f
~> HeftiaEffects h u (e2 : e1 : hs) f
flipHeftia = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (hs :: [Signature]) (f :: * -> *).
UnionH u =>
u (h1 : h2 : hs) f ~> u (h2 : h1 : hs) f
flipUnionH
{-# INLINE flipHeftia #-}

-- | Reverses the order of the top three effect classes in the effect class list.
flipHeftia3 ::
    forall e1 e2 e3 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (e3 : e2 : e1 : es))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': es) f ~> HeftiaEffects h u (e3 ': e2 ': e1 ': es) f
flipHeftia3 :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (e3 : e2 : e1 : es)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : e3 : es) f
~> HeftiaEffects h u (e3 : e2 : e1 : es) f
flipHeftia3 = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
UnionH u =>
u (h1 : h2 : h3 : hs) f ~> u (h3 : h2 : h1 : hs) f
flipUnion3H
{-# INLINE flipHeftia3 #-}

-- | Swaps the second and third effect classes from the top in the effect class list.
flipHeftiaUnder ::
    forall e1 e2 e3 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (e1 : e3 : e2 : es))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': es) f ~> HeftiaEffects h u (e1 ': e3 ': e2 ': es) f
flipHeftiaUnder :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (e1 : e3 : e2 : es)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : e3 : es) f
~> HeftiaEffects h u (e1 : e3 : e2 : es) f
flipHeftiaUnder = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
UnionH u =>
u (h1 : h2 : h3 : hs) f ~> u (h1 : h3 : h2 : hs) f
flipUnionUnderH
{-# INLINE flipHeftiaUnder #-}

-- | Rotates the top three effect classes in the effect class list to the left.
rotate3H ::
    forall e1 e2 e3 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (e2 : e3 : e1 : es))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': es) f ~> HeftiaEffects h u (e2 ': e3 ': e1 ': es) f
rotate3H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (e2 : e3 : e1 : es)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : e3 : es) f
~> HeftiaEffects h u (e2 : e3 : e1 : es) f
rotate3H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
UnionH u =>
u (h1 : h2 : h3 : hs) f ~> u (h2 : h3 : h1 : hs) f
rot3H
{-# INLINE rotate3H #-}

-- | Rotates the top three effect classes in the effect class list to the left twice.
rotate3H' ::
    forall e1 e2 e3 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (e3 : e1 : e2 : es))
    , c f
    , UnionH u
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': es) f ~> HeftiaEffects h u (e3 ': e1 ': e2 ': es) f
rotate3H' :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (e3 : e1 : e2 : es)), c f, UnionH u) =>
HeftiaEffects h u (e1 : e2 : e3 : es) f
~> HeftiaEffects h u (e3 : e1 : e2 : es) f
rotate3H' = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
UnionH u =>
u (h1 : h2 : h3 : hs) f ~> u (h3 : h1 : h2 : hs) f
rot3H'
{-# INLINE rotate3H' #-}

-- | Bundles the top two effect classes in the effect class list into any open union.
bundle2H ::
    forall u' e1 e2 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': es))
    , HFunctor (u (u' '[e1, e2] ': es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (e1 ': e2 ': es) f ~> HeftiaEffects h u (u' '[e1, e2] ': es) f
bundle2H :: forall (u' :: [Signature] -> Signature) (e1 :: Signature)
       (e2 :: Signature) (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : es)),
 HFunctor (u (u' '[e1, e2] : es)), c f, UnionH u, UnionH u') =>
HeftiaEffects h u (e1 : e2 : es) f
~> HeftiaEffects h u (u' '[e1, e2] : es) f
bundle2H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (hs :: [Signature]) (f :: * -> *).
(UnionH u, UnionH u') =>
u (h1 : h2 : hs) f ~> u (u' '[h1, h2] : hs) f
bundleUnion2H
{-# INLINE bundle2H #-}

-- | Bundles the top three effect classes in the effect class list into any open union.
bundle3H ::
    forall u' e1 e2 e3 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (u' '[e1, e2, e3] : es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': es) f ~> HeftiaEffects h u (u' '[e1, e2, e3] ': es) f
bundle3H :: forall (u' :: [Signature] -> Signature) (e1 :: Signature)
       (e2 :: Signature) (e3 :: Signature) (es :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (u' '[e1, e2, e3] : es)), c f, UnionH u, UnionH u') =>
HeftiaEffects h u (e1 : e2 : e3 : es) f
~> HeftiaEffects h u (u' '[e1, e2, e3] : es) f
bundle3H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
(UnionH u, UnionH u') =>
u (h1 : h2 : h3 : hs) f ~> u (u' '[h1, h2, h3] : hs) f
bundleUnion3H
{-# INLINE bundle3H #-}

-- | Bundles the top four effect classes in the effect class list into any open union.
bundle4H ::
    forall u' e1 e2 e3 e4 es h u f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': es))
    , HFunctor (u (u' '[e1, e2, e3, e4] : es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': es) f
        ~> HeftiaEffects h u (u' '[e1, e2, e3, e4] ': es) f
bundle4H :: forall (u' :: [Signature] -> Signature) (e1 :: Signature)
       (e2 :: Signature) (e3 :: Signature) (e4 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : e4 : es)),
 HFunctor (u (u' '[e1, e2, e3, e4] : es)), c f, UnionH u,
 UnionH u') =>
HeftiaEffects h u (e1 : e2 : e3 : e4 : es) f
~> HeftiaEffects h u (u' '[e1, e2, e3, e4] : es) f
bundle4H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (h4 :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, UnionH u') =>
u (h1 : h2 : h3 : h4 : hs) f ~> u (u' '[h1, h2, h3, h4] : hs) f
bundleUnion4H
{-# INLINE bundle4H #-}

-- | Expands the open union at the top of the effect class list.
unbundle2H ::
    forall e1 e2 es h u u' f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': es))
    , HFunctor (u (u' '[e1, e2] ': es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (u' '[e1, e2] ': es) f ~> HeftiaEffects h u (e1 ': e2 ': es) f
unbundle2H :: forall (e1 :: Signature) (e2 :: Signature) (es :: [Signature])
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : es)),
 HFunctor (u (u' '[e1, e2] : es)), c f, UnionH u, UnionH u') =>
HeftiaEffects h u (u' '[e1, e2] : es) f
~> HeftiaEffects h u (e1 : e2 : es) f
unbundle2H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (hs :: [Signature]) (f :: * -> *).
(UnionH u, UnionH u') =>
u (u' '[h1, h2] : hs) f ~> u (h1 : h2 : hs) f
unbundleUnion2H
{-# INLINE unbundle2H #-}

-- | Expands the open union at the top of the effect class list.
unbundle3H ::
    forall e1 e2 e3 es h u u' f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': es))
    , HFunctor (u (u' '[e1, e2, e3] ': es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (u' '[e1, e2, e3] ': es) f ~> HeftiaEffects h u (e1 ': e2 ': e3 ': es) f
unbundle3H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : es)),
 HFunctor (u (u' '[e1, e2, e3] : es)), c f, UnionH u, UnionH u') =>
HeftiaEffects h u (u' '[e1, e2, e3] : es) f
~> HeftiaEffects h u (e1 : e2 : e3 : es) f
unbundle3H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (hs :: [Signature])
       (f :: * -> *).
(UnionH u, UnionH u') =>
u (u' '[h1, h2, h3] : hs) f ~> u (h1 : h2 : h3 : hs) f
unbundleUnion3H
{-# INLINE unbundle3H #-}

-- | Expands the open union at the top of the effect class list.
unbundle4H ::
    forall e1 e2 e3 e4 es h u u' f c.
    ( TransHeftia c h
    , HFunctor (u (e1 ': e2 ': e3 ': e4 ': es))
    , HFunctor (u (u' '[e1, e2, e3, e4] ': es))
    , c f
    , UnionH u
    , UnionH u'
    ) =>
    HeftiaEffects h u (u' '[e1, e2, e3, e4] ': es) f
        ~> HeftiaEffects h u (e1 ': e2 ': e3 ': e4 ': es) f
unbundle4H :: forall (e1 :: Signature) (e2 :: Signature) (e3 :: Signature)
       (e4 :: Signature) (es :: [Signature]) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (f :: * -> *) (c :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u (e1 : e2 : e3 : e4 : es)),
 HFunctor (u (u' '[e1, e2, e3, e4] : es)), c f, UnionH u,
 UnionH u') =>
HeftiaEffects h u (u' '[e1, e2, e3, e4] : es) f
~> HeftiaEffects h u (e1 : e2 : e3 : e4 : es) f
unbundle4H = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (u' :: [Signature] -> Signature)
       (es :: [Signature]) (es' :: [Signature]) (f :: * -> *).
(TransHeftia c h, UnionH u, UnionH u', HFunctor (u es),
 HFunctor (u' es'), c f) =>
(forall (g :: * -> *). u es g ~> u' es' g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u' es' f
transformAllH forall (u :: [Signature] -> Signature)
       (u' :: [Signature] -> Signature) (h1 :: Signature)
       (h2 :: Signature) (h3 :: Signature) (h4 :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, UnionH u') =>
u (u' '[h1, h2, h3, h4] : hs) f ~> u (h1 : h2 : h3 : h4 : hs) f
unbundleUnion4H
{-# INLINE unbundle4H #-}

{- |
Transforms the lower carrier.

__Warning__: The given natural transformation must be a monad morphism
(see <https://hackage.haskell.org/package/mmorph-1.2.0/docs/Control-Monad-Morph.html>).
If not, the result will be ill-behaved.
-}
hoistHeftiaEffects ::
    (TransHeftia c h, HFunctor (u es), c f, c g) =>
    (f ~> g) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u es g
hoistHeftiaEffects :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (g :: * -> *).
(TransHeftia c h, HFunctor (u es), c f, c g) =>
(f ~> g) -> HeftiaEffects h u es f ~> HeftiaEffects h u es g
hoistHeftiaEffects f ~> g
f = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (g :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, c g, HFunctor sig) =>
(f ~> g) -> h sig f ~> h sig g
hoistHeftia f ~> g
f
{-# INLINE hoistHeftiaEffects #-}

-- | Accesses the inside of the 'HeftiaEffects' wrapper.
overHeftiaEffects ::
    (h (u es) f a -> h' (u' es') g b) ->
    HeftiaEffects h u es f a ->
    HeftiaEffects h' u' es' g b
overHeftiaEffects :: forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects h (u es) f a -> h' (u' es') g b
f = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. h (u es) f a -> h' (u' es') g b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE overHeftiaEffects #-}

{- |
Interpose the lower Freer carrier.

__Warning__: The given natural transformation must be a monad morphism
(see <https://hackage.haskell.org/package/mmorph-1.2.0/docs/Control-Monad-Morph.html>).
If not, the result will be ill-behaved.
-}
hoistInterpose ::
    forall e h u es fr u' es' f c c'.
    ( TransHeftia c h
    , HFunctor (u es)
    , TransFreer c' fr
    , Union u'
    , Member u' e es'
    , c (FreerEffects fr u' es' f)
    , c' f
    ) =>
    (e ~> FreerEffects fr u' es' f) ->
    HeftiaEffects h u es (FreerEffects fr u' es' f)
        ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
hoistInterpose :: forall (e :: * -> *) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature])
       (fr :: (* -> *) -> Signature) (u' :: [* -> *] -> * -> *)
       (es' :: [* -> *]) (f :: * -> *) (c :: (* -> *) -> Constraint)
       (c' :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u es), TransFreer c' fr, Union u',
 Member u' e es', c (FreerEffects fr u' es' f), c' f) =>
(e ~> FreerEffects fr u' es' f)
-> HeftiaEffects h u es (FreerEffects fr u' es' f)
   ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
hoistInterpose e ~> FreerEffects fr u' es' f
f = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *)
       (g :: * -> *).
(TransHeftia c h, HFunctor (u es), c f, c g) =>
(f ~> g) -> HeftiaEffects h u es f ~> HeftiaEffects h u es g
hoistHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (e :: * -> *) (fr :: (* -> *) -> Signature)
       (u :: [* -> *] -> * -> *) (es :: [* -> *]) (f :: * -> *)
       (c :: (* -> *) -> Constraint).
(TransFreer c fr, Union u, Member u e es, c f) =>
(e ~> FreerEffects fr u es f)
-> FreerEffects fr u es f ~> FreerEffects fr u es f
interpose e ~> FreerEffects fr u' es' f
f
{-# INLINE hoistInterpose #-}

{- |
Interpose the lower Freer carrier.

__Warning__: The given natural transformation must be a monad morphism
(see <https://hackage.haskell.org/package/mmorph-1.2.0/docs/Control-Monad-Morph.html>).
If not, the result will be ill-behaved.
-}
interposeLower ::
    forall e h u es fr u' es' f c c'.
    ( TransHeftia c h
    , HFunctor (u es)
    , TransFreer c' fr
    , Union u'
    , Member u' e es'
    , c (FreerEffects fr u' es' f)
    , c' f
    , c' (HeftiaEffects h u es (FreerEffects fr u' es' f))
    ) =>
    (e ~> HeftiaEffects h u es (FreerEffects fr u' es' f)) ->
    HeftiaEffects h u es (FreerEffects fr u' es' f)
        ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
interposeLower :: forall (e :: * -> *) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature])
       (fr :: (* -> *) -> Signature) (u' :: [* -> *] -> * -> *)
       (es' :: [* -> *]) (f :: * -> *) (c :: (* -> *) -> Constraint)
       (c' :: (* -> *) -> Constraint).
(TransHeftia c h, HFunctor (u es), TransFreer c' fr, Union u',
 Member u' e es', c (FreerEffects fr u' es' f), c' f,
 c' (HeftiaEffects h u es (FreerEffects fr u' es' f))) =>
(e ~> HeftiaEffects h u es (FreerEffects fr u' es' f))
-> HeftiaEffects h u es (FreerEffects fr u' es' f)
   ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
interposeLower e ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
f =
    forall (c :: (* -> *) -> Constraint) (f :: * -> *) (g :: * -> *)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (es :: [Signature]).
(c f, c g, TransHeftia c h, HFunctor (u es)) =>
(f ~> HeftiaEffects h u es g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u es g
interpretLowerH forall a b. (a -> b) -> a -> b
$
        forall (fr :: (* -> *) -> Signature) (u :: [* -> *] -> * -> *)
       (es :: [* -> *]) (f :: * -> *).
FreerEffects fr u es f ~> fr (u es) f
unFreerEffects
            forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall {k} (c :: (k -> *) -> Constraint)
       (fr :: (k -> *) -> (k -> *) -> k -> *) (f :: k -> *) (g :: k -> *)
       (ins :: k -> *).
(TransFreer c fr, c f, c g) =>
(f ~> g) -> (ins ~> g) -> fr ins f ~> g
interpretFT
                (forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (u :: [Signature] -> Signature) (es :: [Signature]).
(TransHeftia c h, c f, HFunctor (u es)) =>
f ~> HeftiaEffects h u es f
liftLowerH forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (fr :: (* -> *) -> Signature) (u :: [* -> *] -> * -> *)
       (es :: [* -> *]) (f :: * -> *).
fr (u es) f ~> FreerEffects fr u es f
freerEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (c :: (k -> *) -> Constraint)
       (fr :: (k -> *) -> (k -> *) -> k -> *) (ins :: k -> *)
       (f :: k -> *).
(TransFreer c fr, c f) =>
f ~> fr ins f
liftLowerFT)
                \u' es' x
u -> case forall (u :: [* -> *] -> * -> *) (f :: * -> *) (fs :: [* -> *]) a.
(Union u, HasMembership u f fs) =>
u fs a -> Maybe (f a)
project @_ @e u' es' x
u of
                    Just e x
e -> e ~> HeftiaEffects h u es (FreerEffects fr u' es' f)
f e x
e
                    Maybe (e x)
Nothing -> forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (u :: [Signature] -> Signature) (es :: [Signature]).
(TransHeftia c h, c f, HFunctor (u es)) =>
f ~> HeftiaEffects h u es f
liftLowerH forall a b. (a -> b) -> a -> b
$ forall (fr :: (* -> *) -> Signature) (u :: [* -> *] -> * -> *)
       (es :: [* -> *]) (f :: * -> *).
fr (u es) f ~> FreerEffects fr u es f
freerEffects forall a b. (a -> b) -> a -> b
$ forall {k} (c :: (k -> *) -> Constraint)
       (fr :: (k -> *) -> (k -> *) -> k -> *) (ins :: k -> *)
       (f :: k -> *).
TransFreer c fr =>
ins ~> fr ins f
liftInsT u' es' x
u

{- |
Interprets the lower carrier.

__Warning__: The given natural transformation must be a monad morphism
(see <https://hackage.haskell.org/package/mmorph-1.2.0/docs/Control-Monad-Morph.html>).
If not, the result will be ill-behaved.
-}
interpretLowerH ::
    (c f, c g, TransHeftia c h, HFunctor (u es)) =>
    (f ~> HeftiaEffects h u es g) ->
    HeftiaEffects h u es f ~> HeftiaEffects h u es g
interpretLowerH :: forall (c :: (* -> *) -> Constraint) (f :: * -> *) (g :: * -> *)
       (h :: Signature -> Signature) (u :: [Signature] -> Signature)
       (es :: [Signature]).
(c f, c g, TransHeftia c h, HFunctor (u es)) =>
(f ~> HeftiaEffects h u es g)
-> HeftiaEffects h u es f ~> HeftiaEffects h u es g
interpretLowerH f ~> HeftiaEffects h u es g
f = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *) a
       (h' :: Signature -> Signature) (u' :: [Signature] -> Signature)
       (es' :: [Signature]) (g :: * -> *) b.
(h (u es) f a -> h' (u' es') g b)
-> HeftiaEffects h u es f a -> HeftiaEffects h' u' es' g b
overHeftiaEffects forall a b. (a -> b) -> a -> b
$ forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) (g :: * -> *).
(TransHeftia c h, HFunctor sig, c f, c g) =>
(f ~> h sig g) -> h sig f ~> h sig g
interpretLowerHT (forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. f ~> HeftiaEffects h u es g
f)
{-# INLINE interpretLowerH #-}

-- | Transfer the higher-order effect to the underlying level.
subsume ::
    ( TransHeftia c h
    , MemberH u e es
    , UnionH u
    , HFunctor e
    , HFunctor (u es)
    , HFunctor (u (e : es))
    , c f
    ) =>
    HeftiaEffects h u (e ': es) f ~> HeftiaEffects h u es f
subsume :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (e :: Signature)
       (es :: [Signature]) (f :: * -> *).
(TransHeftia c h, MemberH u e es, UnionH u, HFunctor e,
 HFunctor (u es), HFunctor (u (e : es)), c f) =>
HeftiaEffects h u (e : es) f ~> HeftiaEffects h u es f
subsume = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature])
       (e :: Signature) (f :: * -> *).
(TransHeftia c h, UnionH u, HFunctor (u es), HFunctor (u (e : es)),
 HFunctor e, c f) =>
(e (HeftiaEffects h u es f) ~> HeftiaEffects h u es f)
-> HeftiaEffects h u (e : es) f ~> HeftiaEffects h u es f
interpretH forall a b. (a -> b) -> a -> b
$ forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *) a.
(TransHeftia c h, HFunctor sig) =>
sig (h sig f) a -> h sig f a
liftSigT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature) (f :: * -> *) (g :: * -> *).
HFunctor h =>
(f :-> g) -> h f :-> h g
hfmap forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (u :: [Signature] -> Signature) (h :: Signature)
       (hs :: [Signature]) (f :: * -> *).
(UnionH u, HasMembershipH u h hs) =>
h f ~> u hs f
injectH
{-# INLINE subsume #-}

-- | Lifts the lower carrier.
liftLowerH :: (TransHeftia c h, c f, HFunctor (u es)) => f ~> HeftiaEffects h u es f
liftLowerH :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (u :: [Signature] -> Signature) (es :: [Signature]).
(TransHeftia c h, c f, HFunctor (u es)) =>
f ~> HeftiaEffects h u es f
liftLowerH = forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
h (u es) f ~> HeftiaEffects h u es f
heftiaEffects forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (sig :: Signature) (f :: * -> *).
(TransHeftia c h, c f, HFunctor sig) =>
f ~> h sig f
liftLowerHT
{-# INLINE liftLowerH #-}

-- | Drops a Heftia with no effect classes to elaborate to the lower carrier.
elaborated :: (TransHeftia c h, UnionH u, HFunctor (u '[]), c f) => HeftiaEffects h u '[] f ~> f
elaborated :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *).
(TransHeftia c h, UnionH u, HFunctor (u '[]), c f) =>
HeftiaEffects h u '[] f ~> f
elaborated = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (f :: * -> *) (sig :: Signature).
(TransHeftia c h, c f, HFunctor sig) =>
(sig f ~> f) -> h sig f ~> f
runElaborateH forall (u :: [Signature] -> Signature) (f :: * -> *) a x.
UnionH u =>
u '[] f a -> x
absurdUnionH forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
HeftiaEffects h u es f ~> h (u es) f
unHeftiaEffects
{-# INLINE elaborated #-}

-- | Drops the Heftia to the lower carrier.
runHeftiaEffects ::
    (TransHeftia c h, HFunctor (u '[LiftIns f]), UnionH u, c f) =>
    HeftiaEffects h u '[LiftIns f] f ~> f
runHeftiaEffects :: forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (f :: * -> *).
(TransHeftia c h, HFunctor (u '[LiftIns f]), UnionH u, c f) =>
HeftiaEffects h u '[LiftIns f] f ~> f
runHeftiaEffects = forall (c :: (* -> *) -> Constraint) (h :: Signature -> Signature)
       (u :: [Signature] -> Signature) (es :: [Signature]) (f :: * -> *).
(TransHeftia c h, HFunctor (u es), c f, UnionH u) =>
(u es f ~> f) -> HeftiaEffects h u es f ~> f
runElaborate forall a b. (a -> b) -> a -> b
$ forall (ins :: * -> *) (f :: * -> *) a. LiftIns ins f a -> ins a
unliftIns forall (u :: [Signature] -> Signature) (h :: Signature)
       (f :: * -> *) a r (hs :: [Signature]).
UnionH u =>
(h f a -> r) -> (u hs f a -> r) -> u (h : hs) f a -> r
|+: forall (u :: [Signature] -> Signature) (f :: * -> *) a x.
UnionH u =>
u '[] f a -> x
absurdUnionH
{-# INLINE runHeftiaEffects #-}

-- | A type synonym for commonly used Monad Heftia.
type Hef es f = HeftiaEffects HeftiaChurchT ExtensibleUnionH es f

-- -- | Type synonym for commonly used Applicative Heftia.
-- type HefA es f = HeftiaEffects (HeftiaFinalT Applicative) SumUnionH es f

-- | An operator representing the membership relationship of the higher-order effect class list.
type e <<| es = MemberH ExtensibleUnionH e es

-- | A type synonym for functions that perform the elaboration of higher-order effects.
type Elaborator e f = e f ~> f

-- | A type synonym for frequently occurring constraints on a list of effect classes.
type ForallHFunctor = Forall HFunctor