Portability | portable |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
- class Functor g => Distributive g where
- cotraverse :: Comonad w => (w a -> b) -> w (g a) -> g b
- distribute :: Comonad w => w (g a) -> g (w a)
- fmapDefault :: Distributive g => (a -> b) -> g a -> g b
Documentation
class Functor g => Distributive g whereSource
This is the categorical dual of Traversable
Minimal definition: mapW
or distribute
mapW = fmap f . duplicate distribute = mapW id
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.
cotraverse :: Comonad w => (w a -> b) -> w (g a) -> g bSource
The dual of Data.Traversable.mapM
distribute :: Comonad w => w (g a) -> g (w a)Source
The dual of Data.Traversable.sequence
Distributive Identity | |
Distributive ((->) e) | |
Distributive g => Distributive (IdentityT g) | |
Distributive g => Distributive (ReaderT e g) |
fmapDefault :: Distributive g => (a -> b) -> g a -> g bSource
Every Distributive
is a Functor
. This is a valid default definition.