I am trying to merge multiple objects with Sanctuary.
With Ramda.js I would do something like this (see the REPL here):
const R = require('ramda');
const initialEntry = { a: 0, b: 1 };
const entries = [{c: 2}, {d: 3, e: 4}, {f: 5, g: 6, h: 7}];
R.reduce(Object.assign, initialEntry, entries);
However, with Santuary.js the following line of code throws an exception.
S.reduce(Object.assign)(initialEntry)(entries)
Here is the exception I am getting:
! Invalid value
reduce :: Foldable f => (a -> b -> a) -> a -> f b -> a
^^^^^^
1
1) {"a": 0, "b": 1} :: Object, StrMap Number, StrMap FiniteNumber, StrMap Integer, StrMap NonNegativeInteger, StrMap ValidNumber
The value at position 1 is not a member of ‘b -> a’.
I am puzzled by this error message. Am I using S.reduce
incorrectly? Also, I get no errors if I write S.reduce(Object.assign)(initialEntry)([])
.