Sha256: 62b39c85b94370747717d26649f546f690db4e3a107a8ac02af0d6b9a3c59500

Contents?: true

Size: 507 Bytes

Versions: 2

Compression:

Stored size: 507 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Muina
  class Result < Value
    # Right(wrong) side of the Result Monad
    class Failure < self
      class ValueCalledOnFailureError < Error; end

      const :error, T.untyped
      private :error

      def value!
        raise ValueCalledOnFailureError
      end

      def error!
        error
      end

      def and_then(&_blk)
        self
      end

      def or_else(&blk)
        blk[error] if blk
        self
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muina-0.2.8 lib/muina/result/failure.rb
muina-0.2.7 lib/muina/result/failure.rb