News for hackers. Stuff that matters.
Re:Elegant Error Handling with the JavaScript “Either” Monad by the_duke on Wednesday June 19, 2019 @08:24AM (#20222622)
Readable functional programming imo really hinges on some essential basic language primitives. Those are sum types, pattern matching, and restricting mutability.

Forcing sum types onto a language that does not support them is bound to end in awkwardness and reduced readability without providing the real benefits of increased correctness.

This is a great example. std::option from C++ is another one.

Re:Elegant Error Handling with the JavaScript “Either” Monad by Dirlewanger on Wednesday June 19, 2019 @09:24AM (#20223081)
Yeah it's really hard to introduce, let alone completely stick with, FP in a non-FP language. I started to introduce some into our Ruby/Rails project, but halfway through, the code was more procedural than functional (which admittedly is more concise and cogent than OO); it's really hard to remember to treat everything as immutable all the time.
Re:Elegant Error Handling with the JavaScript “Either” Monad by vishbar on Wednesday June 19, 2019 @09:07AM (#20222914)
Scala's for-comprehensions (and Haskell's do-notation) help quite a lot as well.
Re:Elegant Error Handling with the JavaScript “Either” Monad by antisemiotic on Wednesday June 19, 2019 @10:14AM (#20223532)
Also F#'s computational expressions.
Re:Elegant Error Handling with the JavaScript “Either” Monad by lacampbell on Wednesday June 19, 2019 @06:54PM (#20228159)
When combined with flow or typescript, Javascript absolutely supports sum types. Also, it's trivial to encode the Option and Either monad using Objects to get the same functionality.