planet-mitchell-0.0.0: Planet Mitchell

Safe HaskellSafe
LanguageHaskell2010

Distributive

Contents

Synopsis

Distributive

class Functor g => Distributive (g :: * -> *) where #

This is the categorical dual of Traversable.

Due to the lack of non-trivial comonoids in Haskell, we can restrict ourselves to requiring a Functor rather than some Coapplicative class. Categorically every Distributive functor is actually a right adjoint, and so it must be Representable endofunctor and preserve all limits. This is a fancy way of saying it isomorphic to (->) x for some x.

To be distributable a container will need to have a way to consistently zip a potentially infinite number of copies of itself. This effectively means that the holes in all values of that type, must have the same cardinality, fixed sized vectors, infinite streams, functions, etc. and no extra information to try to merge together.

Minimal complete definition

distribute | collect

Methods

distribute :: Functor f => f (g a) -> g (f a) #

The dual of sequenceA

>>> distribute [(+1),(+2)] 1
[2,3]
distribute = collect id
distribute . distribute = id

collect :: Functor f => (a -> g b) -> f a -> g (f b) #

distributeM :: Monad m => m (g a) -> g (m a) #

collectM :: Monad m => (a -> g b) -> m a -> g (m b) #

Instances
Distributive Par1 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Par1 a) -> Par1 (f a) #

collect :: Functor f => (a -> Par1 b) -> f a -> Par1 (f b) #

distributeM :: Monad m => m (Par1 a) -> Par1 (m a) #

collectM :: Monad m => (a -> Par1 b) -> m a -> Par1 (m b) #

Distributive Complex 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Complex a) -> Complex (f a) #

collect :: Functor f => (a -> Complex b) -> f a -> Complex (f b) #

distributeM :: Monad m => m (Complex a) -> Complex (m a) #

collectM :: Monad m => (a -> Complex b) -> m a -> Complex (m b) #

Distributive Min 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Min a) -> Min (f a) #

collect :: Functor f => (a -> Min b) -> f a -> Min (f b) #

distributeM :: Monad m => m (Min a) -> Min (m a) #

collectM :: Monad m => (a -> Min b) -> m a -> Min (m b) #

Distributive Max 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Max a) -> Max (f a) #

collect :: Functor f => (a -> Max b) -> f a -> Max (f b) #

distributeM :: Monad m => m (Max a) -> Max (m a) #

collectM :: Monad m => (a -> Max b) -> m a -> Max (m b) #

Distributive First 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (First a) -> First (f a) #

collect :: Functor f => (a -> First b) -> f a -> First (f b) #

distributeM :: Monad m => m (First a) -> First (m a) #

collectM :: Monad m => (a -> First b) -> m a -> First (m b) #

Distributive Last 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Last a) -> Last (f a) #

collect :: Functor f => (a -> Last b) -> f a -> Last (f b) #

distributeM :: Monad m => m (Last a) -> Last (m a) #

collectM :: Monad m => (a -> Last b) -> m a -> Last (m b) #

Distributive Identity 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Identity a) -> Identity (f a) #

collect :: Functor f => (a -> Identity b) -> f a -> Identity (f b) #

distributeM :: Monad m => m (Identity a) -> Identity (m a) #

collectM :: Monad m => (a -> Identity b) -> m a -> Identity (m b) #

Distributive Dual 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Dual a) -> Dual (f a) #

collect :: Functor f => (a -> Dual b) -> f a -> Dual (f b) #

distributeM :: Monad m => m (Dual a) -> Dual (m a) #

collectM :: Monad m => (a -> Dual b) -> m a -> Dual (m b) #

Distributive Sum 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Sum a) -> Sum (f a) #

collect :: Functor f => (a -> Sum b) -> f a -> Sum (f b) #

distributeM :: Monad m => m (Sum a) -> Sum (m a) #

collectM :: Monad m => (a -> Sum b) -> m a -> Sum (m b) #

Distributive Product 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Product a) -> Product (f a) #

collect :: Functor f => (a -> Product b) -> f a -> Product (f b) #

distributeM :: Monad m => m (Product a) -> Product (m a) #

collectM :: Monad m => (a -> Product b) -> m a -> Product (m b) #

Distributive Log 
Instance details

Defined in Numeric.Log

Methods

distribute :: Functor f => f (Log a) -> Log (f a) #

collect :: Functor f => (a -> Log b) -> f a -> Log (f b) #

distributeM :: Monad m => m (Log a) -> Log (m a) #

collectM :: Monad m => (a -> Log b) -> m a -> Log (m b) #

Distributive (U1 :: * -> *) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (U1 a) -> U1 (f a) #

