Sha256: e85be8b61502bc8d53f8f811e08e383367800ff33636f7ebb9a89245d343a720

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'singleton'
require_relative 'duck_fiber'
require_relative 'goal'
require_relative 'goal_relation'
require_relative 'outcome'

module MiniKraken
  module Core
    class Tap < GoalRelation
      include Singleton

      def initialize
        super('tap', nil)
      end

      def arity
        1
      end

      # @param actuals [Array<Term>] A two-elements array
      # @param anEnv [Vocabulary] A vocabulary object
      # @return [Fiber<Outcome>] A Fiber that yields Outcomes objects
      def solver_for(actuals, anEnv)
        args = *validated_args(actuals)
        DuckFiber.new(:custom) do
          outcome = tap(args.first, anEnv)
          # outcome.prune!
        end
      end

      def tap(aGoal, anEnv)
        require 'debug'
        f1 = aGoal.attain(anEnv)
        outcome1 = f1.resume
        # key = outcome1.associations.keys.first
        # outcome1.associations['x'] = outcome1.associations[key]
        # outcome1.associations.delete(key)
        outcome1
      end
    end # class

    Tap.instance.freeze
  end # module
end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mini_kraken-0.2.04 lib/mini_kraken/core/tap.rb