Thanks for the quick response. Your explanation is so much clearer than ghc's error messages :-))
Harald. |---------+------------------------------> | | Miguel Mitrofanov | | | <miguelim...@yandex| | | .ru> | | | | | | | | | 24.08.2009 13:29 | | | Delivered date: | | | 24.08.2009 13:31 | | | | |---------+------------------------------> >------------------------------------------------------------------------------------------------------------| | | | To: Harald ROTTER <harald.rot...@sagem.com> | | cc: haskell-cafe@haskell.org | | Subject: Re: [Haskell-cafe] Functional Dependencies and multiparameter typeclasses | >------------------------------------------------------------------------------------------------------------| > However, I do not really understand the cause of the original problem. Why > do I need the functional dependency to make this work ? Suppose you have an instance: instance Pixel MyPixel where... instance Image MyImage MyPixel where width i = countPixels i ... And somebody (not necessarily you) makes another instance: instance Pixel CustomPixel where... instance Image MyImage CustomPixel where width i = 0 ... Now, take any image im :: MyImage Then you'd expect that width im :: Int But now there are TWO implementations of "width :: MyImage -> Int" and no way for compiler to figure out which one to use. GHC sort of foresees this problem. By adding a functional dependency you instruct it to forbid the second declaration, when the first one is present, thus removing the problem. " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe