[Haskell-beginners] tail recursion optimizations and monads

Silent Leaf silent.leaf0 at gmail.com
Wed Jun 28 20:01:10 UTC 2017


Hi,

If i do this:
f :: (Monad m) => a -> m a
f a = ma >>= f

 or maybe this:
f :: (Monad m) => Foo -> m a
f foo = mb >>= \foo' -> mc >> f foo'


can i be sure it's tail recursive (as in, with optimization)? is it in fact
ever the case? does it depend on the monad? esp obviously i'm very
interested in the IO monad in those cases. esp, even if it's tail recursive
on the level of haskell, does it entail an execution of the underlying IO
action in any way tail-recursively optimized? or does it not even matter
because at the level of the execution of the IO value, there's no recursion
to speak of anymore? just wondering.

thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170628/cea0fcd9/attachment.html>


More information about the Beginners mailing list