You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very sorry, I couldn't minimize it further
The important part are definitions of Sum and Sum1. Sum contains a nearly meaningless match just to get things working, technically it should be equivalent to Sum1, also manual unfold of Plus1 definition works as well.
importscala.compiletime.{constValueTuple, constValue}
objectSumsextendsApp:
println(constValueTuple[Plus[(true, true, true), (true, true)]]) // works
println(constValueTuple[Plus1[(true, true, true), (true, true)]]) // fails
println(constValueTuple[
Reverse[PlusLoop[Reverse[(true, true, true)], Reverse[(true, true)], false]]]
) // also works despite it's just an unfold of `Plus1` applicationtypePlus[A<:Tuple, B<:Tuple] <:Tuple= (A, B) matchcase (EmptyTuple, EmptyTuple) =>EmptyTuplecase (a, b) =>Reverse[PlusLoop[Reverse[A], Reverse[B], false]]
typePlus1[A<:Tuple, B<:Tuple] =Reverse[PlusLoop[Reverse[A], Reverse[B], false]]
typeReverseLoop[A, XS<:Tuple] <:Tuple=Amatch {
caseEmptyTuple=>XScase x *: xs =>ReverseLoop[xs, x *:XS]
}
typeReverse[A] =ReverseLoop[A, EmptyTuple]
typePlusTri[A, B, C] = (A, B, C) matchcase (false, false, false) => (false, false)
case (true, false, false) | (false, true, false) | (false, false, true) => (false, true)
case (true, true, false) | (true, false, true) | (false, true, true) => (true, false)
case (true, true, true) => (true, true)
typeInc[A<:Tuple] <:Tuple=AmatchcaseEmptyTuple=>true*:EmptyTuplecase t *: as =>
t matchcasefalse=>true*: as
casetrue=>false*:Inc[as]
typeIncT[A<:Tuple, O<:Boolean] <:Tuple=Omatchcasefalse=>Acasetrue=>Inc[A]
typePlusLoop[A<:Tuple, B<:Tuple, O] <:Tuple= (A, B) matchcase (EmptyTuple, EmptyTuple) =>Omatchcasetrue=> (true*:EmptyTuple)
casefalse=>EmptyTuplecase (EmptyTuple, B) =>IncT[B, O]
case (A, EmptyTuple) =>IncT[A, O]
case (a *: as, b *: bs) =>PlusTri[a, b, O] matchcase (x, y) => y *:PlusLoop[as, bs, x]
Compiler version
"3.1.0-RC1"
Minimized code
I'm very sorry, I couldn't minimize it further
The important part are definitions of
Sum
andSum1
.Sum
contains a nearly meaningless match just to get things working, technically it should be equivalent toSum1
, also manual unfold ofPlus1
definition works as well.Output
second
println
fails withExpectation
Plus1
application should work the same way asPlus
The text was updated successfully, but these errors were encountered: