3 ms·
Because foo.bar.baz = 1 has a side-effect, and side-effects, though powerful, are extremely prone to error. Lenses take more effort, but give us the same amount
by munchler 1y ago
Because foo.bar.baz = 1 has a side-effect, and side-effects, though powerful, are extremely prone to error. Lenses take more effort, but give us the same amount of power without all the errors. Many people believe the trade-off is worthwhile.
- johnfn 1y agoimmer.js allows you to do foo.bar.baz = 1 without side effects.
- munchler 1y agoThanks, I just took a look. It works by relaxing constraints to allow mutation on a “draft” copy of the data. Interesting idea! (But verboten in Haskell, of course.)
- johnfn 1y agoBut there's nothing 'verboten' about this in Haskell! Haskell could allow for the exact same syntax, and do the exact same thing behind the scenes. Oh but no, LENSES of course, you must rewrite obvious code in the most obtuse manner possible. :)
- munchler 1y agoUnlike JavaScript, it would require fundamental changes to the language itself, so I don’t think it’s really a fair comparison.
- johnfn 1y agoBut lenses already do the same thing, just with a worse syntax. do notation already rewrites a lot of messy Haskell into cleaner Haskell. It's not that different!