Sounds like type-classes from haskell/scala? Or is that a different thing?

I'm not familiar with Haskell so it's hard for me to say. A cursory look at the wiki.. I get the impression you'd need to explicitly create a new type class? In a dynamic language you can just "dynamically" extend the record (which is sort of like a "class) with new interfaces without making a new class type.

Hopefully that helps.. Sorry if it's not exactly helpful

The protocol example at the end shows how it's done

https://eli.thegreenplace.net/2016/the-expression-problem-an...

If you write something like

    (extend-type BinaryPlus
      Evaluatable
        (evaluate [this] (+ (evaluate (:lhs this)) (evaluate (:rhs this)))))
Then you are adding (and defining) the Evaluatable interface to a record BinaryPlus (which can be coming from a different library and already be implementing other interfaces)

BinaryPlus records can still be used where they were used previously, but you can also use them with the enhancement you added

Clojure's protocols are basically the dynamic language equivalent of type classes.

> I get the impression you'd need to explicitly create a new type class?

In the same way you need to use defprotocol in Clojure. You can implement existing type classes on types without defining a new type class.

Yep pretty much. It’s “open world” polymorphism.