you're right my example is more like Show, it's because i change two times the order of input and output, and did not check at the end if it was what i wanted...
Actually i did not mean constraints on instances, especially thereafter ad-hoc polymorphic instances.
I rather meant what i said, as in default implementation (as in, right inside the body of the class).
like that:
class Foo a where
bar :: a -> String
bar :: Show a => a -> String
bar = show -- default implementation: in other terms, if you define an instance without defining this method
the idea would be then that if you have Foo (), you can either implement a special version, or leave it to show. mind you i'm not even sure we can define an instance without any specific implementation of method?
--that would be allowed:
instance Show => Foo () where
-- nothing, if it's even legal by default
-- and of course that would be allowed to if someone wanted a special function bar :: Foo () => () -> String
instance Foo () where
bar = ....
obviously, i do not mean *both* instances of Foo (), just, one or the other. it would merely be a way to implement ad-hoc polymorphism onto *default implementations of methods*, that is, those inside the body of the class.