-
Notifications
You must be signed in to change notification settings - Fork 87
Rewrite breakout #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Well, the output is not semantically equivalent to the input since it creates an intermediate List. |
I think the rule should work as follows.
For instance, if one writes: List(1, 2, 3).map(_ + 1)(collection.breakOut): Set[Int] Which instantiates List(1, 2, 3).map(_ + 1)(collection.breakOut[List[Int], Int, Set[Int]]): Set[Int] We should produce: List(1, 2, 3).iterator.map(_ + 1).to(implicitly[Factory[Int, Set[Int]]]) |
would this works too? List(1, 2, 3).iterator.map(_ + 1).to(implicitly) |
You should just try:
It seems to be working, yes! |
@julienrf I know, I mean does this work in the general case for migrations. The implicit Factory could be a bit different than the CanBuildFrom. |
It seems to be enough: the type of the required implicit |
val xs = List("London", "France")
def f(x: String): (Int, String) = (x.length, x)
val map = xs.iterator.map(f).to(implicitly)
val map2: Map[Int, String] = xs.iterator.map(f).to(implicitly)
10:35: type mismatch;
[error] found : Nothing <:< Nothing
[error] required: scala.collection.Factory[(Int, String),?]
[error] val map = xs.iterator.map(f).to(implicitly)
[error] ^ |
The line: val map = xs.iterator.map(f).to(implicitly) Is not representative of the way Therefore I suggest ignoring that case for now. |
ok, we ignore the following: import scala.collection.breakOut
val xs = List("London", "France")
def f(x: String): (Int, String) = (x.length, x)
val map = xs.map(f)(breakOut)
// map: scala.collection.immutable.IndexedSeq[(Int, String)] = Vector((6,London), (6,France)) |
no solution
view
iterator
reverse-iterator
|
for operators that take collections such as -lhs.zip(rhs)(breakOut): Array[(Int, Int)]
+lhs.iterator.zip(rhs.iterator).to(implicitly): Array[(Int, Int)] |
No. |
ha, cool |
seen in:
https://github.com/kxbmap/configs/pull/30/files#diff-8416f81bdac5bf53701680a5968a0f9eL226
input:
output:
The text was updated successfully, but these errors were encountered: