3 ms·
They were referring to haskell typeclasses, which is a way to dispatch to different function definitions based upon your data's type - which, if you squint, loo
by jes5199 13y ago
They were referring to haskell typeclasses, which is a way to dispatch to different function definitions based upon your data's type - which, if you squint, looks sort of like OO without inheritance.
- chongli 13y agoAnd without objects.
- jes5199 13y agoIt is not clear to me what you think is missing from Haskell data that distinguishes it from objects
- chongli 13y agoIdentity, for one. Haskell is value-oriented. If two values have equal parts they are considered equal, even if they might be stored at different addresses. Barring the FFI (which is an unsafe extension), there is no way to distinguish otherwise equal values. Thus, Haskell has no concept of object identity which is necessary for a system to be object-oriented.
- mercurial 13y agoTypeclasses can have sorta-inheritance, in the way that x may have to be an instance of typeclass X in order to implement typeclass Y.
- jes5199 13y agoYeah. It's not clear to me that you can just do arbitrary overrides, though, like this type is the same as that one except with one function replaced. I can imagine building such a system out of Haskell primatives, though
- mercurial 13y agoAh, I believe overrides are quite out the question. You already can't have two methods with the same name and a different signatures...
- jes5199 13y agoOf course someone has already written a paper on implementing OO on top of Haskell: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.106.772&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.106...