Skip to content

Instantly share code, notes, and snippets.

@michaelherold
michaelherold / monads.rb
Created November 7, 2018 17:42
It really seems like it should be easier to reduce a list of Results
require 'dry/monads/all'
include Dry::Monads::Result::Mixin
success = Success(:finished)
def merge(result, failures)
result
.or { |failure| Failure(failure + failures) }
.bind { Failure(failures) }