Sha256: 5aa5c584e858f4ef40d551cba9e5e871d3a4b383953f8114c688b4d2cc6ab6cf
Contents?: true
Size: 743 Bytes
Versions: 8
Compression:
Stored size: 743 Bytes
Contents
# frozen_string_literal: true module Dry module Monads # Unit is a special object you can use whenever your computations don't # return any payload. Previously, if your function ran a side-effect # and returned no meaningful value, you had to return things like # Success(nil), Success([]), Success({}), Maybe(""), Success(true) and # so forth. # # You should use Unit if you wish to return an empty monad. # # @example with Result # Success(Unit) # Failure(Unit) # # @example with Maybe # Maybe(Unit) # => Some(Unit) # Unit = Object.new.tap do |unit| def unit.to_s 'Unit' end def unit.inspect 'Unit' end end end end
Version data entries
8 entries across 8 versions & 1 rubygems