Is there any way to compare two functions in Haskell?
My thought is that the answer is no since functions would not derive the Eq type class. However I\'m trying to
The code below may not compile, but hopefully you get the idea:
data Op = Succ | Pred deriving Eq
fromOp :: Enum a => Op -> a -> a
fromOp Succ = succ
fromOp Pred = pred
search :: Op -> Card -> [Card] -> [Card]
search op x list = if (op == Succ && rank x == King) ||
(op == Pred && rank x == Ace)
then []
else let c = [ n | n <- list, rank n == (fromOp op) (rank x)]
in if length c == 1
then x : search op (head c) list
else []