Traversable
A trait for data structures that can be traversed in left-to-right order with an applicative functor.
Instances
instance Traversable[Chain]
Sourceinstance Traversable[DelayList]
Sourceinstance Traversable[Identity]
Sourceinstance Traversable[List]
Sourceinstance Traversable[Map[k]]
Sourceinstance Traversable[Nec]
Sourceinstance Traversable[Nel]
Sourceinstance Traversable[Option]
Sourceinstance Traversable[RedBlackTree[k]]
Sourceinstance Traversable[Vector]
SourceSignatures
def traverse(f: a -> m[b] \ ef, t: t[a]): m[t[b]] \ ef + Aef[t] with Traversable[t], Applicative[m]
SourceReturns the result of applying the applicative mapping function f
to all the elements of the
data structure t
.
Trait Definitions
def sequence(t: t[m[a]]): m[t[a]] \ Aef[t] with Traversable[t], Applicative[m]
SourceReturns the result of running all the actions in the data structure t
.
Module Definitions
def for(t: t[a], f: a -> m[b] \ ef): m[t[b]] \ ef + Aef[t] with Applicative[m], Traversable[t]
SourceReturns the result of applying the applicative mapping function f
to all the elements of the
data structure t
.
for
is traverse
with it's arguments flipped.
def mapAccumLeft(f: acc -> (a -> (acc, b) \ ef), start: acc, t: t[a]): (acc, t[b]) \ ef + Aef[t] with Traversable[t]
SourceReturns the result of applying f
to the traversable structure t
and the initial state acc
.
The result is a pair of the final state and the updated copy of the structure.
mapAccumLeft
is essentially the combination of map
and foldLeft
- like map it returns an updated copy
of the initial structure, like foldLeft
it passes an updating accumulator through each step of the traversal.