title: Function inside let not Num
body: <p>I have these</p>
  <pre><code>data Fruit = Peach | Apple | Pear | Lemon | Fig deriving (Show,Eq)
  data FTree = Bud | Split FTree FTree | Flat Fruit FTree deriving (Show,Eq)
  </code></pre>
  <p>and this meant to count the number of occurrences of an inputted fruit type</p>
  <pre><code>ftreeFOccurs cft ft =
    let ftFO Bud = 0
        ftFO (Flat frt ft) = if (frt == cft) then (1 + (ftFO ft)) else (ftFO ft)
        ftFO (Split ft1 ft2) = (Split (ftFO ft1) (ftFO ft2))
    in ftFO ft
  </code></pre>
  <p>and here would be a typical tree</p>
  <pre><code>Split (Split Bud Bud) (Flat Fig (Flat Lemon (Flat Apple Bud)))
  </code></pre>
  <p>But when I submit <code>ftreeFOccurs</code> I get this error</p>
  <pre><code>No instance for (Num FTree) arising from the literal `0'
      * In the expression: 0
        In an equation for `ftFO': ftFO Bud = 0
  </code></pre>
  <p>A similar function, however,</p>
  <pre><code>ftreeHeight Bud = 0
  ftreeHeight (Flat frt ft) = 1 + ftreeHeight ft
  ftreeHeight (Split ft1 ft2) = deeper (1 + ftreeHeight ft1) (1 + ftreeHeight ft2)
                                where deeper t1 t2 = if (t1 &gt;= t2) then t1 else t2
  </code></pre>
  <p>works. This is a translation of an SML problem from <em>The Little MLer</em>, where the <code>occurs</code> function has a 2-tuple parameter with the fruit and the tree carried through the recursions ... which doesn't seem like the Haskell way. But then I'm not sure why having a function in a <code>let</code> makes this difference.</p>