[Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Aug 18 02:13:44 EDT 2006

Hello Thomas,

Friday, August 18, 2006, 7:57:13 AM, you wrote:

>> There is a major difference though, in C++ (or java, or sather, or c#,
>> etc..) the dictionary is always attached to the value, the actual class
>> data type you pass around. in haskell, the dictionary is passed
>> separately and the appropriae one is infered by the type system. C++
>> doesn't infer, it just assumes everything will be carying around its
>> dictionary with it.

> C++ programmers deal with this using a number of techniques, mostly
> involving templates.

Haskell type classes are closer to templates/generics than to classes

> Actually, there is one technique using C++ templates that I really
> want to see going mainstream in the Haskell implementations.
> Existential types are already there, now I want to see associated
> types (trait types in C++). Maybe I've been doing too much C++
> programming in the last few years, but a lot of the times when I end
> up using multiparameter type classes, what I really want is an
> associated type.

i also wrote a lot of such code for Streams library and can say that
MPTC+FD are close enough to emulate AT, although need slightly more
verbose definitions. moreover, AT are already implemented in GHC 6.5,
afai seen in ghc-cvs reports

> For those who are interested, I'm sure the relevant papers are readily
> available on citeseer/Google. :-)


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

More information about the Haskell-Cafe mailing list