Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.39 KB

File metadata and controls

47 lines (30 loc) · 1.39 KB

Module Data.Bitraversable

Bitraversable

class (Bifunctor t, Bifoldable t) <= Bitraversable t where
  bitraverse :: forall f a b c d. (Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
  bisequence :: forall f a b. (Applicative f) => t (f a) (f b) -> f (t a b)

Bitraversable represents data structures with two type arguments which can be traversed.

A traversal for such a structure requires two functions, one for each type argument. Type class instances should choose the appropriate function based on the type of the element encountered at each point of the traversal.

Default implementations are provided by the following functions:

  • bitraverseDefault
  • bisequenceDefault

bitraverseDefault

bitraverseDefault :: forall t f a b c d. (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)

A default implementation of bitraverse using bisequence and bimap.

bisequenceDefault

bisequenceDefault :: forall t f a b. (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)

A default implementation of bisequence using bitraverse.

bifor

bifor :: forall t f a b c d. (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)

Traverse a data structure, accumulating effects and results using an Applicative functor.