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.
a type which is proved equal toTo
a type which is proved equal toFrom
<:< for expressing subtyping constraints
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.}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.
ftf, $sameDiff
IfFrom = To andTo = C, thenFrom = C (equality is transitive)
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.
IfFrom = To andC = From, thenC = To (equality is transitive)
IfFrom = To thenTo = From (equality is symmetric)
Lift this evidence over any type constructorF.
Lift this evidence over any type constructorF.
Lift this evidence over the type constructorF, but flipped.
Lift this evidence over the type constructorF, but flipped.
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.
ff, $sameDiff
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.
ft, $sameDiff
IfFrom <: To andTo <: C, thenFrom <: C (subtyping is transitive)
IfFrom <: To andTo <: C, thenFrom <: C (subtyping is transitive)
Composes two instances ofFunction1 in a newFunction1, with this function applied first.
Composes two instances ofFunction1 in a newFunction1, with this function applied first.
the result type of functiong
a function R => A
a new functionf such thatf(x) == g(apply(x))
IfFrom <: To andC <: From, thenC <: To (subtyping is transitive)
IfFrom <: To andC <: From, thenC <: To (subtyping is transitive)
Composes two instances ofFunction1 in a newFunction1, with this function applied last.
Composes two instances ofFunction1 in a newFunction1, with this function applied last.
the type to which functiong can be applied
a function A => T1
a new functionf such thatf(x) == apply(g(x))
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
a string representation of the object.