6 ms·
> A typeclass indeed is very similar to an interface in object oriented languages Agreed — as I mentioned in the post, typeclasses and interfaces are pretty si
by bradrn 4y ago
> A typeclass indeed is very similar to an interface in object oriented languages
Agreed — as I mentioned in the post, typeclasses and interfaces are pretty similar. However, typeclasses and classes (i.e. the things used to make objects) are entirely different. I’ve seen numerous times when the similarity in names has caused immense confusion to people familiar with OOP, so I thought it would be worthwhile to clarify this.
(As for similarities between OOP and FP in general, you may be interested in this article: https://www.parsonsmatt.org/2018/03/22/three_layer_haskell_cake.html https://www.parsonsmatt.org/2018/03/22/three_layer_haskell_c.... I endorse their conclusion that typeclasses can be used to implement something which in principle is basically OOP. Also, starting from a different point of view, I will note that Smalltalk code tends to be pretty functional in its structure.)