functor-combinators-0.3.6.0: Tools for functor combinator-based program design

Data.Functor.Contravariant.Divise

Description

The contravariant counterpart of Apply: like Divisible, but without conquer. This is only a part of this library currently for compatibility, until it is (hopefully) merged into semigroupoids.

Since: 0.3.0.0

Synopsis

# Documentation

class Contravariant f => Divise f where Source #

The contravariant analogue of Apply; it is Divisible without conquer.

If one thinks of f a as a consumer of as, then divise allows one to handle the consumption of a value by splitting it between two consumers that consume separate parts of a.

divise takes the "splitting" method and the two sub-consumers, and returns the wrapped/combined consumer.

All instances of Divisible should be instances of Divise with divise = divide.

The guarantee that a function polymorphic over of Divise f provides that Divisible f doesn't that any input consumed will be passed to at least one sub-consumer; it won't potentially disappear into the void, as is possible if conquer is available.

Mathematically, a functor being an instance of Divise means that it is "semgroupoidal" with respect to the contravariant (tupling) Day convolution. That is, it is possible to define a function (f Day f) a -> f a in a way that is associative.

Methods

divise :: (a -> (b, c)) -> f b -> f c -> f a Source #

Takes a "splitting" method and the two sub-consumers, and returns the wrapped/combined consumer.

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Predicate b -> Predicate c -> Predicate a Source # Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Comparison b -> Comparison c -> Comparison a Source # Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Equivalence b -> Equivalence c -> Equivalence a Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Final Associated Typestype FreeFunctorBy Div1 :: (Type -> Type) -> Constraint Source # MethodsfromFree :: forall (f :: Type -> Type). Div1 f ~> Final Divise f Source #toFree :: forall (f :: Type -> Type). FreeFunctorBy Div1 f => Final Divise f ~> Div1 f Source # Divise (V1 :: Type -> Type) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> V1 b -> V1 c -> V1 a Source # Divise (U1 :: Type -> Type) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> U1 b -> U1 c -> U1 a Source # Semigroup r => Divise (Op r) Source # Unlike Divisible, requires only Semigroup on r. Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Op r b -> Op r c -> Op r a Source # Divise (Proxy :: Type -> Type) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Proxy b -> Proxy c -> Proxy a Source # Divise m => Divise (MaybeT m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> MaybeT m b -> MaybeT m c -> MaybeT m a Source # Divise m => Divise (ListT m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> ListT m b -> ListT m c -> ListT m a Source # Divise (Div1 f) Source # Instance details Methodsdivise :: (a -> (b, c)) -> Div1 f b -> Div1 f c -> Div1 f a Source # Divise (Div f) Source # Instance details Methodsdivise :: (a -> (b, c)) -> Div f b -> Div f c -> Div f a Source # Divise f => Divise (Rec1 f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Rec1 f b -> Rec1 f c -> Rec1 f a Source # Semigroup m => Divise (Const m :: Type -> Type) Source # Unlike Divisible, requires only Semigroup on m. Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Const m b -> Const m c -> Const m a Source # Divise f => Divise (Alt f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Alt f b -> Alt f c -> Alt f a Source # Divise f => Divise (IdentityT f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> IdentityT f b -> IdentityT f c -> IdentityT f a Source # Divise m => Divise (ExceptT e m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> ExceptT e m b -> ExceptT e m c -> ExceptT e m a Source # Divise m => Divise (ErrorT e m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> ErrorT e m b -> ErrorT e m c -> ErrorT e m a Source # Divise m => Divise (ReaderT r m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> ReaderT r m b -> ReaderT r m c -> ReaderT r m a Source # Divise m => Divise (StateT s m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> StateT s m b -> StateT s m c -> StateT s m a Source # Divise m => Divise (StateT s m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> StateT s m b -> StateT s m c -> StateT s m a Source # Divise m => Divise (WriterT w m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> WriterT w m b -> WriterT w m c -> WriterT w m a Source # Divise m => Divise (WriterT w m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> WriterT w m b -> WriterT w m c -> WriterT w m a Source # Divise f => Divise (Reverse f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Reverse f b -> Reverse f c -> Reverse f a Source # Semigroup m => Divise (Constant m :: Type -> Type) Source # Unlike Divisible, requires only Semigroup on m. Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Constant m b -> Constant m c -> Constant m a Source # Divise f => Divise (Backwards f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Backwards f b -> Backwards f c -> Backwards f a Source # Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> WrappedDivisible f b -> WrappedDivisible f c -> WrappedDivisible f a Source # Divise f => Divise (Step f) Source # Since: 0.3.0.0 Instance detailsDefined in Control.Applicative.Step Methodsdivise :: (a -> (b, c)) -> Step f b -> Step f c -> Step f a Source # Contravariant f => Divise (ListF f) Source # Since: 0.3.0.0 Instance detailsDefined in Control.Applicative.ListF Methodsdivise :: (a -> (b, c)) -> ListF f b -> ListF f c -> ListF f a Source # Contravariant f => Divise (NonEmptyF f) Source # Since: 0.3.0.0 Instance detailsDefined in Control.Applicative.ListF Methodsdivise :: (a -> (b, c)) -> NonEmptyF f b -> NonEmptyF f c -> NonEmptyF f a Source # Contravariant f => Divise (MaybeF f) Source # Since: 0.3.3.0 Instance detailsDefined in Control.Applicative.ListF Methodsdivise :: (a -> (b, c)) -> MaybeF f b -> MaybeF f c -> MaybeF f a Source # Semigroup w => Divise (AltConst w :: Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Interpret Methodsdivise :: (a -> (b, c)) -> AltConst w b -> AltConst w c -> AltConst w a Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Final Methodscontramap :: (a -> b) -> Final Divise f b -> Final Divise f a #(>$) :: b -> Final Divise f b -> Final Divise f a # (Divise f, Divise g) => Divise (f :*: g) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> (f :*: g) b -> (f :*: g) c -> (f :*: g) a Source # (Divise f, Divise g) => Divise (Product f g) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Product f g b -> Product f g c -> Product f g a Source # Divise (ProxyF f :: Type -> Type) Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor Methodsdivise :: (a -> (b, c)) -> ProxyF f b -> ProxyF f c -> ProxyF f a Source # Contravariant f => Divise (Chain1 Day f) Source # Chain1 Day is the free "semigroup in the semigroupoidal category of endofunctors enriched by Day" --- aka, the free Divise.Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Chain Methodsdivise :: (a -> (b, c)) -> Chain1 Day f b -> Chain1 Day f c -> Chain1 Day f a Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Final Methodsdivise :: (a -> (b, c)) -> Final Divisible f b -> Final Divisible f c -> Final Divisible f a Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Final Methodsdivise :: (a -> (b, c)) -> Final Divise f b -> Final Divise f c -> Final Divise f a Source # Divise f => Divise (M1 i c f) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c0)) -> M1 i c f b -> M1 i c f c0 -> M1 i c f a Source # (Apply f, Divise g) => Divise (f :.: g) Source # Unlike Divisible, requires only Apply on f. Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> (f :.: g) b -> (f :.: g) c -> (f :.: g) a Source # (Apply f, Divise g) => Divise (Compose f g) Source # Unlike Divisible, requires only Apply on f. Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> Compose f g b -> Compose f g c -> Compose f g a Source # Divise m => Divise (RWST r w s m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> RWST r w s m b -> RWST r w s m c -> RWST r w s m a Source # Divise m => Divise (RWST r w s m) Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> RWST r w s m b -> RWST r w s m c -> RWST r w s m a Source # Semigroup e => Divise (ConstF e f :: Type -> Type) Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor Methodsdivise :: (a -> (b, c)) -> ConstF e f b -> ConstF e f c -> ConstF e f a Source # Divise (Chain Day (Proxy :: Type -> Type) f) Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Chain Methodsdivise :: (a -> (b, c)) -> Chain Day Proxy f b -> Chain Day Proxy f c -> Chain Day Proxy f a Source # divised :: Divise f => f a -> f b -> f (a, b) Source # Combine a consumer of a with a consumer of b to get a consumer of (a, b). divised = divise id  (<:>) :: Divise f => f a -> f a -> f a Source # The Contravariant version of <|>: split the same input over two different consumers. dsum1 :: (Foldable1 t, Divise f) => t (f a) -> f a Source # Convenient helper function to build up a Divise by splitting input across many different f as. Most useful when used alongside contramap: dsum1$ contramap get1 x
:| [ contramap get2 y
, contramap get3 z
]


Since: 0.3.3.0

newtype WrappedDivisible f a Source #

Wrap a Divisible to be used as a member of Divise

Constructors

 WrapDivisible FieldsunwrapDivisible :: f a

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodscontramap :: (a -> b) -> WrappedDivisible f b -> WrappedDivisible f a #(>\$) :: b -> WrappedDivisible f b -> WrappedDivisible f a # Source # Instance detailsDefined in Data.Functor.Contravariant.Divise Methodsdivise :: (a -> (b, c)) -> WrappedDivisible f b -> WrappedDivisible f c -> WrappedDivisible f a Source # Source # Instance detailsDefined in Data.Functor.Contravariant.Decide Methodsdecide :: (a -> Either b c) -> WrappedDivisible f b -> WrappedDivisible f c -> WrappedDivisible f a Source # Source # Instance detailsDefined in Data.Functor.Contravariant.Conclude Methodsconclude :: (a -> Void) -> WrappedDivisible f a Source #