distributive-0.6.2.1: Distributive functors -- Dual to Traversable
Copyright (C) 2011-2016 Edward Kmett
License BSD-style (see the file LICENSE)
Maintainer Edward Kmett <ekmett@gmail.com>
Stability provisional
Portability portable
Safe Haskell Trustworthy
Language Haskell2010

Data.Distributive

Description

Synopsis

Documentation

class Functor g => Distributive g where Source #

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 is 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) Source #

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) Source #

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

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

Instances

Instances details
Distributive Par1 Source #
Instance details

Defined in Data.Distributive

Distributive Complex Source #
Instance details

Defined in Data.Distributive

Distributive Min Source #
Instance details

Defined in Data.Distributive

Distributive Max Source #
Instance details

Defined in Data.Distributive

Distributive First Source #
Instance details

Defined in Data.Distributive

Distributive Last Source #
Instance details

Defined in Data.Distributive

Distributive Identity Source #
Instance details

Defined in Data.Distributive

Distributive Dual Source #
Instance details

Defined in Data.Distributive

Distributive Sum Source #
Instance details

Defined in Data.Distributive

Distributive Product Source #
Instance details

Defined in Data.Distributive

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

Defined in Data.Distributive

( Distributive m, Monad m) => Distributive ( WrappedMonad m) Source #
Instance details

Defined in Data.Distributive

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

Defined in Data.Distributive

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

Defined in Data.Distributive

Methods

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

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

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

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

Distributive ( Tagged t) Source #
Instance details

Defined in Data.Distributive

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

Defined in Data.Distributive

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

Defined in Data.Distributive

Methods

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

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

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

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

Distributive g => Distributive ( IdentityT g) Source #
Instance details

Defined in Data.Distributive

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

Defined in Data.Distributive

Distributive ((->) e :: Type -> Type ) Source #
Instance details

Defined in Data.Distributive

Methods

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

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

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

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

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

Defined in Data.Distributive

Methods

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

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

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

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

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

Defined in Data.Distributive

Methods

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

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

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

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

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

Defined in Data.Distributive

Methods

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

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

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

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

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

Defined in Data.Distributive

Methods

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

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

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

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

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

Defined in Data.Distributive

Methods

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

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

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

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

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

The dual of traverse

cotraverse f = fmap f . distribute

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

The dual of mapM

comapM f = fmap f . distributeM