Closed ivenmarquardt closed 3 years ago
Here is an example of a sorting comparator:
type("(^r. r => r => r => r) => Comparator");
type("(^r. r, r, r => r) => Comparator");
type("(^r. {lt: r, eq: r, gt: r} => r) => Comparator");
The first one is a regular sum type. The second one makes use of Javascript's multi-argument functions. The third example uses an object to mimic named arguments.
I'll probably give the last one a shot. Maybe this is the most efficient/readable encoding for all sum types, consider Option
:
type("(^r. {none: r, some: a => r} => r) => Option<a>");
This looks promising and you can probably allow partially applied records as well.
Done.
This should be possible, of course, but currently it isn't.