Document (or fix) stack safety issues
milesfrain opened this issue · 5 comments
Some example of existing stack-unsafe functions:
sort- reported in #192nubEq, can be fixed for strict lists by applying same strategy used for structnubin #179nubfor lazy lists. Don't know of a good way to fix this. The strictnubstrategy of #179 cannot be applied here because you can'treversean infinite lazy list.
We should ideally setup stack-safety tests for every function. To help make those tests run faster, we could shrink the v8 stack size with something like --stack_size=10 (default is 984 kB).
I would prefer that we test with lists which are large enough to blow the stack than shrink the stack artificially, as we ideally ought to be testing with large inputs anyway, e.g. so that we are more likely to notice if we make a change which unintentionally makes some functions much slower for large inputs.
From Data.List.Lazy
elemIndexelemLastIndexfindLastIndexfindIndex<--- caused by
purescript-lists/src/Data/List/Lazy.purs
Lines 317 to 327 in 6383c4f
group also does not appear to be stack-safe.
It appears that concat is also not stack-safe?
Yeah, seems so - concat is implemented with bind which isn't stack safe:
purescript-lists/src/Data/List/Types.purs
Lines 165 to 167 in 68bce83