pragma to request tail recursion optimization (and perhaps [co]inductive recursion)

Hi, Haskell compilers optimize tail recursive functions as cycles, which improves both memory and CPU complexity. However, it's easy to make a mistake and break the conditions under which a function can be tail recursive and thus optimized. Is there a way to tell a Haskell compiler that a function must be tail recursive and if it cannot be done, fail the compilation? Like Scala's @tailrec? I'd say no, and believe it would be quite handy. I suppose this could be realized as a pragma. There could be also additional pragmas to ensure that a recursive function is inductive (the recursive call is on a strict sub-structure of one of the arguments) or co-inductive (the recursive call is guarded by a constructor). Best regards, Petr Pudlak
participants (1)
-
Petr P