This page is no longer maintained — Please continue to the home page at

Searching docs for method by signature

No replies
Stefan Wagner
Joined: 2011-04-08,
User offline. Last seen 42 years 45 weeks ago.

Hi List,

Shortly ago, just a few days, there was a discussion on the list (or was
it (~debate/~language)?), how useful it would be to have a search by
method-signature, like haskell has.

No, sorry, I don't have something like this, but a poor mans
replacement. Maybe it is useful to one or two of you.

I was looking for a method sublist (from: Int, to: Int) in List, and was
lost in the list of hundrets of methods for List. So I produced this
little script, which I append as attachment, for the integrety of

It's 25 lines of comment, and then 1 line of little work.
* (gnu-?) find
* grep
* sed
I guess it will run with ohter shells than bash, except cmd.exe and
powershell, but if you install the gnu-tools, even there it should work.

And, by the way, it worked for me, and found the method 'slice', which
is what I meant.

# find scala Method in Class $1 by signature (param list and return type)
# (c) GPLv3 Stefan Wager 2011
# usage:
# find a sublist-Method in class List, which takes two Indexes
of type Int, and returns a
# List. Unfortunately, the name of Int might be 'n' or something
else, the return might be
# List[A] or List[T] or something, so you have to decide how strict
the regex is
# example:
# List "(.*: Int, .*: Int): List"
# result:
# patch (from: Int, that: Seq[A], replaced: Int): List[A]
# slice (start: Int, end: Int): List[A]
# You can form stricter REGEX to get a better result, but it will
cost some time,
# since masking correctly can get complicated, for example the return
Type of List[A],
# with unknown name of A is not just List[.], but List\[.\].
# To restrict the parameters to two, "([^:]*: Int, [^:]*: Int): List"
would have worked.
# For small result sets it will often be faster to pick the better match
per eye than
# regex.
find $SCALA_HOME/doc/api/scala -name "$1".html -exec egrep "name" {} ";"
| sed 's|<[^>]\+>||g;s/(/ (/g' | grep "$2"

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