#Traversable1 Source

class (Foldable1 t, Traversable t) <= Traversable1 t  where

Traversable1 represents data structures with a minimum of one element that can be traversed, accumulating results and effects in some Applicative functor.

  • traverse1 runs an action for every element in a data structure, and accumulates the results.
  • sequence1 runs the actions contained in a data structure, and accumulates the results.

The traverse1 and sequence1 functions should be compatible in the following sense:

  • traverse1 f xs = sequence1 (f <$> xs)
  • sequence1 = traverse1 identity

Traversable1 instances should also be compatible with the corresponding Foldable1 instances, in the following sense:

  • foldMap1 f = runConst <<< traverse1 (Const <<< f)

Default implementations are provided by the following functions:

  • traverse1Default
  • sequence1Default



#traverse1Default Source

traverse1Default :: forall m b a t. Traversable1 t => Apply m => (a -> m b) -> t a -> m (t b)

A default implementation of traverse1 using sequence1.

#sequence1Default Source

sequence1Default :: forall m a t. Traversable1 t => Apply m => t (m a) -> m (t a)

A default implementation of sequence1 using traverse1.