Scala Hoogle equivalent? - scala

Hoogle allows you to search many standard Haskell libraries by either function name, or by approximate type signature. I find it very useful. Is there anything like Hoogle for Scala? Search in ScalaDoc 2 only finds types and packages by name.

There are plans to make the Hoogle interface work with multiple languages: http://code.google.com/p/ndmitchell/issues/detail?id=45

It's a pity that it does not even have an index like javadoc. Hoogle is nicer, though.
I use a personal search engine from Google to search the Scaladocs.
A search provider (searching with site: http://www.scala-lang.org/docu/files/api) in Firefox is another way to search the docs.
Both do not work well for the Scala 2.8. release – it's not indexed well enough to be useful – and works not with all operators. For example a search for Cons :: returns only nonsense.

Scaladoc for Scala 3 has Hoogle-like searches feature. You can try it out here.
It uses Inkuire search engine.

Related

How to find appropriate functions for PureScript?

PureScript have lots of functions available like filter lenth and more. But how can we find the function that we need and its examples with implementation? I am facing problem solving exercises of the book purescript by examples. Any tips how show I go about solving those? Example in the book does not explain everythin.
Really, the most straightforward way would be to use the tooling that comes with the compiler through an editor plugin. You can use ?typehole to get the type of the type hole and get search results for relevant functions.
I also quite often type in a partial identifier and use the completion to look through the implementations, e.g. fil <complete to find various filter definitions.
For all newbie to PureScript who are following PureScript by example book this github link has all the solutions with updated libraries
https://github.com/kvsm/purescript-by-example

Canonical list of scala 'operators'

It seems easy to find general info on a specific 'operator' (method, syntactic sugar), but I can't seem to find anything that has a list of all, or even just most, of these goodies. As such, it makes it fairly difficult, or at least overly time consuming, to work through learning the language.
I have already looked over this question. While it has great information, and definitely shows you how to find any information you need, I was hoping for something like a 'pocket ref' that just had all the relevant info and was only dedicated to that.
So, my question is this:
Is there a such a list?
Am I getting ahead of myself by looking for such a reference early on in learning the language?
Thanks in advance.
Well, a list of all operators makes as much sense as a list of all methods in the library, regardless of the type. It isn't going to be particularly useful except for finding information about a specific operator.
However, if you do want one, at any ScalaDoc site (http://www.scala-lang.org/api/current/ for the standard library) there is an alphabetic index just under the search bar. The first link (#) lists all the non-alphabetic methods (i.e. "operators").
Many of these are rarely used, or only in specific circumstances.
Obviously, any other library can introduce its own operators, and you'll need to check its own documentation.

Scala naming convention for options

When I return something of type Option, it seems useful to explain in the name of the function name that it is an option, not the thing itself. For example, seqs have reduceOption. Is there a standard naming convention? Things I have seen:
maybeFunctionName
functionNameOption
- neither seems to be all that great.
reduceOption and friends (headOption, etc.) are only named that way to distinguish them from their unsafe alternatives (which arguably shouldn't exist in the first place—i.e, there should just be a head that returns an Option[A]).
whateverOption isn't the usual practice in the standard library (or most other Scala libraries that I'm aware of), and in general you shouldn't need or want to use this kind of Hungarian notation in Scala.
Why would you want to make your function names longer? It doesn't contribute anything, as the fact that it returns an Option is obvious when looking at the function's type.
reduceOption is sort of a special case, since in most cases you really want to use reduce, except that it doesn't work on empty sequences.

Could APL be implemented in Scala as a DSL?

There is a old computer language called APL. Could this be implemented in Scala as a DSL?
http://en.wikipedia.org/wiki/APL_%28programming_language%29
Someone could probably give a better answer than this, but this is my initial thought:
A Scala DSL should in theory be able to implement any programming language because it could build up an arbitrary structure representing the syntax, and then evaluate that.
A Scala DSL could not exactly replicate APL syntax for many reasons, one of which is that
'single quotes'
can denote a string in APL, but not in Scala. Also (from the wikipedia page)
×/2 3 4
wouldn't be valid Scala.
I don't know how close you could get, though...
A Javascript implementation exists here: https://github.com/ngn/apl

Is there a way in scala to convert from any Map to java.util.Map?

I use a lot of scala maps, occasionally I want to pass them in as a map to a legacy java api which wants a java.util.Map (and I don't care if it throws away any changes).
An excellent library I have found that does a better job of this:
http://github.com/jorgeortiz85/scala-javautils
(bad name, awesome library). You explicitly invoke .asJava or .asScala depending on what direction you want to go. No surprises.
Scala provides wrappers for Java collections so that they can be used as Scala collections but not the other way around. That being said it probably wouldn't be hard to write your own wrapper and I'm sure it would be useful for the community. This question comes up on a regular basis.
This question and answer discuss this exact problem and the possible solutions. It advises against transparent conversions as they can have very strange side-effects. It advocates using scala-javautils instead. I've been using them in a large project for a few months now and have found them to be very reliable and easy to use.