Q:

Find an element in a BST Haskell

I am rewriting a search-for-an-element function in BST on my own, however I encountered this error which I'm not certain of what it means (error occured on the line of x (Empty) = False)
 Occurs check: cannot construct the infinite type: a = Tree a
 When generalising the type(s) for `searchTree'

Here is what I've come up with:
data Tree a = Empty | Node a (Tree a) (Tree a)
                    deriving (Show, Read, Eq)

searchTree :: (Ord a) => a -> Tree a -> Bool
searchTree x (Empty) = False
searchTree x (Node left y right)
    |y == x = True
    |y > x = searchTree x left
    |y < x = searchTree x right

A:

You have Node a (Tree a) (Tree a), but pattern-match it as (Node left y right). This infers the following types: left :: a; y, right :: Tree a. Then you compare y :: Tree a to x :: a - that forces them to have the same type, which is only possible if Tree a is the same type as a. That's an impossible1, infinite type, so GHC complains.
The solution is to fix your pattern match: it should be (Node y left right), to match the data constructor.
1 It's a theoretically possible type, just not a very useful one. a ~ Tree a can hold, but only if a ~ Tree (Tree (Tree (Tree (Tree ...)))).

