No, it's not at all the easiest way to go at it. I don't see what I can use from there, even conceptually. This is the barebones code I wrote for this - https://play.nim-lang.org/#ix=4h2L It has some shortcomings: The algorithm to generate it is probably not optimal, checking if each new entry already exists by iterating over the existing data. Hashtable might make more sense in some scenarios.
The data structure does not support recursion (to be able to encode seq of seq..). Perhaps this can be done with object variant, although it's not immediately obvious to me how.
It uses uint32 for index size, instead of bits of appropiate size packed in a bit vector. Alternatively, for data with values repeating a lot one after another, a start/end range based encoding might be more optimal