Sha256: 0f6e7d280985badd1634ce62516bb3515d5c23c12a19fabbb64dda44fdfa7429

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

module Kind
  module Maybe
    require 'kind/core/maybe/result'
    require 'kind/core/maybe/none'
    require 'kind/core/maybe/some'
    require 'kind/core/maybe/wrappable'
    require 'kind/core/maybe/typed'

    extend self

    def new(value)
      (KIND.null?(value) ? None : Some)
        .new(value)
    end

    alias_method :[], :new

    extend Wrappable
  end

  Optional = Maybe

  None = Maybe.none

  def self.None
    None
  end

  def self.Some(value)
    Maybe.some(value)
  end

  def self.Maybe(kind)
    Maybe::Typed.new(kind)
  end

  def self.Optional(kind)
    Maybe::Typed.new(kind)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kind-5.1.0 lib/kind/core/maybe.rb