7

Is it possible to implement Haskell typeclasses in C++? If yes, then how?

2
  • 3
    What are Haskell-like typeclasses? Commented Jun 27, 2010 at 18:22
  • Noah, Sorry but I don't know how else to express it. Commented Jun 27, 2010 at 18:29

2 Answers 2

7

There's a few papers on this, which might be useful as background reading:

Sign up to request clarification or add additional context in comments.

3 Comments

Am I the only one to notice that the OP's name is similar to the name of the first author of "C++ templates/traits versus Haskell type classes" ?
+1 for the second link, a categorization of the required features is very interesting indeed.
First paper: "C++ templates/traits versus Haskell type classes". There is an error at page 9 (Example 6), code is expressed in the body of a struct. It seems to me that the author have only an approximative knowledge of C++ and this shows in the examples.
3

The similar mechanism in C++ is called "concepts". The idea is to define a typeclass by defining the requirements of any type belonging to that class. C++ iterators make extensive use of concepts, and C++0x had intended to support direct syntax for them (rather than the indirect template tricks to perform concept checks C++ currently employs), but it appears this support has been dropped from the standard.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.