heftia-0.1.0.0: Higher-order version of Freer.
Copyright(c) 2023 Yamada Ryo
(c) 2023 Casper Bach Poulsen and Cas van der Rest
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Hefty.Sum

Description

An implementation of an open union for higher-order effects using recursively nested binary sums.

Synopsis

Documentation

absurdLH :: (NopS :+: h) f ~> h f Source #

absurdRH :: (h :+: NopS) f ~> h f Source #

swapSumH :: (h1 :+: h2) f a -> (h2 :+: h1) f a Source #

type family SumH hs where ... Source #

Equations

SumH '[] = NopS 
SumH (h ': hs) = h :+: SumH hs 

newtype SumUnionH hs f a Source #

An implementation of an open union for higher-order effects using recursively nested binary sums.

Constructors

SumUnionH 

Fields

Instances

Instances details
UnionH SumUnionH Source # 
Instance details

Defined in Data.Hefty.Sum

Associated Types

type HasMembershipH SumUnionH h hs Source #

Methods

injectH :: forall (h :: Signature) (hs :: [Signature]) (f :: Type -> Type). HasMembershipH SumUnionH h hs => h f ~> SumUnionH hs f Source #

projectH :: forall h (hs :: [Signature]) (f :: Type -> Type) a. HasMembershipH SumUnionH h hs => SumUnionH hs f a -> Maybe (h f a) Source #

absurdUnionH :: forall (f :: Type -> Type) a x. SumUnionH '[] f a -> x Source #

compH :: forall h (f :: Type -> Type) a (hs :: [Signature]). Either (h f a) (SumUnionH hs f a) -> SumUnionH (h ': hs) f a Source #

decompH :: forall h (hs :: [Signature]) (f :: Type -> Type) a. SumUnionH (h ': hs) f a -> Either (h f a) (SumUnionH hs f a) Source #

(|+:) :: forall h (f :: Type -> Type) a r (hs :: [Signature]). (h f a -> r) -> (SumUnionH hs f a -> r) -> SumUnionH (h ': hs) f a -> r Source #

inject0H :: forall (h :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) (hs :: [(Type -> Type) -> Type -> Type]). h f ~> SumUnionH (h ': hs) f Source #

injectUnderH :: forall (h2 :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) (h1 :: (Type -> Type) -> Type -> Type) (hs :: [(Type -> Type) -> Type -> Type]). h2 f ~> SumUnionH (h1 ': (h2 ': hs)) f Source #

injectUnder2H :: forall (h3 :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) (h1 :: (Type -> Type) -> Type -> Type) (h2 :: (Type -> Type) -> Type -> Type) (hs :: [(Type -> Type) -> Type -> Type]). h3 f ~> SumUnionH (h1 ': (h2 ': (h3 ': hs))) f Source #

injectUnder3H :: forall (h4 :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) (h1 :: (Type -> Type) -> Type -> Type) (h2 :: (Type -> Type) -> Type -> Type) (h3 :: (Type -> Type) -> Type -> Type) (hs :: [(Type -> Type) -> Type -> Type]). h4 f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

weakenH :: forall (hs :: [Signature]) (f :: Type -> Type) (h :: Signature). SumUnionH hs f ~> SumUnionH (h ': hs) f Source #

weaken2H :: forall (hs :: [Signature]) (f :: Type -> Type) (h1 :: Signature) (h2 :: Signature). SumUnionH hs f ~> SumUnionH (h1 ': (h2 ': hs)) f Source #

weaken3H :: forall (hs :: [Signature]) (f :: Type -> Type) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature). SumUnionH hs f ~> SumUnionH (h1 ': (h2 ': (h3 ': hs))) f Source #

weaken4H :: forall (hs :: [Signature]) (f :: Type -> Type) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (h4 :: Signature). SumUnionH hs f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

weakenUnderH :: forall (h1 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h2 :: Signature). SumUnionH (h1 ': hs) f ~> SumUnionH (h1 ': (h2 ': hs)) f Source #

weakenUnder2H :: forall (h1 :: Signature) (h2 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h3 :: Signature). SumUnionH (h1 ': (h2 ': hs)) f ~> SumUnionH (h1 ': (h2 ': (h3 ': hs))) f Source #

weakenUnder3H :: forall (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h4 :: Signature). SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

weaken2UnderH :: forall (h1 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h2 :: Signature) (h3 :: Signature). SumUnionH (h1 ': hs) f ~> SumUnionH (h1 ': (h2 ': (h3 ': hs))) f Source #

weaken2Under2H :: forall (h1 :: Signature) (h2 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h3 :: Signature) (h4 :: Signature). SumUnionH (h1 ': (h2 ': hs)) f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

weaken3UnderH :: forall (h1 :: Signature) (hs :: [Signature]) (f :: Type -> Type) (h2 :: Signature) (h3 :: Signature) (h4 :: Signature). SumUnionH (h1 ': hs) f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

flipUnionH :: forall (h1 :: Signature) (h2 :: Signature) (hs :: [Signature]) (f :: Type -> Type). SumUnionH (h1 ': (h2 ': hs)) f ~> SumUnionH (h2 ': (h1 ': hs)) f Source #

flipUnion3H :: forall (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (h3 ': (h2 ': (h1 ': hs))) f Source #

flipUnionUnderH :: forall (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (h1 ': (h3 ': (h2 ': hs))) f Source #

rot3H :: forall (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (h2 ': (h3 ': (h1 ': hs))) f Source #

rot3H' :: forall (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (h3 ': (h1 ': (h2 ': hs))) f Source #

bundleUnion2H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (h1 ': (h2 ': hs)) f ~> SumUnionH (u' '[h1, h2] ': hs) f Source #

bundleUnion3H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (h1 ': (h2 ': (h3 ': hs))) f ~> SumUnionH (u' '[h1, h2, h3] ': hs) f Source #

bundleUnion4H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (h4 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f ~> SumUnionH (u' '[h1, h2, h3, h4] ': hs) f Source #

unbundleUnion2H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (u' '[h1, h2] ': hs) f ~> SumUnionH (h1 ': (h2 ': hs)) f Source #

unbundleUnion3H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (u' '[h1, h2, h3] ': hs) f ~> SumUnionH (h1 ': (h2 ': (h3 ': hs))) f Source #

unbundleUnion4H :: forall (u' :: [Signature] -> Signature) (h1 :: Signature) (h2 :: Signature) (h3 :: Signature) (h4 :: Signature) (hs :: [Signature]) (f :: Type -> Type). UnionH u' => SumUnionH (u' '[h1, h2, h3, h4] ': hs) f ~> SumUnionH (h1 ': (h2 ': (h3 ': (h4 ': hs)))) f Source #

HFunctor (SumH hs) => HFunctor (SumUnionH hs) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> SumUnionH hs f :-> SumUnionH hs g #

Foldable (SumUnionH ('[] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

fold :: Monoid m => SumUnionH '[] f m -> m #

foldMap :: Monoid m => (a -> m) -> SumUnionH '[] f a -> m #

foldMap' :: Monoid m => (a -> m) -> SumUnionH '[] f a -> m #

foldr :: (a -> b -> b) -> b -> SumUnionH '[] f a -> b #

foldr' :: (a -> b -> b) -> b -> SumUnionH '[] f a -> b #

foldl :: (b -> a -> b) -> b -> SumUnionH '[] f a -> b #

foldl' :: (b -> a -> b) -> b -> SumUnionH '[] f a -> b #

foldr1 :: (a -> a -> a) -> SumUnionH '[] f a -> a #

foldl1 :: (a -> a -> a) -> SumUnionH '[] f a -> a #

toList :: SumUnionH '[] f a -> [a] #

null :: SumUnionH '[] f a -> Bool #

length :: SumUnionH '[] f a -> Int #

elem :: Eq a => a -> SumUnionH '[] f a -> Bool #

maximum :: Ord a => SumUnionH '[] f a -> a #

minimum :: Ord a => SumUnionH '[] f a -> a #

sum :: Num a => SumUnionH '[] f a -> a #

product :: Num a => SumUnionH '[] f a -> a #

Traversable (SumUnionH ('[] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

traverse :: Applicative f0 => (a -> f0 b) -> SumUnionH '[] f a -> f0 (SumUnionH '[] f b) #

sequenceA :: Applicative f0 => SumUnionH '[] f (f0 a) -> f0 (SumUnionH '[] f a) #

mapM :: Monad m => (a -> m b) -> SumUnionH '[] f a -> m (SumUnionH '[] f b) #

sequence :: Monad m => SumUnionH '[] f (m a) -> m (SumUnionH '[] f a) #

Functor (SumUnionH ('[] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

fmap :: (a -> b) -> SumUnionH '[] f a -> SumUnionH '[] f b #

(<$) :: a -> SumUnionH '[] f b -> SumUnionH '[] f a #

type HasMembershipH SumUnionH h hs Source # 
Instance details

Defined in Data.Hefty.Sum

type HasMembershipH SumUnionH h hs = h << SumH hs

class isHead ~ (h1 `IsHeadSigOf` h2) => SumMemberH isHead (h1 :: Signature) h2 where Source #

Methods

injSumH :: h1 f a -> h2 f a Source #

projSumH :: h2 f a -> Maybe (h1 f a) Source #

Instances

Instances details
(IsHeadSigOf f (g :+: h) ~ 'False, f << h) => SumMemberH 'False f (g :+: h) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

injSumH :: forall (f0 :: Type -> Type) a. f f0 a -> (g :+: h) f0 a Source #

projSumH :: forall (f0 :: Type -> Type) a. (g :+: h) f0 a -> Maybe (f f0 a) Source #

SumMemberH 'True f (f :+: g) Source # 
Instance details

Defined in Data.Hefty.Sum

Methods

injSumH :: forall (f0 :: Type -> Type) a. f f0 a -> (f :+: g) f0 a Source #

projSumH :: forall (f0 :: Type -> Type) a. (f :+: g) f0 a -> Maybe (f f0 a) Source #

type family IsHeadSigOf (h1 :: Signature) h2 where ... Source #

Equations

IsHeadSigOf f (f :+: g) = 'True 
IsHeadSigOf _ _ = 'False 

type (<<) h1 h2 = SumMemberH (IsHeadSigOf h1 h2) h1 h2 Source #

injH :: forall h1 h2 f. h1 << h2 => h1 f ~> h2 f Source #

projH :: forall h1 h2 f a. h1 << h2 => h2 f a -> Maybe (h1 f a) Source #