
Hi all, Well, I've got two problems which both want to be solved with undecidable and overlapping instances. Obviously, I'd like to try and avoid them. For the record, the problems have to do with the control-monad-failure and convertible packages. The code below *should* make clear what I'm trying to accomplish: -- failure should not be limited to just monads, so... class Failure e f where failure :: e -> f v class (Functor f, Failure e f) => FunctorFailure e f instance (Functor f, Failure e f) => FunctorFailure e f -- undecidable, overlaps class (Applicative f, Failure e f) => ApplicativeFailure e f instance (Applicative f, Failure e f) => ApplicativeFailure e f -- undecidable, overlaps class (Monad f, Failure e f) => MonadFailure e f instance (Monad f, Failure e f) => MonadFailure e f -- undecidable, overlaps And now the convertible issue. I want two type classes: Convert for anything which *might* be convertible, but might not. For example, sometimes a String can be converted to an Int (like the string "5"), but sometimes it will fail (like "five"). TotalConvert is when something *is* convertible, such as Int to String (simply the show function). Thus the following: class Convert x y where convert :: x -> Maybe y class Convert x y => TotalConvert x y where totalConvert :: x -> y instance TotalConvert x y => Convert x y where -- Boom! convert = Just . totalConvert Any ideas are most welcome. Both of these seem like cases where the compiler could do some DWIMery, but isn't. Michael