Module

Data.Distributive

Package
purescript-distributive
Repository
purescript/purescript-distributive

#Distributive Source

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 Source

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

A default implementation of distribute, based on collect.

#collectDefault Source

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

A default implementation of collect, based on distribute.

#cotraverse Source

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

Zip an arbitrary collection of containers and summarize the results