Hello all!
I’m attempting to build a small runtime using a simple action/reducer pattern but I’m getting a confusing type error: The parameter cannot be eliminated in the result type. Please bind the argument to a module identifier.
. I’m unsure how to interpret the error, though it’s something to do with the action
type and its usage in higher order functions.
The actual module is bigger than this, but here is the smallest reproducible example:
module Make = (
M: {
type action
type state
let reduce: (action, state) => state
},
) => {
type action = M.action
type state = M.state
let reduce = M.reduce
type effects = ref<array<state => state>>
let useEffect = (effects: effects, fn) => {
effects.contents->Js.Array2.push(state => reduce(fn(state), state))->ignore
}
}
module App = Make({
type action = SetX(float) | SetY(float)
type state = {x: float, y: float}
let reduce = (action: action, state: state) => {
switch action {
| SetX(x) => {...state, x: x}
| SetY(y) => {...state, y: y}
}
}
})