hackage search is not so good

Haskell has a package database called Hackage. It has a search feature, but it is hard to find things with the search feature. What is bad about it? What are work arounds?

Problems

It doesn’t work good

If the search does not work good then that’s a problem. What do I mean?

Look, I want to find bindings for libgit.

I type libgit in search:

libgit search results in hackage

Hmm. This does not seem right. One result, very little usage- seems implausible.

I type libgit2 on a whim:

libgit2 search results in hackage

Hmm, better. Four results (one off screen), and hlibgit2 is the one I want. But why does it not show up when I type libgit? For comparison, we reference crates.io libgit search. Bad thing about crates.io search: libgit bindings are not near the top. So much for “sort by relevance”. Good thing: libgit2-sys is on first page of results at all. And at the top if sortby recent downloads!

crates.io libgit search results

Let’s try harder. I want to hash data. I search “sha256”:

sha256 search results in hackage show cryptohash-sha256

Some results… cryptohash is deprecated in favor of cryptonite though, and cryptonite and saltine are nowhere on the results!

Ok, I search “crypto”. Still, they do not appear.

crypto search results in hackage

I search “cryptography”. Finally.

cryptography search results in hackage

You see, it is hard to find things with the search. There was an old search and it worked much better than this. Problem was solved! Not anymore.

Javascript

The second problem: it requires javascript. “Yes but so does crates.io”- true, and that is not great either. Why? Personal workflow, I’ll show you.

I like to use links browser in terminal to search packages and package documentation. We have shell aliases that do this. Main one is ddg command:

vi@localhost ~> cat (which ddg)
#!/bin/sh
if [ $# -eq 0 ]; then
    links "duckduckgo.com/lite"
else
    query="$@"
    links "duckduckgo.com/lite?q=$query"
fi

In rust, we have alternative index lib.rs which works without JS.

ddg !librs serde
                              [1]Lib.rs
   › Search [2]#serialization [3]#json [4]#no-std [5]#deserialization [6]#parser
   [7]serde________________ [8]Search
     * Sorted by relevance
     * [9]I'm feeling ducky
    1. [10]serde

       A generic serialization/deserialization framework

       v1.0.180 9.4M #serde #serialization #no-std
    2. [11]serde_yaml

       YAML data format for Serde

       v0.9.25 1.9M #yaml #serde #serialization
    3. [12]serde_with

       Custom de/serialization functions for Rust's serde

Solutions

hoogle

hoogle is not just search for functions, it can search packages too. It also works without javascript! Let’s try the searches again here.

First, libgit:

libgit search results in hoogle

Good.

Second, sha256:

sha256 search results in hoogle

Not as good, but cryptonite is there at least. Difficult to parse though.

We can limit to just search packages with is:package but that is just a string contains on the package name. Because it is string contains, is:package crypto works for cryptonite but not saltine,

crypto search results in hoogle

But is:package cryptography does not help at all.

cryptography search results in hoogle are empty

So hoogle can help when hackage fails, and it works in links, but it does not solve everything. And it can only search packages in stackage.

stackage

Let us try stackage search, maybe it can help?

stackage libgit search results look like hoogle results

stackage sha256 search results look like hoogle results

Hmm, I think this is the same search algorithm as hoogle. Oh well, at least it works without javascript.

Google

In desperation, we try Google:

google search result pulls up Crypto, some experimental git repo, and FP Complete post recommending cryptonite after clickthough

Well at least we can get going in the right direction. Crypto is not in stackage but maybe it is good. And there is the FP Complete post at the bottom there to recommend cryptonite to us.