title: Haskell: Is it possible to use the abstract data type in pattern matching
body: <p>Say I have an ADT called foo</p>
  
  <pre><code>data foo = N Integer | V Var | Div foo foo
  </code></pre>
  
  <p>Is there a way to use the ADT in pattern matching so I don't have to write out every possible combination of data types?</p>
  
  <pre><code>myfunc :: foo -&gt; [Var]
  myfunc (N _) = []
  myfunc (V a) = [a]
  myfunc (Div (foo) (foo)) = myfunc(foo) ++ myfunc(foo)
  </code></pre>
  
  <p>Is there a way to make something like this work so I don't have to write</p>
  
  <pre><code>myfunc (Div (N a) (N b)) = myfunc(N a) ++ myfunc(N b)
  myfunc (Div (V a) (N b)) = myfunc(V a) ++ myfunc(N b)
  myfunc (Div (N a) (V b)) = myfunc(N a) ++ myfunc(V b)
  ...
  </code></pre>
  
  <p>etc</p>