It seems like there could exist an equivalent stack-safe applicative, similar to MonadRec, working title ApplicativeRec, with a trampolineA :: ApplicativeRec f => f (a -> RR a b) -> f a -> f b. Furthermore, it would get an instance for free for every MonadRec in the form of trampolineA f = trampolineM (\a -> fmap ($ a) f).
However, applicatives that support custom zip semantics (like IO that can zip in parallel), or applicatives that are implicitly stack-safe but do not support parallel execution (like Lazy) could offer better implementations than the default built on trampolineM.
This may also make it possible for SafeT to preserve nested stack-safe parallel composition for zips.
It seems like there could exist an equivalent stack-safe applicative, similar to
MonadRec, working titleApplicativeRec, with atrampolineA :: ApplicativeRec f => f (a -> RR a b) -> f a -> f b. Furthermore, it would get an instance for free for everyMonadRecin the form oftrampolineA f = trampolineM (\a -> fmap ($ a) f).However, applicatives that support custom zip semantics (like
IOthat can zip in parallel), or applicatives that are implicitly stack-safe but do not support parallel execution (likeLazy) could offer better implementations than the default built ontrampolineM.This may also make it possible for
SafeTto preserve nested stack-safe parallel composition for zips.