How can I implement a function to delete an element in a binary search tree? This is my tree:
data Tree a = Leaf
| Node a (Tree a) (Tree a)
I know that in case my tree is a Leaf
delete :: (Ord a) => a -> Tree a -> Tree a
delete _ Leaf = Leaf
and in case left and right are not empty, I have to delete the minimum from right (or maximum from left) and it became the root. But, how can I implement it??