Skip to content

Instantly share code, notes, and snippets.

@mlms13
Created May 14, 2020 03:51
Show Gist options
  • Save mlms13/fcca059960dc4d79826e1bafbb1c8150 to your computer and use it in GitHub Desktop.
Save mlms13/fcca059960dc4d79826e1bafbb1c8150 to your computer and use it in GitHub Desktop.
Combining bs-deriving with Bastet's expected function names
module Face = {
[@deriving (enum, ord, eq)]
type t =
| Blank
| One
| Two
| Three
| Four
| Five
| Six
| Seven
| Eight
| Nine
| Ten
| Eleven
| Twelve;
let eq = (a: t, b: t) => a == b;
let compare = (a: t, b: t) => Relude.Ordering.fromInt(compare(a, b));
let toEnum = of_enum;
let fromEnum = to_enum;
let cardinality = max + 1;
let succ = v => toEnum(fromEnum(v) + 1);
let pred = v => toEnum(fromEnum(v) - 1);
let bottom = Blank;
let top = Twelve;
};
type t =
| Domino(Face.t, Face.t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment