On 8/18/06, John Meacham <[EMAIL PROTECTED]> wrote:
   [lots of good argument before and after deleted]

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.

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. For example

class Monad s => Store s where
   type Key
   insert :: Binary -> s Key
   retrStore :: Key -> s Binary
   ...

so that part of the instance is a choice of the key type.

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

Tom
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to