3 ms·
> Haskell's type system is terrible for this, ie. instead of plain vanilla operator overloading they have (^+^)... Haskell’s type system does not prevent you f
by runeks 9y ago
> Haskell's type system is terrible for this, ie. instead of plain vanilla operator overloading they have (^+^)...
Haskell’s type system does not prevent you from overloading the + operator. It’s the standard library (“Prelude”) that defines + to only work on numbers, and not on vectors, but with Haskell’s type system allows you to define + to do anything you want.
- tome 9y agoYes indeed. Not only is it possible to overload + but Haskell's type system has absolutely nothing to say on the matter.
- Maro 9y agoYes but if you want to use libs, and they don't do it this way, you're f--ked. This is one of the things I ran into.
- dllthomas 9y agoWell, no, you're not "f--ked", there's just a pile of boilerplate. Not fun - and likely not worth it for the marginal benefit of being able to reuse + that way - but plenty possible. And for what it's worth, I certainly agree that the way Num is structured is a wart in Haskell, and I think the previous two commenters agree. It's just that we should be clear about where the blame lies - and that's not the type system.