Open kylegoetz opened 3 years ago
Note that getMonoidSame
doesn't return a Monoid
const M = getMonoidSame<number>()
console.log(M.concat(1, M.empty)) // => undefined, should be 1
Ah, I got confused about the monoid law. I thought e
was the multiplicative zero not the multiplicative identity.
🐛 Bug report
Consider the code
I would expect
but instead I get
{ foo: '1', bar: '2' }
becausebar
is only in the first entry, sogetMonoidSame().concat
is not called forbar
.It seems like concatenating two records should run concat on all props rather than skipping the unshared ones and then including them in the result.
Edit The use case here is if you're loading up a "bulk edit" dialog for an array of data of the same type, you'd want the inputs in your page corresponding to
foo
to be initialized with the shared value offoo
but sincebar
does not have a common value, you'd want that input to be initialized as blank (so as not to be overwritingbar
values by default).