{"id":15010900,"url":"https://github.com/haskell/critbit","last_synced_at":"2025-12-11T23:12:46.059Z","repository":{"id":8268290,"uuid":"9720924","full_name":"haskell/critbit","owner":"haskell","description":"A Haskell implementation of crit-bit trees.","archived":false,"fork":false,"pushed_at":"2022-04-17T16:43:51.000Z","size":1450,"stargazers_count":140,"open_issues_count":6,"forks_count":41,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-10-11T00:03:25.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haskell.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-27T20:51:58.000Z","updated_at":"2025-07-28T02:00:12.000Z","dependencies_parsed_at":"2022-08-07T00:15:31.491Z","dependency_job_id":null,"html_url":"https://github.com/haskell/critbit","commit_stats":null,"previous_names":["bos/critbit"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/haskell/critbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell%2Fcritbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell%2Fcritbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell%2Fcritbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell%2Fcritbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haskell","download_url":"https://codeload.github.com/haskell/critbit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell%2Fcritbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279274961,"owners_count":26138531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-17T02:00:07.504Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T19:37:05.057Z","updated_at":"2025-10-19T22:31:23.209Z","avatar_url":"https://github.com/haskell.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Crit-bit trees for Haskell\n====\n\nThis is the first purely functional implementation of [crit-bit\ntrees](http://cr.yp.to/critbit.html) that I'm aware of.\n\nA crit-bit tree is a key/value container that allows efficient lookups\nand ordered traversal for data that can be represented as a string of\nbits.\n\nThis package exists in part with education in mind:\n\n* The core data structures are simple.\n\n* The core algorithms are easy to grasp.\n\n* I have intentionally structured the source to be easy to follow and\n  extend.\n\n* Originally, I *deliberately* left the package incomplete.  (It has\n  since been substantially fleshed out.)  Ever thought to yourself,\n  \"I'd write a bit of Haskell if only I had a project to work on\"?\n  Well, here's your chance!  I will set aside time to review your code\n  and answer what questions I can.\n\nEducation aside, crit-bit trees offer some interesting features\ncompared to other key/value container types in Haskell.\n\n* For some operations, they are much faster than `Data.Map` from the\n  `containers` package, while for others, they are slower.\n\n* Compared to `Data.HashMap`, you get about the same lookup\n  performance, but also some features that a hash-based structure\n  can't provide: prefix-based search, efficient neighbour lookup,\n  ordered storage.\n\nOf course crit-bit trees have some downsides, too. For example,\nbuilding a tree from randomly ordered inputs is somewhat slow, and of\ncourse the set of usable key types is small (only types that can be\ninterpreted as bitstrings \"for free\").\n\nCompared to the most easily findable crit-bit tree code you'll come\nacross that's [written in C](https://github.com/glk/critbit), the core\nof this library has a lot less accidental complexity, and so may be\neasier to understand. It also handles arbitrary binary data that will\ncause the C library to go wrong.\n\n\n\nHow to contribute\n====\n\nI've purposely published this package in an incomplete state, and I'd\nlike your help to round it out.  In return, you get to learn a little\nHaskell, have your code reviewed by someone who wants to see you\nsucceed, and contribute to a rather nifty library.\n\nDo you need any prior experience with Haskell to get started? No! All\nyou need is curiosity and the ability to learn from context. Oh, and a\ngithub account.\n\nMy aim with this library is drop-in API compatibility with the widely\nused Haskell [`containers`](https://github.com/haskell/containers)\nlibrary, which has two happy consequences:\n\n* There are lots of functions to write!\n\n* In almost every case, you'll find a pre-existing function in\n  `containers` that (from a user's perspective) does exactly what its\n  counterparts in *this* library ought to do.\n\n\nGetting started\n----\n\nIf you want to contribute or play around, please use the most modern\nversion of the [Haskell Platform](http://www.haskell.org/platform/).\n\nOnce you have the Platform installed, there are just a few more steps.\n\nSet up your local database of known open source Haskell packages.\n\n    cabal update\n\nBoth the new `cabal` command and `cabal-dev` will install to\n`$HOME/.cabal/bin`, so put that directory at the front of your shell's\nsearch path before you continue.\n\nGet the `critbit` source.\n\n    git clone git://github.com/bos/critbit\n\nSet up a sandbox.\n\nThe first time through, you may need to download and install a ton of\ndependencies, so hang in there.\n\n    cd critbit\n    cabal sandbox init\n    cabal install \\\n\t--enable-tests \\\n\t--enable-benchmarks \\\n    \t--only-dependencies \\\n\t-j\n\nThe `-j` flag above tells `cabal` to use all of your CPUs, so even the\ninitial build shouldn't take more than a few minutes.\n\nTo actually build:\n\n    cabal build\n\n\nRunning the test suite\n----\n\nOnce you've built the code, you can run the entire test suite fairly\nquickly.  This takes about 30 seconds on my oldish 8-core Mac laptop:\n\n    dist/build/tests/tests +RTS -N\n\n(The `+RTS -N` above tells GHC's runtime system to use all available\ncores.)\n\nIf you're feeling impatient, run a subset of the test suite:\n\n    dist/build/tests/tests -t properties/map/bytestring +RTS -N\n\nAnd if you want to explore, the `tests` program accepts a `--help`\noption. Try it out.\n\n\nRunning benchmarks\n----\n\nIt is just as easy to benchmark stuff as to test it.\n\nFirst, you need a dictionary. If your system doesn't have a file named\n`/usr/share/dict/words`, you can [download a dictionary\nhere](http://www.cs.duke.edu/~ola/ap/linuxwords).\n\nIf you've downloaded a dictionary, tell the benchmark\nsuite where to find it by setting the `WORDS` environment variable.\n\n    export WORDS=/my/path/to/linuxwords\n\nYou can then run benchmarks and generate a report. For instance, this\nruns every benchmark that begins with `bytestring/lookup`.\n\n    dist/build/benchmarks/benchmarks -o lookup.html \\\n        bytestring/lookup\n\nOpen the `lookup.html` file in your browser. [Here's an\nexample](http://htmlpreview.github.io/?https://github.com/bos/critbit/blob/master/doc/criterion-sample-lookup.html)\nof what to expect.\n\nAs with `tests`, run the `benchmarks` program with `--help` if you\nwant to do some exploring.\n\n\n\nWhat your code should look like\n----\n\nOkay, so you've bought into this idea, and would like to try writing a\npatch. How to begin?\n\nI've generally tried to write commits with a view to being readable,\nso there are examples you can follow.\n\nFor instance, [here's the commit where I added the `keys`\nfunction](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3). This\ncommit follows a simple pattern:\n\n* [Uncomment the export](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3#L0L91) of the function.\n\n* [Write the function\n  definition](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3#L0R503).\n  In this case, the documentation is taken almost verbatim from the\n  corresponding function in [the `Data.Map`\n  module](https://github.com/haskell/containers/blob/342a95002822cca56f2d5b086cdd5a98592d5c10/Data/Map/Base.hs#L1889).\n\n* [Write a\n  test](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3#L2R108)\n  and [make sure it gets\n  run](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3#L2R124).\n\n* [Add an entry to the benchmark\n  suite](https://github.com/bos/critbit/commit/48438b48ca9bc5d96c1987afe7acdf4dada823f3#L1R179)\n  so it's easy to see how this compares to other key/value map types.\n\nNaturally, you'll follow the prevailing coding and formatting style.\nIf you forget, I'll be sad and offer you only a terse \"fix your\nformatting\" review, and then you'll be sad too.\n\n\nWhat your commits should look like\n----\n\nPlease follow the guidelines below, as they make it easier to review\nyour pull request and deal with your commits afterwards.\n\n* One logical idea per commit! If you want to add five functions,\n  that's fine, but please spread them across five commits.\n\n* Do not reorganize or refactor unrelated code in a commit whose\n  purpose is to add new code.\n\n* When you add a new function, add its tests and benchmarks in the\n  same commit.\n\n* \u003cb\u003eDo not add trailing whitespace\u003c/b\u003e. Follow the same formatting\n  and naming conventions as you already see in the code around you.\n\n* Keep your maximum line length at 80 columns for everything except\n  lines of example code in documentation.\n\n(If you can't follow the guidelines, there's a good chance I'll ask\nyou to fix your commits and resubmit them.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell%2Fcritbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaskell%2Fcritbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell%2Fcritbit/lists"}