Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Simpler Belt Examples (like Belt.Set) #241

Open
peterpme opened this issue Sep 2, 2020 · 0 comments
Open

Simpler Belt Examples (like Belt.Set) #241

peterpme opened this issue Sep 2, 2020 · 0 comments

Comments

@peterpme
Copy link

peterpme commented Sep 2, 2020

I was trying to understand how to use Belt.set and the example I see is.

Even for somebody whose used a bit of Reason, this takes a bit to grok 😅

module PairComparator =
  Belt.Id.MakeComparable({
    type t = (int, int)
    let cmp = ((a0, a1), (b0, b1)) =>
      switch (Pervasives.compare(a0, b0)) {
      | 0 => Pervasives.compare(a1, b1)
      | c => c
      }
  })

let mySet = Belt.Set.make(~id=module(PairComparator))
let mySet2 = Belt.Set.add(mySet, (1, 2))

In this specific example, I don't have an alternative but just wanted to bring this to attention. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant