title: Why do I get these type errors?
body: <p>I have a data type:</p>
  
  <pre><code>data Tree = Empty | Node Int Tree Tree
  </code></pre>
  
  <p>and I want function </p>
  
  <pre><code>nodeDepth :: Tree -&gt; [(Int, Int)] 
  </code></pre>
  
  <p>one pair for each node. The first element is label (value )and the second one is its depth.</p>
  
  <p>My intention (raw code) is like :</p>
  
  <pre><code>nodeDepth (Node label left right) = zip nodeDepth' (Node label left right) [0]
  nodeDepth' Empty _ = []
  nodeDepth' (Node label left right) [level] = label : nodeDepth' (Node label left right) level : (1 + level)
  </code></pre>
  
  <p>But this does not work.</p>
  
  <p>what's wrong? I am using Frege REPL</p>
  
  <pre><code>Error message are like :
  
  E &lt;console&gt;.fr:22: t19906 occurs in type [t19906] rendering expression level{19727} untypable.
  
  E &lt;console&gt;.fr:22: type error in  expression level
      type is   t19906
      used as   [t19906]
  
  E &lt;console&gt;.fr:22: type error in  expression
      nodeDepth' (Node label left right) level:+ 1 level
      type is   [[t19909]]
      used as   [Int]
  
  
  E &lt;console&gt;.fr:22: [[Int]] is not an instance of Num
  
  
  E &lt;console&gt;.fr:20: type error in expression nodeDepth'
      type is apparently [t19961]
      used as function
  
  
  H &lt;console&gt;.fr:20: too many or too few arguments perhaps?
  
  
  E &lt;console&gt;.fr:20: type error in  expression Node label left right
      type is   Tree
      used as   [t19964]
  
  
  E &lt;console&gt;.fr:20: type error in expression
      zip nodeDepth' (Node label left right)
      type is apparently [(t19961,t19964)]
      used as function
  
  
  H &lt;console&gt;.fr:20: too many or too few arguments perhaps?
  
  
  W &lt;console&gt;.fr:20: application of nodeDepth will diverge.
  </code></pre>