module Dry::Monads::Task::Mixin

Task constructors.

@api public

Constants

Task

The Task monad represents an async computation. The implementation is a rather thin wrapper of Concurrent::Promise from the concurrent-ruby. The API supports setting a custom executor from concurrent-ruby.

@api public

Unit

@see Dry::Monads::Unit

Public Class Methods

[](executor) click to toggle source

Created a mixin with the given executor injected.

@param executor [Concurrent::AbstractExecutorService,Symbol] @return [Module]

# File lib/dry/monads/task.rb, line 285
def self.[](executor)
  Module.new do
    include Mixin

    # Created a new Task with an injected executor.
    #
    # @param block [Proc]
    # @return [Task]
    define_method(:Task) do |&block|
      Task[executor, &block]
    end
  end
end