<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Compare Binary Search Trees (flawed)'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Wed, 22 May 2013 18:13:01 GMT</pubDate>
<item>
<title>deepsoul said on 9/17/09</title>
<link>http://snipplr.com/view/18966/compare-binary-search-trees-flawed/</link>
<description><![CDATA[ The source you posted compiles and works correctly for me.  It is only deliberately obfuscated.   The result of the second and third case at lines 16 to 26 is always `NotEqual`, because `Remains ..` can never result from line 17 resp. 23.

As for comparing two trees, the following will do nicely:

    treeEq :: Eq a => Tree a -> Tree a -> Bool
    treeEq Empty Empty = True
    treeEq _ Empty = False
    treeEq Empty _ = False
    treeEq ta@(Node a ta1 ta2) tb@(Node b tb1 tb2) =
                                  a == b &amp;&amp; treeEq ta1 tb1 &amp;&amp; treeEq ta2 tb2
    instance (Ord a) => Eq (Tree a) where (==) = treeEq ]]></description>
<pubDate>Thu, 17 Sep 2009 15:16:48 GMT</pubDate>
<guid>http://snipplr.com/view/18966/compare-binary-search-trees-flawed/</guid>
</item>
</channel>
</rss>