Skip to content

Instantly share code, notes, and snippets.

@ethanresnick
ethanresnick / src.ts
Created January 20, 2020 09:12
Any value monoid
/**
* This is a monoid over _all elements in the JS programming language_.
* It's not really useful on its own, and it's a bit of a hack, but it's valid
* and maybe kinda cool. Here's how it works:
*
* 1) it lifts non-lists into a list, like:
*
* 1234 `mappend` { a: true } === [1234, { a: true }]
*
* 2) then, if given a list, it extracts the items from the list before adding