
On Thu, 21 Dec 2006, Ross Paterson wrote:
On Thu, Dec 21, 2006 at 07:16:16PM +0100, Henning Thielemann wrote:
About the question, whether functions should be provided in the most general context, I refer to http://www.haskell.org/haskellwiki/Slim_instance_declaration
Certainly we all agree that a module that defines instances should export functions it uses that others can use in defining further instances, but I don't see the point of this rule as stated. What would we gain if Ratio exported (+) on rationals with a different name?
(+) is probably not a convincing example. E.g. the Functor method 'fmap' is instantiated by 'map' for lists. The monad method (>>=) for lists is implemented by (flip concatMap). Shall we hide concatMap because (>>=) is already there? I say no, because in cases where lists are the only possible choice, 'map' and 'concatMap' are more informative to the reader and let automatic type inference work better than 'fmap' and (>>=). Imagine the Monad concept is still not invented. Then we could only define 'concatMap' but not '(>>=)'. Later the Monad class is introduced. Shall we discourage the use of 'concatMap' because there is now also (>>=)? Now imagine we encounter an even more general concept, where monads are a special case of. Shall we hide the more restrictive Monad method (>>=) and the plain implementation 'concatMap' in favour of the more general method?