A Scala 3 syntax question here. I feel like there's not enough documentation around this yet.
How do you fetch an implicit value in a for comprehension, when its type is parameterized?
for
o <- Option("line just to make for comprehension start")
given Int = 2
a = implicitly[Int] // error: no implicit argument of type Int was found for parameter e of method implicitly in object Predef
given List[Int] = List(1, 2, 3)
b = implicitly[List[Int]] // error: no implicit argument of type List[Int] was found for parameter e of method implicitly in object Predef
yield ()
Edit:
But if I insert a dummy line in between the declaration and the usage, it works:
for
o <- Option("line just to make for comprehension start")
given List[Int] = List(1, 2, 3)
p <- Option("dummy")
b = implicitly[List[Int]] // works
yield ()