Sha256: 32ff35964fcabf20a61264ac9e68bd5cc3a8fc1929c0484b6037faa833e71de0

Contents?: true

Size: 488 Bytes

Versions: 11

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

module Kind
  require 'kind/monad'

  class Result::Monad::Wrapper < Kind::Monad::Wrapper
    def failure(types = Undefined, matcher = Undefined)
      return if @monad.success? || output?

      @output = yield(@monad.value) if @monad.result?(types, matcher)
    end

    def success(types = Undefined, matcher = Undefined)
      return if @monad.failure? || output?

      @output = yield(@monad.value) if @monad.result?(types, matcher)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kind-5.10.0 lib/kind/result/monad/wrapper.rb
kind-5.9.0 lib/kind/result/monad/wrapper.rb
kind-5.8.1 lib/kind/result/monad/wrapper.rb
kind-5.8.0 lib/kind/result/monad/wrapper.rb
kind-5.7.0 lib/kind/result/monad/wrapper.rb
kind-5.6.0 lib/kind/result/monad/wrapper.rb
kind-5.5.0 lib/kind/result/monad/wrapper.rb
kind-5.4.1 lib/kind/result/monad/wrapper.rb
kind-5.4.0 lib/kind/result/monad/wrapper.rb
kind-5.3.0 lib/kind/result/monad/wrapper.rb
kind-5.2.0 lib/kind/result/monad/wrapper.rb