Source

par / lib / par / lazy.rb

Full commit
module Par
  class Lazy
    def initialize source, &block
      @source = source
      @block = block
    end

    def or &block
      other = Lazy.new(@source, &block)

      left = self.value 

      return left if left != Par.bottom
      return other.value
    end

    def value 
      @source.conditional_rewind {
        @block.call
      }
    end
  end
end