I’m a beginner and very new to Elm’s syntax. I saw this piece of code in the real world SPA example:
The destructuring part is what is confusing me — I know that this is valid:
(x, y) = (1, 2)
But the expression from the elm spa code is assigning 6 variables: toPage, toModel, toMsg, subUpdate, subMsg and subModel from what it seems to be a two element tuple (model, cmd).
Isn’t this invalid? How does it work, what am I missing?
That’s just a local function via the let binding, down in the code toPage gets called with the 5 arguments and it just returns the 2-tuple. You could move that function out as a toplevel function of the module.