These are chat archives for pzol/deterministic

9th
Oct 2015
Jacques Fuentes
@jpfuentes2
Oct 09 2015 23:35
any interest in adding Result#fold as a catamorphism?
right now it looks like expected flow for checking Result success/failure is with match or with conditionals
class Deterministic::Result
  def fold(failure, success)
    match {
      Success(_) { |s| success.call(s.value) }
      Failure(_) { |f| failure.call(f.value) }
    }
  end
end
example usage:
def render_result(status, result)
  result.fold(
    ->(f) { render_failures(500, f) },
    ->(v) { render_json(status, v) }
  )
end