You can turn it into a loop with a case statement inside if you collect the connected component of tail called functions and make those the cases. But it’s gonna be a big function.
You can split it up a bit if you use a trampoline, but then you lose some efficiency.
You can split it up a bit if you use a trampoline, but then you lose some efficiency.
Which would definitely work, no doubts about that, but it might be nicer to just get it handled at a more fundamental level.