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

Simpler Belt Examples (like Belt.Set) #241

@peterpme

Description

@peterpme

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions