On Type Level, i stumble upon the following:
sealed abstract class StSource[A] {
type S
def init: S // create the initial state
def emit(s: S): (
StSource[A] {type S = S0}
is a refined type. {type S = S0}
is a type refinement.
From one side, StSource[A] {type S = S0}
is a subtype of StSource[A]
.
From the other side, StSource[A]
is also an existential type with respect to StSource[A] {type S = S0}
, namely StSource[A]
is StSource.Aux[A, _]
(aka StSource.Aux[A, X] forSome {type X}
).
def test[A, S] = {
implicitly[StSource.Aux[A, S] <:< StSource[A]]
implicitly[StSource.Aux[A, _] =:= StSource[A]]
implicitly[StSource[A] =:= StSource.Aux[A, _]]
}
https://scala-lang.org/files/archive/spec/2.13/03-types.html#compound-types
A compound type