Object/Trait

cats

Foldable

Related Docs: trait Foldable | package cats

Permalink

object Foldable extends Serializable

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Foldable
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait AllOps[F[_], A] extends Ops[F, A]

    Permalink
  2. trait Ops[F[_], A] extends AnyRef

    Permalink
  3. trait ToFoldableOps extends AnyRef

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply[F[_]](implicit instance: Foldable[F]): Foldable[F]

    Permalink
    Annotations
    @inline()
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def iterateRight[A, B](it: Iterator[A], lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]

    Permalink
  14. def iteratorFoldM[M[_], A, B](it: Iterator[A], z: B)(f: (B, A) ⇒ M[B])(implicit M: Monad[M]): M[B]

    Permalink

    Implementation of Foldable.foldM which can short-circuit for structures with an Iterator.

    Implementation of Foldable.foldM which can short-circuit for structures with an Iterator.

    For example we can sum a Stream of integers and stop if the sum reaches 100 (if we reach the end of the Stream before getting to 100 we return the total sum) :

    scala> import cats.implicits._
    scala> type LongOr[A] = Either[Long, A]
    scala> def sumStream(s: Stream[Int]): Long =
         |   Foldable.iteratorFoldM[LongOr, Int, Long](s.toIterator, 0L){ (acc, n) =>
         |     val sum = acc + n
         |     if (sum < 100L) Right(sum) else Left(sum)
         |   }.merge
    
    scala> sumStream(Stream.continually(1))
    res0: Long = 100
    
    scala> sumStream(Stream(1,2,3,4))
    res1: Long = 10

    Note that Foldable[Stream].foldM uses this method underneath, so you wouldn't call this method explicitly like in the example above.

  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. object nonInheritedOps extends ToFoldableOps

    Permalink
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. object ops

    Permalink
  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped