Here's a Scala 3 feature suggestion: I'd like to write for-comprehensions which know their generator type, like so: for[List] { x <- xs y <- ys } yield ... It would make it much easier to work out whether `xs` or `ys` is the wrong type.
You mean `for[F] yield x` would give `F.unit(x)`? I admire your ambition! And this syntax even looks nice!
-
-
Exactly. You could even do `for[F] { if x > 10 } yield 3`, which actually cleans up something that is currently kind of messy.
-
The compiler would need to know how to construct the value without an existing value to work from, so it would need to infer the companion object from the TC, and call `unit` on it, which would need to be added to all the monad types.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.