collect :: Functor f => (a -> U1 b) -> f a -> U1 (f b) #

distributeM :: Monad m => m (U1 a) -> U1 (m a) #

collectM :: Monad m => (a -> U1 b) -> m a -> U1 (m b) #

Representable f => Distributive (Co f) 
Instance details

Defined in Data.Functor.Rep

Methods

distribute :: Functor f0 => f0 (Co f a) -> Co f (f0 a) #

collect :: Functor f0 => (a -> Co f b) -> f0 a -> Co f (f0 b) #

distributeM :: Monad m => m (Co f a) -> Co f (m a) #

collectM :: Monad m => (a -> Co f b) -> m a -> Co f (m b) #

Distributive (Proxy :: * -> *) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Proxy a) -> Proxy (f a) #

collect :: Functor f => (a -> Proxy b) -> f a -> Proxy (f b) #

distributeM :: Monad m => m (Proxy a) -> Proxy (m a) #

collectM :: Monad m => (a -> Proxy b) -> m a -> Proxy (m b) #

Distributive f => Distributive (Cofree f) 
Instance details

Defined in Control.Comonad.Cofree

Methods

distribute :: Functor f0 => f0 (Cofree f a) -> Cofree f (f0 a) #

collect :: Functor f0 => (a -> Cofree f b) -> f0 a -> Cofree f (f0 b) #

distributeM :: Monad m => m (Cofree f a) -> Cofree f (m a) #

collectM :: Monad m => (a -> Cofree f b) -> m a -> Cofree f (m b) #

Distributive f => Distributive (Yoneda f) 
Instance details

Defined in Data.Functor.Yoneda

Methods

distribute :: Functor f0 => f0 (Yoneda f a) -> Yoneda f (f0 a) #

collect :: Functor f0 => (a -> Yoneda f b) -> f0 a -> Yoneda f (f0 b) #

distributeM :: Monad m => m (Yoneda f a) -> Yoneda f (m a) #

collectM :: Monad m => (a -> Yoneda f b) -> m a -> Yoneda f (m b) #

Distributive (ReifiedGetter s) 
Instance details

Defined in Control.Lens.Reified

Methods

distribute :: Functor f => f (ReifiedGetter s a) -> ReifiedGetter s (f a) #

collect :: Functor f => (a -> ReifiedGetter s b) -> f a -> ReifiedGetter s (f b) #

distributeM :: Monad m => m (ReifiedGetter s a) -> ReifiedGetter s (m a) #

collectM :: Monad m => (a -> ReifiedGetter s b) -> m a -> ReifiedGetter s (m b) #

Distributive f => Distributive (Rec1 f) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (Rec1 f a) -> Rec1 f (f0 a) #

collect :: Functor f0 => (a -> Rec1 f b) -> f0 a -> Rec1 f (f0 b) #

distributeM :: Monad m => m (Rec1 f a) -> Rec1 f (m a) #

collectM :: Monad m => (a -> Rec1 f b) -> m a -> Rec1 f (m b) #

Distributive g => Distributive (IdentityT g) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (IdentityT g a) -> IdentityT g (f a) #

collect :: Functor f => (a -> IdentityT g b) -> f a -> IdentityT g (f b) #

distributeM :: Monad m => m (IdentityT g a) -> IdentityT g (m a) #

collectM :: Monad m => (a -> IdentityT g b) -> m a -> IdentityT g (m b) #

(Representable f, Representable g) => Distributive (Day f g) 
Instance details

Defined in Data.Functor.Day

Methods

distribute :: Functor f0 => f0 (Day f g a) -> Day f g (f0 a) #

collect :: Functor f0 => (a -> Day f g b) -> f0 a -> Day f g (f0 b) #

distributeM :: Monad m => m (Day f g a) -> Day f g (m a) #

collectM :: Monad m => (a -> Day f g b) -> m a -> Day f g (m b) #

Distributive f => Distributive (Backwards f) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (Backwards f a) -> Backwards f (f0 a) #

collect :: Functor f0 => (a -> Backwards f b) -> f0 a -> Backwards f (f0 b) #

distributeM :: Monad m => m (Backwards f a) -> Backwards f (m a) #

collectM :: Monad m => (a -> Backwards f b) -> m a -> Backwards f (m b) #

Distributive f => Distributive (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Star f a a0) -> Star f a (f0 a0) #

collect :: Functor f0 => (a0 -> Star f a b) -> f0 a0 -> Star f a (f0 b) #

distributeM :: Monad m => m (Star f a a0) -> Star f a (m a0) #

collectM :: Monad m => (a0 -> Star f a b) -> m a0 -> Star f a (m b) #

