title: Haskell: How do I define the types my function can take as parameters? AND how do I access unnamed variables in a data structure?
body: <p>1) Here is my code, the find function needs to take a (Node a) and a type (a) as parameters but my function definition doesn't seem to work, what am I doing wrong? Little info on the net that I can find, so thanks for any help!</p>
  
  <p>2) When my find function is implemented I'll need to access a specific variable in a Node, how do I do this?!?</p>
  
  <pre><code>-- int for comparisons
  find :: (Node a) =&gt; Node a -&gt; a -&gt; Bool
  find n s
  | s == "asd" = True
  | s /= "asd" = False
  
  data Node a = Node a (Node a) (Node a)
  | Empty
  
  myTree = Node "parent" (Node "left" Empty Empty)
  (Node "right" Empty Empty)
  </code></pre>
  
  <p>Here is the error message I get:</p>
  
  <pre><code>Type constructor `Node' used as a class
  In the type `(Node a) =&gt; Node a -&gt; a -&gt; Bool'
  In the type signature for `find':
  find :: (Node a) =&gt; Node a -&gt; a -&gt; Bool
  Failed, modules loaded: none.
  </code></pre>
  
  <p>I'm obviously still learning this so an explanation of the solutions would also be appreciated, thankyou!</p>