4 ms·
The weirdest thing about things like dry-monad is that they're so incredibly shoehorned in. In places like Haskell, the default for a function is to be pure and
by WJW 3y ago
The weirdest thing about things like dry-monad is that they're so incredibly shoehorned in. In places like Haskell, the default for a function is to be pure and monads add some capability for side effects (ie logging, or keeping state, or error tracking, all the way up to arbitrary IO). In Ruby on the other hand, the default is that a method can do anything it pleases, from from monkeypatching the standard libraries to database queries to launching intercontinental nuclear missiles. There is (by design!) no contract enforced at all on what the code can do.
Trying to bolt paradigms from stricter languages onto Ruby is like nailing jelly to a wall.
- perceptronas 3y agoFP Scala is enforced by discipline rather than the language itself. It works wonderfully, even though you don't have effect tracking and can launch intercontinental missiles everywhere. Not saying this paradigm fits in Ruby, but it certainly works with discipline as well. As for shoehorning things into Ruby – I think its fine to experiment. Libraries can always try to bring best practices from other languages, some might fit wonderfully, others might not. I personally dislike exceptions, I will happily include "fake" Result/Either for non panic workflows