You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
elm.js:2166 Uncaught RangeError: Maximum call stack size exceeded
at _Platform_gatherEffects (elm.js:2166)
at _Platform_gatherEffects (elm.js:2179)
...
This function is not tail recursive when working with a nested Cmd.batch. Large flat batches are ok, since a for loop is used to iterate those.
OR Users can write their own custom version of Cmd.batch that keeps the batch flat, and gets transformed into a Cmd.batch later one, once the whole batch has been built.
===
It is conventient to use an update monad like this:
How deep of a nesting are you talking about? I thought current browsers typically allow 10,000-30,000 levels of stack calls. Do you have thousands of updates you're composing, or is this happening with just tens or hundreds of nesting levels?
is not a describing monad. As you can see it's (a -> X a) -> X a -> X a while point of nomadic bind (andThen) is to go from X a to X b. I would suggest not to go crazy about similar abstractions especially those which involve recursion in update.
Elm 0.19.1
This function is not tail recursive when working with a nested
Cmd.batch
. Large flat batches are ok, since a for loop is used to iterate those.https://github.com/elm/core/blob/master/src/Elm/Kernel/Platform.js#L273
Workarounds:
Cmd.batch
that keeps the batch flat, and gets transformed into aCmd.batch
later one, once the whole batch has been built.===
It is conventient to use an update monad like this:
When operating over a large number of update functions, which are written in this style:
It can be convenient to create a larger update by folding over a list of smaller ones, like this:
Even if the smaller
someUpdate
functions returnCmd.none
, a large nestedCmd.batch
will be created.This can be fixed by avoiding using this style of programming, but it seems a shame to not allow it.
Solutions:
Cmd.batch
a bit smarter, by having it flatten any nested batching.The text was updated successfully, but these errors were encountered: