Sha256: f2b36ef0b9d11c977fa611d66d9f8c5032ebc06e439b0eec160ead533b70e895

Contents?: true

Size: 899 Bytes

Versions: 1

Compression:

Stored size: 899 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Typed
  # A monad representing either a success or a failure. Contains payload and error information as well.
  class Result
    extend T::Sig
    extend T::Helpers
    extend T::Generic

    abstract!

    Payload = type_member(:out)
    Error = type_member(:out)

    sig { abstract.returns(T::Boolean) }
    def success?; end

    sig { abstract.returns(T::Boolean) }
    def failure?; end

    sig { abstract.returns(Payload) }
    def payload; end

    sig { abstract.returns(Error) }
    def error; end

    sig do
      abstract
        .type_parameters(:U, :T)
        .params(_block: T.proc.params(arg0: Payload).returns(Result[T.type_parameter(:U), T.type_parameter(:T)]))
        .returns(T.any(Result[T.type_parameter(:U), T.type_parameter(:T)], Result[T.type_parameter(:U), Error]))
    end
    def and_then(&_block); end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sorbet-result-0.3.0 lib/typed/result.rb