This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Regarding @usecase, Tuple, and zipped

No replies
David Copeland
Joined: 2009-06-16,
User offline. Last seen 42 years 45 weeks ago.
I found some time to work on improving the scaladocs for the core library and in my quest to fix a grammatical issue in Product* series of classes, came across genprod, and am now improving the scaladoc for all of the classes it generates (being Product, Tuple, and Function).
There's a method in Tuple2 and Tuple3 called zipped, which is best explained by example:
scala> val tuple = (List(1,2,3),List('a','b','c'),List("x","y","z")) tuple: (List[Int], List[Char], List[java.lang.String]) = (List(1, 2, 3),List(a, b, c),List(x, y, z))
scala> tuple.zipped map { (x,y,z) => x + ":" + y + ":" + z}res8: List[java.lang.String] = List(1:a:x, 2:b:y, 3:c:z)
However:
scala> val tuple = (1,2,3) tuple: (Int, Int, Int) = (1,2,3)
scala> tuple.zipped <console>:7: error: could not find implicit value for parameter w1: (Int) => scala.collection.TraversableLike[El1,Repr1]        tuple.zipped             ^So, I'm trying to think of an easy to way to explain that this might happen.  My current text is:
Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]].

I'm not sure how helpful this is.  I tried using @usecase to make a simpler signature, but was unable to do so.  I tried something like
@usecase def zipped[A <: Traversable, B <: Traversable]:Zipped[A,B]
with the thinking that, most use of this method would be if you have a tuple of Traversables, you can zip them.
scaladoc gives me:
 [scaladoc] /Users/davec/Projects/scala/src/library/scala/Tuple2.scala:53: warning: wrong number of type arguments for Tuple2.this.Zipped, should be 4  [scaladoc]    * @usecase def zipped[A <: Traversable,B <: Traversable]:Zipped[A, B] [scaladoc]               ^
I'm possibly missing the point of @usecase, but is there a better way to document the requirement imposed by the implicit parameter?
Dave
---
My Blog: http://www.naildrivin5.com/blog
Scala Tour for Java Developers: http://www.naildrivin5.com/scalatour
Fork me on Github: http://davetron5000.github.com

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland