|
|
|
|
|
by IshKebab
356 days ago
|
|
> practical Haskell needs on the order of 2x as many operators as practical JavaScript, not 10x. Yeah but the JavaScript operators are almost all universally understood. There are some exceptions and mistakes, like `===` which shouldn't exist, and `.?` which is new but fairly standard. But most of the operators are just standard maths stuff, normal array/field accesses, etc. Haskell has normal operators plus a bunch of weird operators that you need to learn. Even if the raw number of operators is only 2x, the number of operators that you have to learn is probably 10x. Especially when you consider that Javascript operators are fixed so you have to learn them once, whereas Haskell operators are user-defined and Haskell programmers love defining them. |
|
* $ is "function application" - f $ x = f x, but lets you elide nested parens: f $ g $ h x = f (g (h x))
* & is "reverse function application" x & f = f x. This reads nicely in pipelines as "and"
* <$> is "fmap" what is like a lifted application over a structure: f <$> [1, 2, 3] = [f 1, f 2, f 3]
* <&> is "reverse fmap", which is nice when you have a big lambda
* Anything in <_> brackets is generally a "lifted" version of some operator
* And so on