functor-combinators-0.4.1.3: Tools for functor combinator-based program design
Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
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.

Minimal complete definition

divise | divised

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.

divised :: 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).

Instances

Instances details
Divise SettableStateVar Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Divise Comparison Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

divised :: Comparison a -> Comparison b -> Comparison (a, b) Source #

Divise Equivalence Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

divised :: Equivalence a -> Equivalence b -> Equivalence (a, b) Source #

Divise Predicate Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

divised :: Predicate a -> Predicate b -> Predicate (a, b) 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 #

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 #

divised :: Op r a -> Op r b -> Op r (a, b) 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 #

divised :: Proxy a -> Proxy b -> Proxy (a, b) 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 #

divised :: U1 a -> U1 b -> U1 (a, b) 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 #

divised :: V1 a -> V1 b -> V1 (a, b) 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 #

divised :: Div f a -> Div f b -> Div f (a, b) 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 #

divised :: Div1 f a -> Div1 f b -> Div1 f (a, b) 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 #

divised :: MaybeT m a -> MaybeT m b -> MaybeT m (a, b) 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 #

divised :: Const m a -> Const m b -> Const m (a, b) 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 #

divised :: Alt f a -> Alt f b -> Alt f (a, b) 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 #

divised :: Rec1 f a -> Rec1 f b -> Rec1 f (a, b) 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 #

divised :: ListF f a -> ListF f b -> ListF f (a, b) 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 #

divised :: MaybeF f a -> MaybeF f b -> MaybeF f (a, b) 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 #

divised :: NonEmptyF f a -> NonEmptyF f b -> NonEmptyF f (a, b) 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 #

divised :: Step f a -> Step f b -> Step f (a, b) Source #

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

Defined in Data.Functor.Contravariant.Divise

(Divisible f, Invariant f) => Divise (WrappedDivisibleOnly f) Source # 
Instance details

Defined in Data.Functor.Invariant.Inplicative

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 #

divised :: AltConst w a -> AltConst w b -> AltConst w (a, b) 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 #

divised :: Backwards f a -> Backwards f b -> Backwards f (a, b) 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 #

divised :: ExceptT e m a -> ExceptT e m b -> ExceptT e m (a, b) 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 #

divised :: IdentityT f a -> IdentityT f b -> IdentityT f (a, b) 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 #

divised :: ReaderT r m a -> ReaderT r m b -> ReaderT r m (a, b) 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 #

divised :: StateT s m a -> StateT s m b -> StateT s m (a, b) 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 #

divised :: StateT s m a -> StateT s m b -> StateT s m (a, b) 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 #

divised :: WriterT w m a -> WriterT w m b -> WriterT w m (a, b) 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 #

divised :: WriterT w m a -> WriterT w m b -> WriterT w m (a, b) 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 #

divised :: Constant m a -> Constant m b -> Constant m (a, b) 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 #

divised :: Reverse f a -> Reverse f b -> Reverse f (a, b) Source #

