title: Is there a way to assert that a function is recognized as tail-recursive by the compiler?
body: <p>Let's say I've written a function in Haskell and I want to assert that it is tail-recursive and it will be optimized by the compiler. Is there a way to do it?</p>
  
  <p>I know there's a way to do it in Scala with <a href="https://www.scala-lang.org/api/current/scala/annotation/tailrec.html" rel="noreferrer">@tailrec</a> annotation.</p>
  
  <p><a href="http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html" rel="noreferrer">Example:</a></p>
  
  <pre><code>import scala.annotation.tailrec
  
  class Factorial2 {
    def factorial(n: Int): Int = {
      @tailrec def factorialAcc(acc: Int, n: Int): Int = {
        if (n &lt;= 1) acc
        else factorialAcc(n * acc, n - 1)
      }
      factorialAcc(1, n)
    }
  }
  </code></pre>