|
|
|
|
|
by linkdd
1868 days ago
|
|
Haskell is nice, it's type systems allows the developer to prove the properties of their algorithm. But it's so hard to read when you're not used to the syntax, compare this to a Javascript/Typescript solution: const conds = [
i => i % 2 === 1,
i => i % 4 === 0,
i => i % 6 === 0
]
[1, 2, 3].map(i => conds.every(f => f(i)))
Any developer with any language background should be able to understand this.But `foldl1 (||) (map ($x) tests)` is gibberish when you don't know the Haskell syntax. Maybe that's why the entry level to Haskell is so high. |
|
Much of the minimal elegance of Haskell relies on it being able to express logic while abstracting away details. If the goal was to get the syntax to look more like the one of JS/TS, there could have been a way to write it similarly to your example - and even simpler. But the point was - show how the use of a monoid abstracts all that - allowing one to simply use the already defined operations of the monoid.
At the time the exaples were written, they were indeed intended for a Haskell crowd, but good point going forward. Thank you.