-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell 98 Distributive functors -- Dual to Traversable -- -- Haskell 98 Distributive functors -- Dual to Traversable @package distributive @version 0.1 module Data.Distributive -- | This is the categorical dual of Traversable. However, there -- appears to be little benefit to allow the distribution via an -- arbitrary comonad so we restrict ourselves to Functor. -- -- Minimal complete definition: distribute or collect -- -- 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. class Functor g => Distributive g distribute :: (Distributive g, Functor f) => f (g a) -> g (f a) collect :: (Distributive g, Functor f) => (a -> g b) -> f a -> g (f b) distributeM :: (Distributive g, Monad m) => m (g a) -> g (m a) collectM :: (Distributive g, Monad m) => (a -> g b) -> m a -> g (m b) -- | Every Distributive is a Functor. This is a valid default -- definition. fmapDefault :: Distributive g => (a -> b) -> g a -> g b cotraverse :: (Functor f, Distributive g) => (f a -> b) -> f (g a) -> g b comapM :: (Monad m, Distributive g) => (m a -> b) -> m (g a) -> g b instance Distributive g => Distributive (IdentityT g) instance Distributive g => Distributive (ReaderT e g) instance Distributive ((->) e) instance Distributive Identity