Skip to content

Instantly share code, notes, and snippets.

View acutmore's full-sized avatar

Ashley Claymore acutmore

View GitHub Profile
@acutmore
acutmore / tuples-in-weakmaps.js
Last active June 16, 2022 09:27
DEPRECATED (FLAWED) - Proof of concept: Tuples (with symbols) as WeakMap keys in Userland
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// this approach fails to handle cycles
// next attempt: https://gist.github.com/acutmore/d1aaaff27c898fdd26b2e15de5c2f7c6
const {Tuple, FakeSymbol} = ToyTupleLib();
const Box = BoxLib(FakeSymbol);
const TupleWeakMap = TupleWeakMapLib(Tuple, FakeSymbol, v => FakeSymbol.isFakeSymbol(v));
const wm = new TupleWeakMap();
@acutmore
acutmore / onSettled.js
Created February 17, 2022 17:40
utility function to take an array of promises and return an async iterator that yield results as promises settle
/** @param promises {Array<Promise<unknown>>} */
export async function * onSettled(promises) {
let wake;
let wait = new Promise(_ => wake = _);
let pending = promises.length;
const queue = [];
for (const p of promises) {
Promise.allSettled([p]).then(([result]) => {
queue.push(result);
@acutmore
acutmore / immutability-supports-equality.md
Last active September 23, 2022 22:31
When considering the design of the Record & Tuple proposal a core driver in much of the design stems primarily from equality rather than immutability.

Immutability is Equality's support act [hackmd]

When considering the design of the Record & Tuple proposal a core driver in much of the design stems primarily from equality rather than immutability.

Categorizing equality

There are many ways to think about equality but one way to divide up the design space is two dimensions.

pure impure