Packages

p

org.specs2

foldm

package foldm

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait FoldM [T, M[_], U] extends AnyRef

    A FoldM is a "left fold" over a data structure with:

    A FoldM is a "left fold" over a data structure with:

    • a 'start' value
    • a 'fold' method to accumulate state
    • an 'end' method to finalize the result

    Both 'start' and 'end' have an effect which allows the whole folding to take place inside a context M.

    If 'M' has an 'Apply' instance then FoldM can be made Applicative to allow the folding of two values U and S at the same time.

    If 'M' has a 'Monad' instance then FoldM can be made into a 'Compose' instance which allows to compose 2 folds into one, for example:

    • 'sum' computes the sum of some elements
    • 'list' accumulates all the elements in a list
    • the 'sum compose list' will accumulate the list of all the sums over some elements (this is a 'scan')

    A FoldM can be used with a 'FoldableM' which produces the elements to fold over. Examples of FoldableM include

    • a List
    • an Iterator
    • a scalaz Process

    Usage example:

    sum.run(List(1, 2, 3)) == 6

  2. trait FoldableM [F[_], M[_]] extends AnyRef

    A structure delivering elements of type A (variable type, like a List) and which can be folded over

  3. trait FoldableMS [A, F, M[_]] extends AnyRef

    A structure delivering elements of type A (fixed type, like an InputStream) and which can be folded over

Value Members

  1. object FoldId

    List of predefined FoldIds

  2. object FoldM

    Typeclass instances and creation methods for folds

  3. object FoldableM
  4. object FoldableMS

Ungrouped