com.jnape.palatable.lambda.traversable

## Interface Traversable<A,T extends Traversable<?,T>>

- Type Parameters:
    `A` - The type of the parameter
    `T` - The unification parameter
  All Superinterfaces:
    Functor<A,T>
  All Known Implementing Classes:
    Choice2, Choice3, Choice4, Choice5, Choice6, Choice7, Choice8, Const, Either, Identity, LambdaIterable, LambdaMap, Lazy, Maybe, RecursiveResult, SingletonHList, Tagged, These, Try, Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7, Tuple8

      public interface Traversable<A,T extends Traversable<?,T>>
      extends Functor<A,T>

  An interface for a class of data structures that can be "traversed from left to right" in a structure-preserving way, successively applying some applicative computation to each element and collapsing the results into a single resulting applicative.

  The same rules that apply to `Functor` apply to `Traversable`, along with the following additional 3 laws:

  - naturality: `t.apply(trav.traverse(f, pure).<Object>fmap(id()).coerce()) .equals(trav.traverse(t.compose(f), pure2).<Object>fmap(id()).coerce())`
  - identity: `trav.traverse(Identity::new, x -> new Identity<>(x)).equals(new Identity<>(trav)`
  - composition: `trav.traverse(f.andThen(x -> x.fmap(g)).andThen(Compose::new), x -> new Compose<>(new Identity<>(new Identity<>(x)))).equals(new Compose<Identity, Identity, Traversable<Object, Trav>>(trav.traverse(f, x -> new Identity<>(x)).fmap(t -> t.traverse(g, x -> new Identity<>(x)))))`

  For more information, read about Traversables.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default <B> Traversable<B,T>` | `fmap(Fn1<? super A,? extends B> fn)` Covariantly transmute this functor's parameter using the given mapping function.
    `<B,App extends Applicative<?,App>,TravB extends Traversable<B,T>,AppTrav extends Applicative<TravB,App>> AppTrav` | `traverse(Fn1<? super A,? extends Applicative<B,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)` Apply `fn` to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

      `coerce`

- - ### Method Detail

    - #### traverse

          <B,App extends Applicative<?,App>,TravB extends Traversable<B,T>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super A,? extends Applicative<B,App>> fn,
                                                                                                                                    Fn1<? super TravB,? extends AppTrav> pure)

      Apply `fn` to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.
      Type Parameters:
        `B` - the resulting element type
        `App` - the result applicative type
        `TravB` - this Traversable instance over B
        `AppTrav` - the full inferred resulting type from the traversal
      Parameters:
        `fn` - the function to apply
        `pure` - the applicative pure function
      Returns:
        the traversed Traversable, wrapped inside an applicative

    - #### fmap

          default <B> Traversable<B,T> fmap(Fn1<? super A,? extends B> fn)

      Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
      Specified by:
        `fmap` in interface `Functor<A,T extends Traversable<?,T>>`
      Type Parameters:
        `B` - the new parameter type
      Parameters:
        `fn` - the mapping function
      Returns:
        a functor over B (the new parameter type)