Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive functions that may not be stack safe #247

Open
14 tasks
mlms13 opened this issue Mar 15, 2020 · 1 comment
Open
14 tasks

Recursive functions that may not be stack safe #247

mlms13 opened this issue Mar 15, 2020 · 1 comment

Comments

@mlms13
Copy link
Member

mlms13 commented Mar 15, 2020

This is an incomplete list of functions that could blow the stack. At some point we should do a more thorough audit, but I thought for now I'd at least keep track as I come across things.

  • Tree.flatten (see Rewrite Flatten to be stack safe #246)
  • Tree.fill
  • Tree.map
  • Tree.apply
  • Tree.bind
  • Tree.zipWith
  • Int.rangeAsList and Int.rangeAsArray
  • List.flatten
  • List.init
  • List.chunk
  • Array.takeWhile
  • Array.chunk
  • SequenceZipper.findLeftBy
  • SequenceZipper.findRightBy
@mlms13 mlms13 changed the title Non-TCO functions Additional recursive functions may not be stack safe Mar 15, 2020
@andywhite37 andywhite37 changed the title Additional recursive functions may not be stack safe Recursive functions may not be stack safe Mar 16, 2020
@andywhite37 andywhite37 changed the title Recursive functions may not be stack safe Recursive functions that may not be stack safe Mar 18, 2020
@mlms13
Copy link
Member Author

mlms13 commented Apr 16, 2023

This one is outside of the scope of Relude itself (as it's defined in Bastet, or possibly even in the OCaml standard library... not sure), but List.fold_right doesn't appear to be stack-safe (which I think is pretty normal for a foldr implementation), but it's used as the foundation for things like traverse and sequence which maybe makes those functions also not stack safe.

IIRC, PureScript ended up changing to a tail-recursive implementation of foldr, so we could start by digging in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant