title: Haskell algebraic data type pattern matching
body: <p>I have the following: </p>
  
  <pre><code>data Alpha a = Beta a [Alpha a]
  val = Beta 1 [Beta 2 [], Beta 5 [Beta 7 []]]
  </code></pre>
  
  <p>I'm trying to define a function that will move over a val of type Alpha Int and sum it. My desired approach is to extract all the Ints and then sum the resulting list, but I am struggling to extract all the Ints as I don't know what to do with the recursion...</p>
  
  <p>a slight attempt:</p>
  
  <pre><code>checkAlpha :: Alpha Int -&gt; [Int]
  checkAlpha (Beta a []) = [a]
  checkAlpha (Beta a b) = [a] ++ (map checkAlpha b)
  </code></pre>
  
  <p>Obviously this doesn't quite work but I can't see a solution in sight.</p>