ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
738 stars 131 forks source link

Hoogle for Frege #145

Open mmhelloworld opened 8 years ago

mmhelloworld commented 8 years ago

Hi,

First of all, thank you for making Hoogle. It is a wonderful tool and I am now trying to make it useful for Frege. I already have a working version here using Hoogle 4. The way I did it for Frege is to create a text file of all the Frege types and then use hoogle convert to convert it to a database file (.hoo extension).

Is there an equivalent to convert a text file to a database file with Hoogle 5? I checked hoogle generate --help but it doesn't seem to be taking a text file. Am I doing it the right way or is there a better approach to make Hoogle useful for Frege? Sorry if this is not the right channel to ask this.

ndmitchell commented 8 years ago

Awesome! I can't actually try it right now, but will take a look tonight.

Do you have an example of a typical Frege version of a Hoogle file? How are you getting the initial files? Are they in a tarball already, or available somewhere?

For Hoogle 5 I simplified things and there are still text files, but I wrote a custom processor tailored to the Haskell ones. I have it on my todo list to generalise that to work with other types of text files (e.g. just raw text files), but if the Frege ones are in some standard place/format etc, it might be simpler just to have a dedicated Frege mode (then Frege users could easily install local Hoogle as well).

mmhelloworld commented 8 years ago

Thank you for your quick response!

Do you have an example of a typical Frege version of a Hoogle file? Are they in a tarball already, or available somewhere?

It is not in a standard place right now as I just created the text file and then scped to a cloud machine where Hoogle is running. I have uploaded the text file as a gist here: https://gist.github.com/mmhelloworld/8d061753ef57ab6ab984.

How are you getting the initial files?

Currently there is only one text file with all the types from the Frege standard library. I generated it by iterating through all the classes in a Java package and its sub packages which are Frege modules then write the types and doc in a text file for each module. I have also documented the steps here in case if you want to take a look: https://github.com/Frege/frege-repl#how-to-generate-hoogle-database-for-frege.

I have it on my todo list to generalise that to work with other types of text files (e.g. just raw text files), but if the Frege ones are in some standard place/format etc, it might be simpler just to have a dedicated Frege mode

A Frege mode would be definitely simpler for users. On the other hand, using a raw text file (either directly or converting to a binary) with Hoogle would also be useful and Hoogle itself may not have to deal with Frege then and it would be extensible for other languages too as we don't have to introduce another mode for another language later. At the moment, I can go either way and just want to make this excellent tool available for Frege :). Please let me know if you need anything.

ndmitchell commented 8 years ago

I am happy to support Frege natively in Hoogle - that seems entirely reasonable. The number of languages is pretty small (currently 1, hopefully soon 2 once Frege joins in) - so I don't think it's going to be a problem.

Given I'm already running a Hoogle server, and that at the loads we're expecting the hassle is in admining/running/checking the thing, I suggest I just host the Frege version of Hoogle, likely as http://hoogle.haskell.org/frege - unless you have any strong desire to do the hosting. I'm happy to take pull requests to change the code, so you are welcome to take more control of that side of things.

If that's what we want to go for:

mmhelloworld commented 8 years ago

I suggest I just host the Frege version of Hoogle, likely as http://hoogle.haskell.org/frege

yes, that would be perfect! The machine I am running on is only temporary anyway and we, in the Frege community, are already to trying move to permanent servers and this would be one less thing then. Thank you!

You need to host the Frege input file somewhere online

I have now hosted it in online Frege REPL at this URL: http://try.frege-lang.org/hoogle-frege.txt. If anything needs to be changed in that text file, please let me know.

ndmitchell commented 8 years ago

Thanks, that looks suitable, I'll see what I can do.

ndmitchell commented 8 years ago

With the git version of Hoogle you can do:

Which is what I've done, with the results at http://hoogle.haskell.org:8081/. It was easier to spawn two servers quickly than to integrate them properly, which is what I'll eventually do, and thus the URL will eventually move to http://hoogle.haskell.org/frege.

This is very deliberately the minimal viable thing, no proper branding.

One significant improvement would be if you have online documentation for your code, then I could link to it from the search results.

ndmitchell commented 8 years ago

OK, fo und your docs at http://www.frege-lang.org/doc/frege/Prelude.html#interact. Easiest way to sort that out is to generate @url in front of each declaration with the URL you want it to link to.

mmhelloworld commented 8 years ago

Awesome! That was very fast!

I was able to run Hoogle locally with --frege mode.

Regarding linking to docs, I am working on it right now and I'll publish a new database file. Would Hoogle pick it up next day?

Do you have any other suggestions for longer term that we need to think about? like instead of a textual database file, a tarball maybe?

ndmitchell commented 8 years ago

Hoogle updates the database at 8pm UTC, so update the file before then, and it should show up ~8:05pm.

The reason Haskell uses a tarball is to accommodate multiple packages. I suggest you move to a tarball for multiple package names, or otherwise stick with a text file - it doesn't make much difference in Hoogle itself.

Other than that, this is in a state where it can persist indefinitely - I think some branding is probably the most useful thing next.

mmhelloworld commented 8 years ago

Hi Neil,

I've uploaded a new Hoogle database file for Frege with @urls and some fixes. It took more time than I anticipated and I had to fix a lot of things that I ended up rewriting the database generation code. I tested it with my local hoogle and it looks good now with links to Frege doc site.

I'll also try with a tarball soon. Regarding branding, I am not really sure where to start. Do you think customizing the home page for Frege would be a good start or do you have something else in mind?

ndmitchell commented 8 years ago

I'm on mobile only for a week, but will check it out when i have a real machine. For branding, depends what you want.

On Sunday, January 24, 2016, Marimuthu Madasamy notifications@github.com wrote:

Hi Neil,

I've uploaded a new Hoogle database file for Frege with @urls and some fixes. It took more time than I anticipated and I had to fix a lot of things that I ended up rewriting the database generation code. I tested it with my local hoogle and it looks good now with links to Frege doc site.

I'll also try with a tarball soon. Regarding branding, I am not really sure where to start. Do you think customizing the home page for Frege would be a good start or do you have something else in mind?

— Reply to this email directly or view it on GitHub https://github.com/ndmitchell/hoogle/issues/145#issuecomment-174277324.

ndmitchell commented 8 years ago

The URL's look good. For branding, at the moment it looks just like the Haskell one. I imagine we want to be running the same server, and brand the Frege one by at least saying Frege somewhere on it - so people know to expect results from Frege. If you want to have "Frege style colors" or whatever that's an option too, but entirely up to you.

ndmitchell commented 7 years ago

@mmhelloworld - seems http://try.frege-lang.org/hoogle-frege.txt is down. Any idea where it went?

matil019 commented 6 years ago

Nice to meet you! I use Hoogle for Frege everyday, and it's very useful. Great thanks to you!

@mmhelloworld, how do you generate the text database of Frege? I'm trying to run Hoogle for my Frege project, and it's very helpful if you shared your tool.

mmhelloworld commented 6 years ago

@matil019 I wrote some code to generate hoogle database by reading from Frege documentation website. I was going to make the code a bit nicer and put it under one of our Frege repositories but never got to it. I will upload an initial version in the next few days.

mmhelloworld commented 6 years ago

@matil019 I have pushed an initial version of the code that generates Hoogle database for Frege here.

matil019 commented 6 years ago

@mmhelloworld Thank you for sharing. I tried it and it looks nice! Mind if I modify it to work with local (unpublished) classes?

mmhelloworld commented 6 years ago

@matil019 Absolutely, please make necessary changes. Thanks for asking.