Sunday, March 13, 2011

Hoogle for your language (i.e. F#, Scala, ML, Clean...)

Summary: If you offer to help, I'll make Hoogle search your statically typed functional language.

Hoogle is a search engine for Haskell functions, that allows you to search by either name, or by type. But very little of Hoogle is actually Haskell specific - most is applicable to any language with a Hindley-Milner based type system.

Recently I have been asked by several people what they can do to allow Hoogle to search their preferred language. There are four steps to integrating a language with Hoogle, detailed below. If you are interested in helping please email me - I already have volunteers for both F# and Scala, but additional volunteers for other languages are welcome.

To allow searching a language from Hoogle, there are four steps:

1) A volunteer needs to generate some Hoogle input files containing details of the modules/functions/packages etc. to be searched. These files should be plain text, but can be in a language specific format - i.e. ML syntax for type signatures. For a rough idea of how these files could look see this example - for Haskell I get these files from Hackage. The code to generate these input files can be written in any language, and can live outside Hoogle.

2) Someone needs to write a parser that converts these language specific inputs into internal Hoogle representations. The equivalent code for Haskell is in the Hoogle repo. If a volunteer writes this code, I'll happily use it. If I have to write this code then that's OK, although I might take a bit longer. This code needs to be written in Haskell and live inside Hoogle.

At this stage, Hoogle will be able to search the new language. The remaining stages will just make the experience more pleasant.

3) Someone needs to write a query parser for the language, inside Hoogle. I may do this, as I'm intending to rewrite the Haskell query parser anyway, and I could probably find some savings by doing them together. This code needs to be written in Haskell and live inside Hoogle.

4) A volunteer would be useful to keep the function definitions up to date, generate new definitions, and ensure they get uploaded.

Email me if you want to volunteer!


gambistics said...

In which way would hoogle be able to cope with subtyping? Without some support it will probably be difficult to support a language like Scala.

Neil Mitchell said...

Subtyping can be expressed in terms of type classes, so I don't think there's a problem. In the next version of Hoogle I intend to express type classes as subtyping anyway :-)

Daniel said...

You mention that any language based on Hindley-Milner can benefit from it. Since Scala is _not_ based on Hindley-Milner, what kind of impact could that have?

Neil Mitchell said...

Daniel: I think any language could benefit from it - even ones like C#/C++. But it will work best on languages with strong types, including generics, whose signatures are mildy similar to Haskell. The type inference algorithm doesn't matter at all - it's all about what the result types look like (so when I said Hindley-Milner I was more meaning Haskell-like, than actually any algorithm)