[Haskell-cafe] confusion about 'instance'....

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Jan 10 08:36:21 EST 2008

Hello Mark,

Thursday, January 10, 2008, 4:25:20 PM, you wrote:

"instance Num a =>> A a"

> Mean the same thing as

> "instance A (forall a.Num a=>a)"

programmers going from OOP world always forget that classes in Haskell
doesn't the same as classes in C++. *implementation* of this instance
require to pass dictionary of Num class along with type. now imagine
the following code:

f :: A a => a -> a

f cannot use your instance because it doesn't receive Num dictionary
of type `a`. it is unlike OOP situation where every object carries the
generic VMT which includes methods for every class/interface that
object supports

as usual, i suggest you to study http://haskell.org/haskellwiki/OOP_vs_type_classes
first and especially two papers mentioned in References there

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list