RangeError: Maximum call stack size exceeded when decoding a long list

This would be tail recursive:

mergeListHelp : List Expando -> List Expando -> List Expando -> List Expando
mergeListHelp acc olds news =
  case (olds, news) of
    ([], _) ->
      List.reverse acc ++ news

    (_, []) ->
      List.reverse acc

    (x :: xs, y :: ys) ->
       mergeListHelp (mergeHelp x y :: acc) xs ys

And then modify the two places mergeListHelp is called from mergeListHelp oldValues newValues to mergeListHelp [] oldValues newValues.

P.S. In the second case of the original code, news is always [].

1 Like