twitter / scalding

A Scala API for Cascading
http://twitter.com/scalding
Apache License 2.0
3.5k stars 706 forks source link

change to using `A => Iterable[B]` in flatMap #1775

Open johnynek opened 6 years ago

johnynek commented 6 years ago

In scala 2.13 TraverseableOnce is going away. We always allowed A => TraversableOnce[B] on the idea we could work with Iterators.

We never noticed that those two types are almost equivalent. Since the main subclasses of TraversableOnce[A] are either Iterator[A] or Iterable[A] we could have:

implicit def toIterableFn[A, B](fn: A => Iterator[B]): A => Iterable[B] = { (a: A) =>
  new Iterable[B] {
    def iterator = fn(a)
  }
}

I think @non has a fully lazy Iterable somewhere that we could use there (it is always just a transformer on a () => Iterator[A]).