[Haskell-cafe] ANN: hranker: Basic utility for ranking a list of items (e.g. for the logo poll)

Robin Green greenrd at greenrd.org
Sun Mar 22 21:06:57 EDT 2009

hranker is a fun little command-line utility I have written to help a
user rank a list of items (of any type implementing Show, Eq and Ord).
I hope the code is sufficiently clear that it could also serve as an
educational piece of code, especially for people wanting to learn how
to use the HCL library.

It is now available on hackage:


Just typing hranker or hranker --help will yield a usage message.

Here is an example usage of the program: In the unlikely event that
anyone else wants to use it to help them prepare their votes in the
Haskell logo poll (which is what I used it for just now), here is what
to do:

1. cabal install hranker (or download it and runhaskell Setup.lhs etc.)

2. hranker 113 (because 113 is the number of items in the poll)

3. IMPORTANT: Read the warnings the program prints on startup!

4. To control the program, enter the first character of the command you
wish to perform, and then press Enter. The command you have chosen may
ask you for further information. Commands generally operate on the next
unranked item, apart from annotate (which can operate on ranked or
unranked items), remove (which always operates on ranked items), and
quit. I recommend you use the annotate command a lot - it is really
helpful for this kind of situation where you have a lot of numbered
items to rank. If you use the remove command, don't remove *all* ranked
items, because if you do you it may terminate.

5. If you rank *everything* somehow (remember, ties are allowed), the
program will print an inverse mapping (items to ranks, instead of ranks
to items) before terminating. If you choose to quit before that point,
you won't get that inverse mapping, unless you explicitly invoke the
mapping command.

There is obvious room for improvement: apart from fixing the remove bug
mentioned above, there is currently no simple way to remove or annotate
just *one* item at a rank when multiple items are tied at that rank.

Have fun! There are some hilarious entries in the logo poll, if you
haven't yet voted.


More information about the Haskell-Cafe mailing list