On Mar 4, 2009, at 17.14 h, Brian Hurt wrote:

So then you start throwing out the standard instances, among others, you do one for string:
instance Sexpable String where
toSexp s = Atom s
fromSexp (Atom s) = Just s
fromSexp _ = Nothing

and, a little while later, one for generic lists:
instance Sexpable a => Sexpable [ a ] where
toSexp xs = List $ map toSexp xs
fromSexp (List xs) = mapM fromSexp xs
fromSexp _ = Nothing

Opps!  Now you have conflicting instances for type String- one the explicit implementation, and one via the generic list.

To be fair, your String instance is using a GHC extension. It is not legal in plain Haskell.

IMO, in this particular example, the problem is caused not so much by limitations of type classes as such (which exist, of course), but by the somewhat questionable idea of defining a fundamental type like String as a list of chars, transparently.

- Andreas