functor-combinators-0.3.6.0: Tools for functor combinator-based program design
Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

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
Divise Predicate Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise Comparison Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise Equivalence Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

FreeOf Divise Div1 Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Associated Types

type FreeFunctorBy Div1 :: (Type -> Type) -> Constraint Source #

Methods

fromFree :: 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 details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Semigroup r => Divise (Op r) Source #

Unlike Divisible, requires only Semigroup on r.

Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise m => Divise (MaybeT m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise m => Divise (ListT m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise (Div1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

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

Divise (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

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

Divise f => Divise (Rec1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise f => Divise (Alt f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise f => Divise (IdentityT f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise m => Divise (ExceptT e m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> ExceptT e m b -> ExceptT e m c -> ExceptT e m a Source #

Divise m => Divise (ErrorT e m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> ErrorT e m b -> ErrorT e m c -> ErrorT e m a Source #

Divise m => Divise (ReaderT r m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> ReaderT r m b -> ReaderT r m c -> ReaderT r m a Source #

Divise m => Divise (StateT s m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> StateT s m b -> StateT s m c -> StateT s m a Source #

Divise m => Divise (StateT s m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> StateT s m b -> StateT s m c -> StateT s m a Source #

Divise m => Divise (WriterT w m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> WriterT w m b -> WriterT w m c -> WriterT w m a Source #

Divise m => Divise (WriterT w m) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (a -> (b, c)) -> WriterT w m b -> WriterT w m c -> WriterT w m a Source #

Divise f => Divise (Reverse f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divise f => Divise (Backwards f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Divisible f => Divise (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Control.Applicative.Step

Methods

divise :: (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 details

Defined in Control.Applicative.ListF

Methods

divise :: (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 details

Defined in Control.Applicative.ListF

Methods

divise :: (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 details

Defined in Control.Applicative.ListF

Methods

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

Semigroup w => Divise (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

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

Contravariant (Final Divise f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Methods

contramap :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

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

(Divise f, Divise g) => Divise (Product f g) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.HFunctor

Methods

divise :: (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 details

Defined in Data.HFunctor.Chain

Methods

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

Divise (Final Divisible f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Methods

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

Divise (Final Divise f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.Functor.Contravariant.Divise

Methods

divise :: (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 details

Defined in Data.HFunctor

Methods

divise :: (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 details

Defined in Data.HFunctor.Chain

Methods

divise :: (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 

Fields

Instances

Instances details
Contravariant f => Contravariant (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

contramap :: (a -> b) -> WrappedDivisible f b -> WrappedDivisible f a #

(>$) :: b -> WrappedDivisible f b -> WrappedDivisible f a #

Divisible f => Divise (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

Decidable f => Decide (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Decide

Methods

decide :: (a -> Either b c) -> WrappedDivisible f b -> WrappedDivisible f c -> WrappedDivisible f a Source #

Decidable f => Conclude (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Conclude

Methods

conclude :: (a -> Void) -> WrappedDivisible f a Source #