Module

Data.Distributive

#Distributive

class (Functor f) <= Distributive f  where

Categorical dual of Traversable:

  • distribute is the dual of sequence - it zips an arbitrary collection of containers.
  • collect is the dual of traverse - it traverses an arbitrary collection of values.

Laws:

  • distribute = collect identity
  • distribute <<< distribute = identity
  • collect f = distribute <<< map f
  • map f = unwrap <<< collect (Identity <<< f)
  • map distribute <<< collect f = unwrap <<< collect (Compose <<< f)

Members

Instances

#distributeDefault

distributeDefault :: forall a f g. Distributive f => Functor g => g (f a) -> f (g a)

A default implementation of distribute, based on collect.

#collectDefault

collectDefault :: forall a b f g. Distributive f => Functor g => (a -> f b) -> g a -> f (g b)

A default implementation of collect, based on distribute.

#cotraverse

cotraverse :: forall a b f g. Distributive f => Functor g => (g a -> b) -> g (f a) -> f b

Zip an arbitrary collection of containers and summarize the results

Modules