Class: Ruff::Standard::Async::Instance
- Inherits:
-
Object
- Object
- Ruff::Standard::Async::Instance
- Defined in:
- lib/ruff/standard/async.rb
Constant Summary collapse
- Waiting =
are ADT-like classes which have only getter method. These are used internally.
type 'a promise = | Waiting of ('a, unit) continuation list | Done of 'a
Util::ADT.create
- Done =
Util::ADT.create
Instance Attribute Summary collapse
-
#eff ⇒ Object
readonly
You can reimplement the handler using these effect instances with accessing
Async.async
,Async.yield
, andAsync.await
.
Instance Method Summary collapse
-
#async(th) ⇒ Promise<A>
is a smart method to invoke the effect operation
Async.async
. -
#await(p) ⇒ A
is a smart method to invoke the effect operation
Async.await
. -
#initialize ⇒ Instance
constructor
makes a new instance.
-
#with(&th) ⇒ ()!{e}
Returns unit but still has the possibility to invoke effects
e
. -
#yield ⇒ ()
is a smart method to invoke the effect operation
Async.yield
.
Constructor Details
#initialize ⇒ Instance
makes a new instance.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ruff/standard/async.rb', line 55 def initialize # delegates effect instances. @eff = OpenStruct.new( async: Ruff.instance, yield: Ruff.instance, await: Ruff.instance ) # is a proc queue. @q = Util::FnStack.new end |
Instance Attribute Details
#eff ⇒ Object (readonly)
You can reimplement the handler using these effect instances
with accessing Async.async
, Async.yield
, and Async.await
.
104 105 106 |
# File 'lib/ruff/standard/async.rb', line 104 def eff @eff end |
Instance Method Details
#async(th) ⇒ Promise<A>
is a smart method to invoke the effect operation Async.async
.
72 73 74 |
# File 'lib/ruff/standard/async.rb', line 72 def async(th) @eff.async.perform th end |
#await(p) ⇒ A
is a smart method to invoke the effect operation Async.await
.
88 89 90 |
# File 'lib/ruff/standard/async.rb', line 88 def await(p) @eff.await.perform p end |
#with(&th) ⇒ ()!{e}
Returns unit but still has the possibility to invoke effects e
.
98 99 100 |
# File 'lib/ruff/standard/async.rb', line 98 define_method :with do |&th| fork(Util::Ref.new(Waiting.new([])), th) end |
#yield ⇒ ()
is a smart method to invoke the effect operation Async.yield
.
79 80 81 |
# File 'lib/ruff/standard/async.rb', line 79 def yield @eff.yield.perform end |