[Haskell] Type-class overloaded functions: second-order typeclass programming with backtracking