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:
Hmm. This does not seem right. One result, very little usage- seems implausible.
I type libgit2
on a whim:
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!
Let’s try harder. I want to hash data. I search “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.
I search “cryptography”. Finally.
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:
Good.
Second, sha256:
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,
But is:package cryptography
does not help at all.
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?
Hmm, I think this is the same search algorithm as hoogle. Oh well, at least it works without javascript.
In desperation, we try Google:
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.