What is the difference between Scala traits Haskell type class and C++0x Concepts?
Like in this example below where Observer declare an abstract members receiveUpdate
Observer is in fact a “anonymous” types or Structural types.
package observer
trait Subject {
type Observer = { def receiveUpdate(subject: Any) }
private var observers = List[Observer]()
def addObserver(observer:Observer) = observers ::= observer
def notifyObservers = observers foreach (_.receiveUpdate(this))
}
So only two of them have something in common but not by much, that is Concepts and Type-classes. There already has been comparisons between the two in this paper: A comparison of C++ concepts and Haskell type classes