A) I’ve been learning Reason for the last two months, so I’m almost certainly just being dumb here. B) The context is PR #35 on reductive, in which I’m trying to add something akin to a lens (a la react-redux).
let lensedComponent =
(
make: /* line 111 */
(~state: 'lensed, ~dispatch: 'action => unit, array(ReasonReact.reactElement)) =>
ReasonReact.component('a, 'b, 'c),
get: 'state => 'lensed,
~state: 'state,
~dispatch: 'action => unit,
children: array(ReasonReact.reactElement),
)
: ReasonReact.component('a, 'b, 'c) => {
let state: 'lensed = get(state);
let baseComponent = make(~state, ~dispatch, children);
{
...baseComponent,
ReasonReact.retainedProps: state,
shouldUpdate:
(
{
oldSelf: {retainedProps: oldState},
newSelf: {retainedProps: newState},
} as total,
) =>
oldState === newState ?
false : baseComponent.ReasonReact.shouldUpdate(total),
};
};
The 4.0.7 compiler does not like the labels on the parameters in the type signature of the make
argument.
File "/Users/nfiedler/projects/reductive/src/reductive.re", line 112, characters 9-24:
Error: Syntax error: Labels are not allowed inside a tuple not expected.
But taking them away means the ~state
argument in the call to make
is somehow missing, and the compiler complains.
119 ┆ : ReasonReact.component('a, 'b, 'c) => {
120 ┆ let state: 'lensed = get(state);
121 ┆ let baseComponent = make(~state, ~dispatch, children);
122 ┆ {
123 ┆ ...baseComponent,
The function applied to this argument has type
('action => unit, array(ReasonReact.reactElement)) =>
ReasonReact.componentSpec('a, 'a, 'b, 'b, 'c)
This argument cannot be applied with label ~state
Thank you in advance for any suggestions you can offer.