title: Haskell Tail Recursive Inner Functions
body: <p>Coming from a Scala background I'm pretty used to using tail recursion to write stuff that can't be easily represented using another method. Let's say I want to calculate the length of a list, but I don't want to use a fold. I want to do it in a natural tail recursive way. I thought of this way:</p>
  
  <pre><code>myLength :: [a]  -&gt; Int
  myLength x    = innerLength x 0
  
  innerLength :: [a] -&gt; Int -&gt; Int  -- Tail recursive inner call
  innerLength [] _      = 0
  innerLength (x:xs) n  = innerLength xs n+1
  </code></pre>
  
  <p>and this works fine. But it isn't very readable that innerLength is really the tail recursive inner call to count the list members and it seems like innerLength is scoped in such a way someone could just use innerLength instead of the better myLength.</p>
  
  <p>Is there a better way to do this?</p>