Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/=:=

=:=

scala.=:=
sealed abstractclass=:=[From,To] extendsFrom<:<To,Serializable

An instance ofA =:= B witnesses that the typesA andB are equal. It also acts as aA <:< B, but not aB <:< A (directly) due to restrictions on subclassing.

In case of any confusion over which method goes in what direction, all the "Co" methods (includingapply) go from left to right in the type ("with" the type), and all the "Contra" methods go from right to left ("against" the type). E.g.,apply turns aFrom into aTo, andsubstituteContra replaces theTos in a type withFroms.

Type parameters

From

a type which is proved equal toTo

To

a type which is proved equal toFrom

Attributes

See also

<:< for expressing subtyping constraints

Example

An in-place variant ofscala.collection.mutable.ArrayBuffer#transpose

implicit class BufOps[A](private val buf: ArrayBuffer[A]) extends AnyVal {  def inPlaceTranspose[E]()(implicit ev: A =:= ArrayBuffer[E]) = ???  // Because ArrayBuffer is invariant, we can't make do with just a A <:< ArrayBuffer[E]  // Getting buffers *out* from buf would work, but adding them back *in* wouldn't.}
Source
typeConstraints.scala
Graph
Supertypes
classFrom<:<To
traitFrom=>To
classObject
traitMatchable
classAny
Show all

Members list

Value members

Abstract methods

overridedefsubstituteBoth[F[_,_]](ftf:F[To,From]):F[From,To]

SubstituteTo forFrom andFrom forTo in the typeF[To, From], given thatF is a type constructor of two arguments.

SubstituteTo forFrom andFrom forTo in the typeF[To, From], given thatF is a type constructor of two arguments. Essentially swapsTo andFrom inftf's type.

Equivalent in power to each ofsubstituteCo andsubstituteContra.

This method is impossible to implement withoutthrowing or otherwise "cheating" unlessFrom = To, so it ensures that this really represents a type equality.

Attributes

Returns

ftf, $sameDiff

Definition Classes
Source
typeConstraints.scala

Concrete methods

defandThen[C](r:To=:=C):From=:=C

IfFrom = To andTo = C, thenFrom = C (equality is transitive)

IfFrom = To andTo = C, thenFrom = C (equality is transitive)

Attributes

Source
typeConstraints.scala
overridedefapply(f:From):To

Coerce aFrom into aTo.

Coerce aFrom into aTo. This is guaranteed to be the identity function.

This method is often called implicitly as an implicitA =:= B doubles as an implicit viewA => B.

Attributes

Definition Classes
Source
typeConstraints.scala
defcompose[C](r:C=:=From):C=:=To

IfFrom = To andC = From, thenC = To (equality is transitive)

IfFrom = To andC = From, thenC = To (equality is transitive)

Attributes

Source
typeConstraints.scala
defflip:To=:=From

IfFrom = To thenTo = From (equality is symmetric)

IfFrom = To thenTo = From (equality is symmetric)

Attributes

Source
typeConstraints.scala
overridedefliftCo[F[_]]:F[From]=:=F[To]

Lift this evidence over any type constructorF.

Lift this evidence over any type constructorF.

Attributes

Definition Classes
Source
typeConstraints.scala
overridedefliftContra[F[_]]:F[To]=:=F[From]

Lift this evidence over the type constructorF, but flipped.

Lift this evidence over the type constructorF, but flipped.

Attributes

Definition Classes
Source
typeConstraints.scala
overridedefsubstituteCo[F[_]](ff:F[From]):F[To]

Substitute theFrom in the typeF[From], whereF is any type constructor, forTo.

Substitute theFrom in the typeF[From], whereF is any type constructor, forTo.

Equivalent in power to each ofsubstituteBoth andsubstituteContra.

This method is impossible to implement withoutthrowing or otherwise "cheating" unlessFrom = To, so it ensures that this really represents a type equality.

Attributes

Returns

ff, $sameDiff

Definition Classes
Source
typeConstraints.scala
overridedefsubstituteContra[F[_]](ft:F[To]):F[From]

Substitute theTo in the typeF[To], whereF is any type constructor, forFrom.

Substitute theTo in the typeF[To], whereF is any type constructor, forFrom.

Equivalent in power to each ofsubstituteBoth andsubstituteCo.

This method is impossible to implement withoutthrowing or otherwise "cheating" unlessFrom = To, so it ensures that this really represents a type equality.

Attributes

Returns

ft, $sameDiff

Definition Classes
Source
typeConstraints.scala

Inherited methods

defandThen[C](r:To<:<C):From<:<C

IfFrom <: To andTo <: C, thenFrom <: C (subtyping is transitive)

IfFrom <: To andTo <: C, thenFrom <: C (subtyping is transitive)

Attributes

Inherited from:
<:<
Source
typeConstraints.scala
overridedefandThen[C](r:To=>C):From=>C

Composes two instances ofFunction1 in a newFunction1, with this function applied first.

Composes two instances ofFunction1 in a newFunction1, with this function applied first.

Type parameters

A

the result type of functiong

Value parameters

g

a function R => A

Attributes

Returns

a new functionf such thatf(x) == g(apply(x))

Definition Classes
Inherited from:
<:<
Source
typeConstraints.scala
defcompose[C](r:C<:<From):C<:<To

IfFrom <: To andC <: From, thenC <: To (subtyping is transitive)

IfFrom <: To andC <: From, thenC <: To (subtyping is transitive)

Attributes

Inherited from:
<:<
Source
typeConstraints.scala
overridedefcompose[C](r:C=>From):C=>To

Composes two instances ofFunction1 in a newFunction1, with this function applied last.

Composes two instances ofFunction1 in a newFunction1, with this function applied last.

Type parameters

A

the type to which functiong can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new functionf such thatf(x) == apply(g(x))

Definition Classes
Inherited from:
<:<
Source
typeConstraints.scala
overridedeftoString():String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Inherited from:
Function1
Source
Function1.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp