I am trying to understand some notation in the Scala docs. Particularly the signature for the List.flatten method. It takes an implicit argument that I assume is supposed to function like a typeclass CanIterate[A, B]. Then, internally, flatten iterates through all the items in each element and adds them to the new, flattened list (or if the list wasn’t nested to begin with, the implicit argument won’t be available, and you’ll get a compiler error). The full signature is:
override def flatten[B](implicit toIterableOnce: A -> IterableOnce[B]): List[B]
The part that confuses me is -> rather than =>. If there were an implicit function from A to IterableOnce[B], I would be happy. But my understanding is that -> is syntactic sugar for making a pair, so we’re getting an implicit tuple with type (A, IterableOnce[B]). I don’t see how that could help with the conversion. I see the same syntax for lots of other implicit parameters.
Am I not understanding the syntax? Can such a pair somehow be used for the conversion? Is there an error in the docs, and it really should be =>?
Any help is appreciated!