Contravariant (Final Divise f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Methods

contramap :: (a' -> a) -> Final Divise f a -> Final Divise f a' #

(>$) :: b -> Final Divise f b -> Final Divise f a #

(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 #

divised :: Product f g a -> Product f g b -> Product f g (a, b) Source #

(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 #

divised :: (f :*: g) a -> (f :*: g) b -> (f :*: g) (a, b) 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 #

divised :: ProxyF f a -> ProxyF f b -> ProxyF f (a, b) 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 #

divised :: Chain1 Day f a -> Chain1 Day f b -> Chain1 Day f (a, b) 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 #

divised :: Final Divisible f a -> Final Divisible f b -> Final Divisible f (a, b) 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 #

divised :: Final Divise f a -> Final Divise f b -> Final Divise f (a, b) 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 #

divised :: Compose f g a -> Compose f g b -> Compose f g (a, b) 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 #

divised :: (f :.: g) a -> (f :.: g) b -> (f :.: g) (a, b) 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 #

divised :: M1 i c f a -> M1 i c f b -> M1 i c f (a, b) 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 #

divised :: ConstF e f a -> ConstF e f b -> ConstF e f (a, b) 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 #

divised :: RWST r w s m a -> RWST r w s m b -> RWST r w s m (a, b) 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 #

divised :: RWST r w s m a -> RWST r w s m b -> RWST r w s m (a, b) 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 :: Chain Day Proxy f a -> Chain Day Proxy f b -> Chain Day Proxy f (a, b) Source #

(<:>) :: 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
Foldable f => Foldable (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

fold :: Monoid m => WrappedDivisible f m -> m #

foldMap :: Monoid m => (a -> m) -> WrappedDivisible f a -> m #

foldMap' :: Monoid m => (a -> m) -> WrappedDivisible f a -> m #

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

foldr' :: (a -> b -> b) -> b -> WrappedDivisible f a -> b #

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

foldl' :: (b -> a -> b) -> b -> WrappedDivisible f a -> b #

foldr1 :: (a -> a -> a) -> WrappedDivisible f a -> a #

foldl1 :: (a -> a -> a) -> WrappedDivisible f a -> a #

toList :: WrappedDivisible f a -> [a] #

null :: WrappedDivisible f a -> Bool #

length :: WrappedDivisible f a -> Int #

elem :: Eq a => a -> WrappedDivisible f a -> Bool #

maximum :: Ord a => WrappedDivisible f a -> a #

minimum :: Ord a => WrappedDivisible f a -> a #

sum :: Num a => WrappedDivisible f a -> a #

product :: Num a => WrappedDivisible f a -> a #

Eq1 f => Eq1 (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

liftEq :: (a -> b -> Bool) -> WrappedDivisible f a -> WrappedDivisible f b -> Bool #

Ord1 f => Ord1 (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

liftCompare :: (a -> b -> Ordering) -> WrappedDivisible f a -> WrappedDivisible f b -> Ordering #

Read1 f => Read1 (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Show1 f => Show1 (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WrappedDivisible f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WrappedDivisible f a] -> ShowS #

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

Defined in Data.Functor.Contravariant.Divise

Methods

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

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

Traversable f => Traversable (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

traverse :: Applicative f0 => (a -> f0 b) -> WrappedDivisible f a -> f0 (WrappedDivisible f b) #

sequenceA :: Applicative f0 => WrappedDivisible f (f0 a) -> f0 (WrappedDivisible f a) #

mapM :: Monad m => (a -> m b) -> WrappedDivisible f a -> m (WrappedDivisible f b) #

sequence :: Monad m => WrappedDivisible f (m a) -> m (WrappedDivisible f a) #

Functor f => Functor (WrappedDivisible f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Methods

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

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

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

Defined in Data.Functor.Contravariant.Divise

Methods

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

conquer :: WrappedDivisible f a #

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

Defined in Data.Functor.Contravariant.Conclude

Methods

conclude :: (a -> Void) -> 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 #

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

Defined in Data.Functor.Contravariant.Divise

(Divisible f, Divise f) => Inplicative (WrappedDivisible f) Source #
knot _ = conquer
Instance details

Defined in Data.Functor.Invariant.Inplicative

Methods

knot :: a -> WrappedDivisible f a Source #

Divise f => Inply (WrappedDivisible f) Source #

Ignores the covariant part of gather

Instance details

Defined in Data.Functor.Invariant.Inplicative

Methods

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

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

Decide f => Inalt (WrappedDivisible f) Source #

Ignores the covariant part of gather

Instance details

Defined in Data.Functor.Invariant.Internative

Methods

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

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

Conclude f => Inplus (WrappedDivisible f) Source #
reject = conclude
Instance details

Defined in Data.Functor.Invariant.Internative

Methods

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

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

Defined in Data.Functor.Invariant.Internative

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

Defined in Data.Functor.Contravariant.Divise

Methods

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

Generic (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Associated Types

type Rep (WrappedDivisible f a) :: Type -> Type #

Read (f a) => Read (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Show (f a) => Show (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Eq (f a) => Eq (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

Ord (f a) => Ord (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

type Rep (WrappedDivisible f a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divise

type Rep (WrappedDivisible f a) = D1 ('MetaData "WrappedDivisible" "Data.Functor.Contravariant.Divise" "functor-combinators-0.4.1.3-6AGvZMQUvOOEyTeopopf92" 'True) (C1 ('MetaCons "WrapDivisible" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapDivisible") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))