Match type not simplified in return position
See original GitHub issueCompiler version
3.1.1, 3.1.2-RC1
Minimized code
import scala.compiletime.ops.int.*
type Fill[N <: Int, A] <: Tuple = N match {
case 0 => EmptyTuple
case S[n] => A *: Fill[n, A]
}
sealed trait SeqToTuple[N <: Int] {
def apply[A](s: Seq[A]): Fill[N, A]
}
implicit val emptyToZero: SeqToTuple[0] = new SeqToTuple[0] {
override def apply[A](s: Seq[A]): EmptyTuple = EmptyTuple
}
implicit def successorToSuccessor[N <: Int](implicit pred: SeqToTuple[N]): SeqToTuple[S[N]] = new SeqToTuple[S[N]] {
override def apply[A](s: Seq[A]): Fill[S[N], A] =
s.head *: pred(s.tail) // Scala doesn't know that `A *: Fill[N, A]` = `Fill[S[N], A]` for some reason
}
Output
Found: A *: Fill[N, A]
Required: Fill[compiletime.ops.int.S[N], A]
where: N is a type in method successorToSuccessor with bounds <: Int
Expectation
Scala recognizes that Fill[S[N], A]
= A *: Fill[N, A]
(as it is a case of the match type) and lets the program compile.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
INDEX & MATCH Functions Combo in Excel (10 Easy ...
INDEX MATCH is a powerful combination that allows you to do simple and advanced lookups in Excel. In this article, I'll show you...
Read more >MATCH function - Microsoft Support
The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in...
Read more >How to use INDEX and MATCH - Exceljet
INDEX and MATCH is the most popular tool in Excel for performing more advanced ... Let's say we want to write a formula...
Read more >INDEX & MATCH for Flexible Lookups
It helps the INDEX function to locate the answer. The MATCH function was designed to return the position or address of the lookup...
Read more >What is INDEX MATCH & Why Should You Use It? - GoSkills
We used the match type 0 to ensure that only an exact match will be returned. INDEX MATCH example 5 The MATCH function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think really the issue is that
0
andS[n]
are not treated like independent class types, for example, if we substituteInt
for someNat
enum then the example works unchanged:Awesome! Thanks for the insights.