Hey folks.
I’m trying to write compare
functions for a bunch of variant types, and pattern matching all the variants looks kind of tedious, so I was wondering if it’s OK to use pervasives.compare
for that task, e.g.:
type t = {
id: int,
dueDate: option(Js.Date.t),
priority: option(priority),
status,
stickers: list(Sticker.t),
title: string,
}
and status =
| Todo
| BlockedBy(t)
| InProgress(Employee.t)
| UnderReview(Employee.t)
| Done;
let compareStatuses = (x, y) => compare(x.status, y.status);
It works in BuckleScript, but I wonder if it just happens to work for now or if there’s a guarantee.