Sha256: ca0295987206df5e2fe68da3f4b2004406a98935c44d6ae570561d860370ca3d

Contents?: true

Size: 506 Bytes

Versions: 1

Compression:

Stored size: 506 Bytes

Contents

module Monad
  module Maybe
    class Base
      attr_reader :value

      def <<(obj)
        to_list << obj
      end
  
      def maybe?
        true
      end
  
      def to_list
        List.new(to_a)
      end

      def to_maybe
        self
      end

      def maybe(&blk)
        bind(blk)
      end

      def then(fn)
        bind(->(x){ fn && fn.call })
        self
      end

      def and(&blk)
        self.then(blk)
      end
  
      private
      def initialize; end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
monad-maybe-0.9.9 lib/monad/maybe/base.rb