Tuple

object Tuple
Companion
class
class Object
trait Matchable
class Any

Type members

Types

type Concat[X <: Tuple, +Y <: Tuple] = X match { case EmptyTuple => Y case x1 *: xs1 => x1 *: Concat[xs1, Y] }

Type of the concatenation of two tuples

Type of the concatenation of two tuples

type Drop[T <: Tuple, N <: Int] = N match { case 0 => T case S[n1] => T match { case EmptyTuple => EmptyTuple case x *: xs => Drop[xs, n1] } }

Transforms a tuple (T1, ..., Tn) into (Ti+1, ..., Tn).

Transforms a tuple (T1, ..., Tn) into (Ti+1, ..., Tn).

type Elem[X <: Tuple, N <: Int] = X match { case x *: xs => N match { case 0 => x case S[n1] => Elem[xs, n1] } }

Type of the element a position N in the tuple X

Type of the element a position N in the tuple X

type Filter[Tup <: Tuple, P <: ([_] =>> Boolean)] = Tup match { case EmptyTuple => EmptyTuple case h *: t => P[h] match { case true => h *: Filter[t, P] case false => Filter[t, P] } }

Filters out those members of the tuple for which the predicate P returns false. A predicate P[X] is a type that can be either true or false. For example:

Filters out those members of the tuple for which the predicate P returns false. A predicate P[X] is a type that can be either true or false. For example:

type IsString[x] = x match {
  case String => true
  case _ => false
}
Filter[(1, "foo", 2, "bar"), IsString] =:= ("foo", "bar")
type FlatMap[Tup <: Tuple, F <: ([_] =>> Tuple)] = Tup match { case EmptyTuple => EmptyTuple case h *: t => Concat[F[h], FlatMap[t, F]] }

Converts a tuple (T1, ..., Tn) to a flattened (..F[T1], ..., ..F[Tn])

Converts a tuple (T1, ..., Tn) to a flattened (..F[T1], ..., ..F[Tn])

type Fold[T <: Tuple, Z, F[_, _]] = T match { case EmptyTuple => Z case h *: t => F[h, Fold[t, Z, F]] }

Fold a tuple (T1, ..., Tn) into F[T1, F[... F[Tn, Z]...]]]

Fold a tuple (T1, ..., Tn) into F[T1, F[... F[Tn, Z]...]]]

type Head[X <: NonEmptyTuple] = X match { case x *: _ => x }

Type of the head of a tuple

Type of the head of a tuple

type InverseMap[X <: Tuple, F[_]] = X match { case F[x] *: t => x *: InverseMap[t, F] case EmptyTuple => EmptyTuple }

Converts a tuple (F[T1], ..., F[Tn]) to (T1, ... Tn)

Converts a tuple (F[T1], ..., F[Tn]) to (T1, ... Tn)

type IsMappedBy[F[_]] = [X <: Tuple] =>> X =:= Map[InverseMap[X, F], F]

Implicit evidence.

Implicit evidence. IsMappedBy[F][X] is present in the implicit scope iff X is a tuple for which each element's type is constructed via F. E.g. (F[A1], ..., F[An]), but not (F[A1], B2, ..., F[An]) where B2 does not have the shape of F[A].

type Map[Tup <: Tuple, F[_]] = Tup match { case EmptyTuple => EmptyTuple case h *: t => F[h] *: Map[t, F] }

Converts a tuple (T1, ..., Tn) to (F[T1], ..., F[Tn])

Converts a tuple (T1, ..., Tn) to (F[T1], ..., F[Tn])

type Size[X <: Tuple] = X match { case EmptyTuple => 0 case x *: xs => S[Size[xs]] }

Literal constant Int size of a tuple

Literal constant Int size of a tuple

type Split[T <: Tuple, N <: Int] = (Take[T, N], Drop[T, N])

Splits a tuple (T1, ..., Tn) into a pair of two tuples (T1, ..., Ti) and (Ti+1, ..., Tn).

Splits a tuple (T1, ..., Tn) into a pair of two tuples (T1, ..., Ti) and (Ti+1, ..., Tn).

type Tail[X <: NonEmptyTuple] = X match { case _ *: xs => xs }

Type of the tail of a tuple

Type of the tail of a tuple

type Take[T <: Tuple, N <: Int] = N match { case 0 => EmptyTuple case S[n1] => T match { case EmptyTuple => EmptyTuple case x *: xs => x *: Take[xs, n1] } }

Transforms a tuple (T1, ..., Tn) into (T1, ..., Ti).

Transforms a tuple (T1, ..., Tn) into (T1, ..., Ti).

type Union[T <: Tuple] = Fold[T, Nothing, [x, y] =>> x | y]

Given a tuple (T1, ..., Tn), returns a union of its member types: T1 | ... | Tn.

Given a tuple (T1, ..., Tn), returns a union of its member types: T1 | ... | Tn. Returns Nothing if the tuple is empty.

type Zip[T1 <: Tuple, T2 <: Tuple] = (T1, T2) match { case (h1 *: t1, h2 *: t2) => (h1, h2) *: Zip[t1, t2] case (EmptyTuple, _) => EmptyTuple case (_, EmptyTuple) => EmptyTuple case _ => Tuple }

Given two tuples, A1 *: ... *: An * At and B1 *: ... *: Bn *: Bt where at least one of At or Bt is EmptyTuple or Tuple, returns the tuple type (A1, B1) *: ... *: (An, Bn) *: Ct where Ct is EmptyTuple if At or Bt is EmptyTuple, otherwise Ct is Tuple.

Given two tuples, A1 *: ... *: An * At and B1 *: ... *: Bn *: Bt where at least one of At or Bt is EmptyTuple or Tuple, returns the tuple type (A1, B1) *: ... *: (An, Bn) *: Ct where Ct is EmptyTuple if At or Bt is EmptyTuple, otherwise Ct is Tuple.

Value members

Concrete methods

Empty tuple

Empty tuple

def apply[T](x: T): T *: EmptyTuple

Tuple with one element

Tuple with one element

def fromArray[T](xs: Array[T]): Tuple

Convert an array into a tuple of unknown arity and types

Convert an array into a tuple of unknown arity and types

def fromIArray[T](xs: IArray[T]): Tuple

Convert an immutable array into a tuple of unknown arity and types

Convert an immutable array into a tuple of unknown arity and types

def fromProduct(product: Product): Tuple

Convert a Product into a tuple of unknown arity and types

Convert a Product into a tuple of unknown arity and types

def fromProductTyped[P <: Product](p: P)(using m: ProductOf[P]): `<none>`
def unapply(x: EmptyTuple): true

Matches an empty tuple.

Matches an empty tuple.