tail recursion optimizations and monads

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

tail recursion optimizations and monads

Silent Leaf

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!

Beginners mailing list
[hidden email]