Distributive (Costar f d) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Costar f d a) -> Costar f d (f0 a) #

collect :: Functor f0 => (a -> Costar f d b) -> f0 a -> Costar f d (f0 b) #

distributeM :: Monad m => m (Costar f d a) -> Costar f d (m a) #

collectM :: Monad m => (a -> Costar f d b) -> m a -> Costar f d (m b) #

Distributive (Tagged t) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (Tagged t a) -> Tagged t (f a) #

collect :: Functor f => (a -> Tagged t b) -> f a -> Tagged t (f b) #

distributeM :: Monad m => m (Tagged t a) -> Tagged t (m a) #

collectM :: Monad m => (a -> Tagged t b) -> m a -> Tagged t (m b) #

Distributive f => Distributive (Reverse f) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (Reverse f a) -> Reverse f (f0 a) #

collect :: Functor f0 => (a -> Reverse f b) -> f0 a -> Reverse f (f0 b) #

distributeM :: Monad m => m (Reverse f a) -> Reverse f (m a) #

collectM :: Monad m => (a -> Reverse f b) -> m a -> Reverse f (m b) #

Distributive ((->) e :: * -> *) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (e -> a) -> e -> f a #

collect :: Functor f => (a -> e -> b) -> f a -> e -> f b #

distributeM :: Monad m => m (e -> a) -> e -> m a #

collectM :: Monad m => (a -> e -> b) -> m a -> e -> m b #

(Distributive a, Distributive b) => Distributive (a :*: b) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f ((a :*: b) a0) -> (a :*: b) (f a0) #

collect :: Functor f => (a0 -> (a :*: b) b0) -> f a0 -> (a :*: b) (f b0) #

distributeM :: Monad m => m ((a :*: b) a0) -> (a :*: b) (m a0) #

collectM :: Monad m => (a0 -> (a :*: b) b0) -> m a0 -> (a :*: b) (m b0) #

(Distributive f, Distributive g) => Distributive (Product f g) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (Product f g a) -> Product f g (f0 a) #

collect :: Functor f0 => (a -> Product f g b) -> f0 a -> Product f g (f0 b) #

distributeM :: Monad m => m (Product f g a) -> Product f g (m a) #

collectM :: Monad m => (a -> Product f g b) -> m a -> Product f g (m b) #

Distributive g => Distributive (ReaderT e g) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f (ReaderT e g a) -> ReaderT e g (f a) #

collect :: Functor f => (a -> ReaderT e g b) -> f a -> ReaderT e g (f b) #

distributeM :: Monad m => m (ReaderT e g a) -> ReaderT e g (m a) #

collectM :: Monad m => (a -> ReaderT e g b) -> m a -> ReaderT e g (m b) #

Distributive f => Distributive (M1 i c f) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (M1 i c f a) -> M1 i c f (f0 a) #

collect :: Functor f0 => (a -> M1 i c f b) -> f0 a -> M1 i c f (f0 b) #

distributeM :: Monad m => m (M1 i c f a) -> M1 i c f (m a) #

collectM :: Monad m => (a -> M1 i c f b) -> m a -> M1 i c f (m b) #

(Distributive a, Distributive b) => Distributive (a :.: b) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f => f ((a :.: b) a0) -> (a :.: b) (f a0) #

collect :: Functor f => (a0 -> (a :.: b) b0) -> f a0 -> (a :.: b) (f b0) #

distributeM :: Monad m => m ((a :.: b) a0) -> (a :.: b) (m a0) #

collectM :: Monad m => (a0 -> (a :.: b) b0) -> m a0 -> (a :.: b) (m b0) #

(Distributive f, Distributive g) => Distributive (Compose f g) 
Instance details

Defined in Data.Distributive

Methods

distribute :: Functor f0 => f0 (Compose f g a) -> Compose f g (f0 a) #

collect :: Functor f0 => (a -> Compose f g b) -> f0 a -> Compose f g (f0 b) #

distributeM :: Monad m => m (Compose f g a) -> Compose f g (m a) #

collectM :: Monad m => (a -> Compose f g b) -> m a -> Compose f g (m b) #

cotraverse :: (Distributive g, Functor f) => (f a -> b) -> f (g a) -> g b #

The dual of traverse

cotraverse f = fmap f . distribute

comapM :: (Distributive g, Monad m) => (m a -> b) -> m (g a) -> g b #

The dual of mapM

comapM f = fmap f . distributeM

fmapCollect :: Distributive f => (a -> b) -> f a -> f b #

fmapCollect is a viable default definition for fmap given a Distributive instance defined in terms of collect.