NonEmptyForEach

zio.prelude.NonEmptyForEach
See theNonEmptyForEach companion object
trait NonEmptyForEach[F[_]] extends ForEach[F]

A NonEmptyForEach describes a ForEach that is guaranteed to contain at least one element, such as a NonEmptyList, a NonEmptyChunk, or certain tree like data structures.

Because of the additional information that there is always at least one element, certain operations are available on a NonEmptyForEach that are not available on a ForEach. For example, if an ordering is defined on the elements of a NonEmptyForEach then min and max are defined, whereas for a ForEach only minOption and maxOption would be, since the collection might not contain any elements at all.

Attributes

Companion
object
Graph
Supertypes
trait ForEach[F]
trait Covariant[F]
trait Invariant[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Value members

Abstract methods

def forEach1[G[_] : Covariant, A, B](fa: F[A])(f: A => G[B]): G[F[B]]

Traverse each element in the collection using the specified effectual function f, returning a new collection with the results in the context of the effect.

Traverse each element in the collection using the specified effectual function f, returning a new collection with the results in the context of the effect.

Attributes

Concrete methods

def flip1[G[_] : Covariant, A](fa: F[G[A]]): G[F[A]]

Converts a collection with elements that are in the context of effects to a collection of elements in the context of an effect.

Converts a collection with elements that are in the context of effects to a collection of elements in the context of an effect.

Attributes

override def forEach[G[_] : Covariant, A, B](fa: F[A])(f: A => G[B]): G[F[B]]

Traverse each element in the collection using the specified effectual function f, returning a new collection with the results in the context of the effect.

Traverse each element in the collection using the specified effectual function f, returning a new collection with the results in the context of the effect.

Attributes

Definition Classes
def forEach1_[G[_] : Covariant, A](fa: F[A])(f: A => G[Any]): G[Unit]

Traverses each element in the collection with the specified effectual function f purely for its effects.

Traverses each element in the collection with the specified effectual function f purely for its effects.

Attributes

override def forEach_[G[_] : Covariant, A](fa: F[A])(f: A => G[Any]): G[Unit]

Traverses each element in the collection with the specified effectual function f purely for its effects.

Traverses each element in the collection with the specified effectual function f purely for its effects.

Attributes

Definition Classes
def max[A : Ord](fa: F[A]): A

Returns the largest value in the collection if one exists or None otherwise.

Returns the largest value in the collection if one exists or None otherwise.

Attributes

def maxBy[A, B : Ord](fa: F[A])(f: A => B): A

Returns the largest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Returns the largest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Attributes

def min[A : Ord](fa: F[A]): A

Returns the smallest value in the collection if one exists or None otherwise.

Returns the smallest value in the collection if one exists or None otherwise.

Attributes

def minBy[A, B : Ord](fa: F[A])(f: A => B): A

Returns the smallest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Returns the smallest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Attributes

def reduce1[A : Associative](fa: F[A]): A

Reduces the non-empty collection of associative elements.

Reduces the non-empty collection of associative elements.

Attributes

def reduceAll[A](fa: F[A])(f: (A, A) => A): A

Reduces the collection to a summary value using the binary function f.

Reduces the collection to a summary value using the binary function f.

Attributes

def reduceIdempotent1[A : Equal](fa: F[A]): A

Reduces the collection to a summary value using the idempotent operation, returning None if the collection is empty.

Reduces the collection to a summary value using the idempotent operation, returning None if the collection is empty.

Attributes

def reduceMap[A, B : Associative](fa: F[A])(f: A => B): B

Maps each element of the collection to a type B for which a combine operation is defined using the function f and then reduces those values to a single summary using the combine operation.

Maps each element of the collection to a type B for which a combine operation is defined using the function f and then reduces those values to a single summary using the combine operation.

Attributes

def reduceMapLeft[A, B](fa: F[A])(map: A => B)(reduce: (B, A) => B): B

Reduces the elements of this collection from left to right using the function map to transform the first value to the type B and then the function reduceAll to combine the B value with each other A value.

Reduces the elements of this collection from left to right using the function map to transform the first value to the type B and then the function reduceAll to combine the B value with each other A value.

Attributes

def reduceMapRight[A, B](fa: F[A])(map: A => B)(reduce: (A, B) => B): B

Reduces the elements of this collection from right to left using the function map to transform the first value to the type B and then the function reduceAll to combine the B value with each other A value.

Reduces the elements of this collection from right to left using the function map to transform the first value to the type B and then the function reduceAll to combine the B value with each other A value.

Attributes

Converts the collection to a NonEmptyChunk.

Converts the collection to a NonEmptyChunk.

Attributes

def toNonEmptyList[A](fa: F[A]): NonEmptyList[A]

Converts the collection to a NonEmptyList.

Converts the collection to a NonEmptyList.

Attributes

Inherited methods

def collect[A, B](fa: F[A])(pf: PartialFunction[A, B])(implicit identityBoth: IdentityBoth[F], identityEither: IdentityEither[F]): F[B]

Collects elements of the collection for which the partial functionpf is defined.

Collects elements of the collection for which the partial functionpf is defined.

Attributes

Inherited from:
ForEach

Collects elements of the collection for which the effectual partial function pf is defined.

Collects elements of the collection for which the effectual partial function pf is defined.

Attributes

Inherited from:
ForEach
final def compose[G[_] : ForEach]: ForEach[{ type lambda = [A] =>> F[G[A]]; }#<none>]

Attributes

Inherited from:
ForEach
final def compose[G[_]](implicit g: Contravariant[G]): Contravariant[{ type lambda = [A] =>> F[G[A]]; }#<none>]

Compose covariant and contravariant functors.

Compose covariant and contravariant functors.

Attributes

Inherited from:
Covariant
final def compose[G[_]](implicit g: Covariant[G]): Covariant[{ type lambda = [A] =>> F[G[A]]; }#<none>]

Compose two covariant functors.

Compose two covariant functors.

Attributes

Inherited from:
Covariant
final def compose[G[_]](implicit g: Invariant[G]): Invariant[{ type lambda = [A] =>> F[G[A]]; }#<none>]

Compose two invariant functors.

Compose two invariant functors.

Attributes

Inherited from:
Invariant
def compositionLaw[A, B, C](fa: F[A], f: Equivalence[A, B], g: Equivalence[B, C])(implicit equal: Equal[F[C]]): Boolean

Attributes

Inherited from:
Invariant
def concatenate[A : Identity](fa: F[A]): A

Reduces the collection to a summary value using the associative operation. Alias for fold.

Reduces the collection to a summary value using the associative operation. Alias for fold.

Attributes

Inherited from:
ForEach
def contains[A, A1 >: A](fa: F[A])(a: A1)(implicit A: Equal[A1]): Boolean

Returns whether the collection contains the specified element.

Returns whether the collection contains the specified element.

Attributes

Inherited from:
ForEach
def count[A](fa: F[A])(f: A => Boolean): Int

Returns the number of elements in the collection that satisfy the specified predicate.

Returns the number of elements in the collection that satisfy the specified predicate.

Attributes

Inherited from:
ForEach
def exists[A](fa: F[A])(f: A => Boolean): Boolean

Returns whether any element of the collection satisfies the specified predicate.

Returns whether any element of the collection satisfies the specified predicate.

Attributes

Inherited from:
ForEach
def filter[A](fa: F[A])(f: A => Boolean)(implicit identityBoth: IdentityBoth[F], identityEither: IdentityEither[F]): F[A]

Filters the collection with the predicate f.

Filters the collection with the predicate f.

Attributes

Inherited from:
ForEach

Filters the collection with the effectual predicate f.

Filters the collection with the effectual predicate f.

Attributes

Inherited from:
ForEach
def find[A](fa: F[A])(f: A => Boolean): Option[A]

Returns the first element in the collection satisfying the specified predicate if one exists or None otherwise.

Returns the first element in the collection satisfying the specified predicate if one exists or None otherwise.

Attributes

Inherited from:
ForEach
def flip[G[_] : Covariant, A](fa: F[G[A]]): G[F[A]]

Converts a collection with elements that are in the context of effects to a collection of elements in the context of an effect.

Converts a collection with elements that are in the context of effects to a collection of elements in the context of an effect.

Attributes

Inherited from:
ForEach
def fold[A : Identity](fa: F[A]): A

Folds over the elements of this collection using an associative operation and an identity. Alias for reduceIdentity.

Folds over the elements of this collection using an associative operation and an identity. Alias for reduceIdentity.

Attributes

Inherited from:
ForEach
def foldLeft[S, A](fa: F[A])(s: S)(f: (S, A) => S): S

Folds over the elements of this collection from left to right to produce a summary value, maintaining some internal state along the way.

Folds over the elements of this collection from left to right to produce a summary value, maintaining some internal state along the way.

Attributes

Inherited from:
ForEach
def foldLeftM[G[_] : Covariant, S, A](fa: F[A])(s: S)(f: (S, A) => G[S]): G[S]

Effectually fold over the elements of this collection from left to right to produce a summary value, maintaining some internal state along the way.

Effectually fold over the elements of this collection from left to right to produce a summary value, maintaining some internal state along the way.

Attributes

Inherited from:
ForEach
def foldMap[A, B : Identity](fa: F[A])(f: A => B): B

Maps each element of the collection to a type B for which an Identity is defined using the function f, then reduces those values to a single summary using the combine operation of Identity, or the identity element if the collection is empty.

Maps each element of the collection to a type B for which an Identity is defined using the function f, then reduces those values to a single summary using the combine operation of Identity, or the identity element if the collection is empty.

Attributes

Inherited from:
ForEach
def foldMapM[G[_] : IdentityBoth, A, B : Identity](fa: F[A])(f: A => G[B]): G[B]

Effectfully maps each element of the collection to a type B for which an Identity is defined using the function f, then reduces those values to a single summary using the combine operation of Identity, or the identity element if the collection is empty.

Effectfully maps each element of the collection to a type B for which an Identity is defined using the function f, then reduces those values to a single summary using the combine operation of Identity, or the identity element if the collection is empty.

Attributes

Inherited from:
ForEach
def foldRight[S, A](fa: F[A])(s: S)(f: (A, S) => S): S

Folds over the elements of this collection from right to left to produce a summary value, maintaining some internal state along the way.

Folds over the elements of this collection from right to left to produce a summary value, maintaining some internal state along the way.

Attributes

Inherited from:
ForEach
def foldRightM[G[_] : Covariant, S, A](fa: F[A])(s: S)(f: (A, S) => G[S]): G[S]

Effectually fold over the elements of this collection from right to left to produce a summary value, maintaining some internal state along the way.

Effectually fold over the elements of this collection from right to left to produce a summary value, maintaining some internal state along the way.

Attributes

Inherited from:
ForEach
def forEachFlatten[G[_] : Covariant, A, B](fa: F[A])(f: A => G[F[B]])(implicit evidence$1: IdentityBoth[G], evidence$2: Covariant[G], F: AssociativeFlatten[F]): G[F[B]]

Attributes

Inherited from:
ForEach
def forall[A](fa: F[A])(f: A => Boolean): Boolean

Returns whether any element of the collection satisfies the specified predicate.

Returns whether any element of the collection satisfies the specified predicate.

Attributes

Inherited from:
ForEach
def fproduct[A, B](f: A => B): (F[A]) => F[(A, B)]

Attributes

Inherited from:
Covariant
def fproductLeft[A, B](f: A => B): (F[A]) => F[(B, A)]

Attributes

Inherited from:
Covariant
def groupByNonEmpty[V, K](fa: F[V])(f: V => K): Map[K, NonEmptyChunk[V]]

Attributes

Inherited from:
ForEach
def groupByNonEmptyM[G[_] : Covariant, V, K](fa: F[V])(f: V => G[K]): G[Map[K, NonEmptyChunk[V]]]

Attributes

Inherited from:
ForEach
def identityLaw1[A](fa: F[A])(implicit equal: Equal[F[A]]): Boolean

Attributes

Inherited from:
Invariant
def intersperse[A](fa: F[A], middle: A)(implicit I: Identity[A]): A

Folds over the elements of this collection using an associative operation with the middle element interspersed between every element.

Folds over the elements of this collection using an associative operation with the middle element interspersed between every element.

Attributes

Inherited from:
ForEach
final def invmap[A, B](f: Equivalence[A, B]): Equivalence[F[A], F[B]]

Attributes

Inherited from:
Covariant
def isEmpty[A](fa: F[A]): Boolean

Returns whether the collection is empty.

Returns whether the collection is empty.

Attributes

Inherited from:
ForEach
def map[A, B](f: A => B): (F[A]) => F[B]

Lifts a function operating on values to a function that operates on each element of a collection.

Lifts a function operating on values to a function that operates on each element of a collection.

Attributes

Inherited from:
ForEach
def mapAccum[S, A, B](fa: F[A])(s: S)(f: (S, A) => (S, B)): (S, F[B])

Statefully maps over the elements of the collection, maintaining some state along the way and returning the final state along with the new collection.

Statefully maps over the elements of the collection, maintaining some state along the way and returning the final state along with the new collection.

Attributes

Inherited from:
ForEach
final def mapSubset[A, B : AnyType](f: A => B): (F[A]) => F[B]

Attributes

Inherited from:
Covariant
def maxByOption[A, B : Ord](fa: F[A])(f: A => B): Option[A]

Returns the largest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Returns the largest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Attributes

Inherited from:
ForEach
def maxOption[A : Ord](fa: F[A]): Option[A]

Returns the largest value in the collection if one exists or None otherwise.

Returns the largest value in the collection if one exists or None otherwise.

Attributes

Inherited from:
ForEach
def minByOption[A, B : Ord](fa: F[A])(f: A => B): Option[A]

Returns the smallest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Returns the smallest element in the collection if one exists, using the function f to map each element to a type for which an Ord is defined, or None otherwise.

Attributes

Inherited from:
ForEach
def minOption[A : Ord](fa: F[A]): Option[A]

Returns the smallest value in the collection if one exists or None otherwise.

Returns the smallest value in the collection if one exists or None otherwise.

Attributes

Inherited from:
ForEach
def nonEmpty[A](fa: F[A]): Boolean

Returns whether the collection contains at least one element

Returns whether the collection contains at least one element

Attributes

Inherited from:
ForEach
def partitionMap[A, B, C](fa: F[A])(f: A => Either[B, C])(implicit both: IdentityBoth[F], either: IdentityEither[F]): (F[B], F[C])

Partitions the collection based on the specified function.

Partitions the collection based on the specified function.

Attributes

Inherited from:
ForEach
def partitionMapM[G[_] : Covariant, A, B, C](fa: F[A])(f: A => G[Either[B, C]])(implicit evidence$1: IdentityBoth[G], evidence$2: Covariant[G], both: IdentityBoth[F], either: IdentityEither[F]): G[(F[B], F[C])]

Partitions the collection based on the specified effectual function.

Partitions the collection based on the specified effectual function.

Attributes

Inherited from:
ForEach
def partitionMapV[W, E, A, B](fa: F[A])(f: A => ZValidation[W, E, B])(implicit both: IdentityBoth[F], either: IdentityEither[F]): (F[E], F[B])

Partitions the collection based on the specified validation function.

Partitions the collection based on the specified validation function.

Attributes

Inherited from:
ForEach
def product[A](fa: F[A])(implicit ev: Identity[subtypeF.Type[A]]): A

Returns the product of all elements in the collection.

Returns the product of all elements in the collection.

Attributes

Inherited from:
ForEach

Reduces the collection to a summary value using the associative operation, returning None if the collection is empty.

Reduces the collection to a summary value using the associative operation, returning None if the collection is empty.

Attributes

Inherited from:
ForEach
def reduceIdempotent[A : Equal](fa: F[A]): Option[A]

Reduces the collection to a summary value using the idempotent operation, returning None if the collection is empty.

Reduces the collection to a summary value using the idempotent operation, returning None if the collection is empty.

Attributes

Inherited from:
ForEach
def reduceIdentity[A : Identity](fa: F[A]): A

Reduces the collection to a summary value using the associative operation. Alias for fold.

Reduces the collection to a summary value using the associative operation. Alias for fold.

Attributes

Inherited from:
ForEach
def reduceMapOption[A, B : Associative](fa: F[A])(f: A => B): Option[B]

Maps each element of the collection to a type B for which an associative operation exists and then reduces the values using the associative operation, returning None if the collection is empty.

Maps each element of the collection to a type B for which an associative operation exists and then reduces the values using the associative operation, returning None if the collection is empty.

Attributes

Inherited from:
ForEach
def reduceOption[A](fa: F[A])(f: (A, A) => A): Option[A]

Reduces the collection to a summary value using the binary function f, returning None if the collection is empty.

Reduces the collection to a summary value using the binary function f, returning None if the collection is empty.

Attributes

Inherited from:
ForEach
def reverse[A](fa: F[A]): F[A]

Reverses the order of elements in the collection.

Reverses the order of elements in the collection.

Attributes

Inherited from:
ForEach
def size[A](fa: F[A]): Int

Returns the number of elements in the collection.

Returns the number of elements in the collection.

Attributes

Inherited from:
ForEach
def sum[A](fa: F[A])(implicit ev: Identity[subtypeF.Type[A]]): A

Returns the sum of all elements in the collection.

Returns the sum of all elements in the collection.

Attributes

Inherited from:
ForEach
def toChunk[A](fa: F[A]): Chunk[A]

Converts the collection to a Chunk.

Converts the collection to a Chunk.

Attributes

Inherited from:
ForEach
def toList[A](fa: F[A]): List[A]

Converts the collection to a List.

Converts the collection to a List.

Attributes

Inherited from:
ForEach
def zipAll[A, B, C](fa: F[A], fb: F[B])(implicit both: IdentityBoth[F], either: IdentityEither[F]): F[These[A, B]]

Zips the left collection and right collection together, using None to handle the case where one collection is larger than the other.

Zips the left collection and right collection together, using None to handle the case where one collection is larger than the other.

Attributes

Inherited from:
ForEach
def zipAllWith[A, B, C](fa: F[A], fb: F[B])(f: (These[A, B]) => C)(implicit both: IdentityBoth[F], either: IdentityEither[F]): F[C]

Zips the left collection and right collection together, using the specified function to handle the cases where one collection is larger than the other.

Zips the left collection and right collection together, using the specified function to handle the cases where one collection is larger than the other.

Attributes

Inherited from:
ForEach
def zipWithIndex[A](fa: F[A]): F[(A, Int)]

Zips each element of the collection with its index.

Zips each element of the collection with its index.

Attributes

Inherited from:
ForEach