Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Haskell has solved these problems quite nicely for me. You can use infix or prefix. And you can make any operator prefix by enclosing it in parens. The other way round, you have to backtick your function to make it infix. And it uses typeclasses to (mostly) allow the same operators for all numeric types.

> (+) 1 2 > 1 `add` 2



There's a way to set the infix associativity and precedence, isn't there? (I'm rusty at Haskell, it's not my thing.)

You can do typeclass-like overloading in OCaml via its module system, but it isn't really integrated into basic arithmetic, which probably would have been the single most useful place for it. (I just got used to it, but it's definitely a wart.)


> There's a way to set the infix associativity and precedence, isn't there?

Yes, at least for your new operators like , ++, ==> etc.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: