Sha256: e177d4baca7363a231d044ea9e059c098bedaf032966ff73acdb219167a41a05

Contents?: true

Size: 503 Bytes

Versions: 11

Compression:

Stored size: 503 Bytes

Contents

# frozen_string_literal: true

require 'kind/basic'

module Kind
  module Either
    require 'kind/either/monad'
    require 'kind/either/left'
    require 'kind/either/right'
    require 'kind/either/methods'

    extend self

    def new(value)
      Right[value]
    end

    alias_method :[], :new

    def self.from
      result = yield

      Either::Monad === result ? result : Either::Right[result]
    rescue StandardError => e
      Either::Left[e]
    end
  end

  extend Either::Methods
end

Version data entries

11 entries across 11 versions & 1 rubygems

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