Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/reasonableconsulting/compare

ReasonML helpers for generating cmp functions.
https://github.com/reasonableconsulting/compare

comparator compare ocaml reason reasonml sort sorting

Last synced: 29 days ago
JSON representation

ReasonML helpers for generating cmp functions.

Awesome Lists containing this project

README

        

# compare

ReasonML helpers for generating cmp functions.

## Usage

```reason
module Comparator =
Belt.Id.MakeComparable({
type t = string;

let cmp =
Compare.concat([
Compare.by(key => key),
Compare.by(key => String.length(key)),
]);
});

type t = Belt.Map.t(Comparator.t, int, Comparator.identity);

let ourMap = Belt.Map.fromArray(~id=(module Comparator), [|
("a", 1), ("b", 2), ("ab", 3)
|]);

Belt.Map.forEach(ourMap, Js.log2);
```

## License

MPL-2.0