title: Test if two trees are equal and binary search trees in Haskell
body: <p>I am kinda stuck on implementing an Eq instance for binary search trees. I want to check if the values in the two trees are the same, but I don't really know how to do that correctly. Because of the possibly different structures of two binary search trees I can't just compare the nodes directly. My idea was to convert them into a list, sort the lists and compare them but that seems pretty complicated and I wondered if there is another way to do that. Here is what I got so far:</p>
  
  <pre><code>data BB a = L | K a (BB a) (BB a) deriving (Show)
  
  instance Eq BB where
    not (isBinarySearchTree t1 &amp;&amp; isBinarySearchTree t2) = False
    inOrder t1 == inOrder t2 = True
  </code></pre>