[...new Set([{x: 1}, {x: 1}])] [1, 1, 2, 3, 4].filter(
(obj => x => {
if (obj[x]) {
return false;
}
obj[x] = true;
return true;
})({}),
);
What's happening is that you're passing an object (hashmap / hashset) into a function that returns a filtering function, and that object is used inside the closure to track the dupes. It's still a pure function because even though you're mutating the passed in object, the filtering function is still deterministic and referentially transparent.
Besides, I feel like if I really want a strong type system https://reasonml.github.io/ might be the better choice over flow.