Haskell recursion and memory usage

前端 未结 4 577
猫巷女王i
猫巷女王i 2020-12-13 06:35

I\'m getting comfortable with the idea of replacing loops with recursion. I\'m fiddling around with a pet project, and I wanted to test some text input functionality so I w

4条回答
  •  伪装坚强ぢ
    2020-12-13 07:10

    As I understand it you should forget about TCO: instead of asking whether a recursive call is in tail position, think in terms of guarded recursion. This answer I think has it right. You might also check out the post on Data and Codata from the always interesting and challenging "Neighborhood of Infinity" blog. Finally check out the Space Leak Zoo.

    EDIT: I'm sorry the above doesn't address your question about monadic actions directly; I'm interested to see other answers like DanielWagner's that address the IO monad specifically.

提交回复
热议问题