ruff 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +18 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -14
- data/docs/Ruff.html +3 -3
- data/docs/Ruff/Effect.html +2 -2
- data/docs/Ruff/Handler.html +73 -113
- data/docs/Ruff/Standard.html +33 -3
- data/docs/Ruff/Standard/CurrentTime.html +150 -14
- data/docs/Ruff/Standard/CurrentTime/Instance.html +183 -25
- data/docs/Ruff/Standard/Defer.html +152 -15
- data/docs/Ruff/Standard/Defer/Instance.html +213 -37
- data/docs/Ruff/Standard/State.html +215 -30
- data/docs/Ruff/Standard/State/Instance.html +389 -72
- data/docs/Ruff/Throws.html +2 -2
- data/docs/Ruff/Throws/Eff.html +6 -4
- data/docs/Ruff/Throws/Resend.html +14 -12
- data/docs/_index.html +3 -3
- data/docs/file.README.html +7 -23
- data/docs/frames.html +1 -1
- data/docs/index.html +7 -23
- data/docs/method_list.html +84 -28
- data/docs/top-level-namespace.html +2 -2
- data/lib/ruff/handler.rb +50 -49
- data/lib/ruff/objects.rb +4 -2
- data/lib/ruff/standard.rb +16 -0
- data/lib/ruff/standard/current_time.rb +29 -2
- data/lib/ruff/standard/defer.rb +33 -3
- data/lib/ruff/standard/state.rb +69 -14
- data/lib/ruff/version.rb +1 -1
- data/version +1 -1
- metadata +2 -3
- data/.rubocop_todo.yml +0 -366
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Ruff::Standard::State::Instance
|
8
8
|
|
9
|
-
— Ruff 1.0.
|
9
|
+
— Ruff 1.0.1 Documentation
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -103,6 +103,39 @@
|
|
103
103
|
|
104
104
|
|
105
105
|
|
106
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
107
|
+
<ul class="summary">
|
108
|
+
|
109
|
+
<li class="public ">
|
110
|
+
<span class="summary_signature">
|
111
|
+
|
112
|
+
<a href="#eff-instance_method" title="#eff (instance method)">#<strong>eff</strong> ⇒ Object </a>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
</span>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<span class="note title readonly">readonly</span>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<span class="summary_desc"><div class='inline'><p>You can reimplement the handler using these effect instances with accessing <code>#eff.get</code> and <code>#eff.modify</code> .</p>
|
132
|
+
</div></span>
|
133
|
+
|
134
|
+
</li>
|
135
|
+
|
136
|
+
|
137
|
+
</ul>
|
138
|
+
|
106
139
|
|
107
140
|
|
108
141
|
|
@@ -117,7 +150,7 @@
|
|
117
150
|
<li class="public ">
|
118
151
|
<span class="summary_signature">
|
119
152
|
|
120
|
-
<a href="#get-instance_method" title="#get (instance method)">#<strong>get</strong> ⇒
|
153
|
+
<a href="#get-instance_method" title="#get (instance method)">#<strong>get</strong> ⇒ S </a>
|
121
154
|
|
122
155
|
|
123
156
|
|
@@ -131,7 +164,8 @@
|
|
131
164
|
|
132
165
|
|
133
166
|
|
134
|
-
<span class="summary_desc"><div class='inline'
|
167
|
+
<span class="summary_desc"><div class='inline'><p>is a smart method to invoke the effect operation <code>State.get</code> .</p>
|
168
|
+
</div></span>
|
135
169
|
|
136
170
|
</li>
|
137
171
|
|
@@ -155,7 +189,7 @@
|
|
155
189
|
|
156
190
|
|
157
191
|
|
158
|
-
<span class="summary_desc"><div class='inline'><p>
|
192
|
+
<span class="summary_desc"><div class='inline'><p>makes new instances.</p>
|
159
193
|
</div></span>
|
160
194
|
|
161
195
|
</li>
|
@@ -164,7 +198,7 @@
|
|
164
198
|
<li class="public ">
|
165
199
|
<span class="summary_signature">
|
166
200
|
|
167
|
-
<a href="#modify-instance_method" title="#modify (instance method)">#<strong>modify</strong>(&fn) ⇒
|
201
|
+
<a href="#modify-instance_method" title="#modify (instance method)">#<strong>modify</strong>(&fn) ⇒ () </a>
|
168
202
|
|
169
203
|
|
170
204
|
|
@@ -178,7 +212,8 @@
|
|
178
212
|
|
179
213
|
|
180
214
|
|
181
|
-
<span class="summary_desc"><div class='inline'
|
215
|
+
<span class="summary_desc"><div class='inline'><p>is a smart hetmod to invoke the effect operation <code>State.modify</code> .</p>
|
216
|
+
</div></span>
|
182
217
|
|
183
218
|
</li>
|
184
219
|
|
@@ -186,7 +221,7 @@
|
|
186
221
|
<li class="public ">
|
187
222
|
<span class="summary_signature">
|
188
223
|
|
189
|
-
<a href="#put-instance_method" title="#put (instance method)">#<strong>put</strong>(s) ⇒
|
224
|
+
<a href="#put-instance_method" title="#put (instance method)">#<strong>put</strong>(s) ⇒ () </a>
|
190
225
|
|
191
226
|
|
192
227
|
|
@@ -200,7 +235,8 @@
|
|
200
235
|
|
201
236
|
|
202
237
|
|
203
|
-
<span class="summary_desc"><div class='inline'
|
238
|
+
<span class="summary_desc"><div class='inline'><p>is a short hand for <code>modify {|_| s }</code>.</p>
|
239
|
+
</div></span>
|
204
240
|
|
205
241
|
</li>
|
206
242
|
|
@@ -208,7 +244,7 @@
|
|
208
244
|
<li class="public ">
|
209
245
|
<span class="summary_signature">
|
210
246
|
|
211
|
-
<a href="#with-instance_method" title="#with (instance method)">#<strong>with</strong>(&
|
247
|
+
<a href="#with-instance_method" title="#with (instance method)">#<strong>with</strong>(&th) ⇒ A!{e} </a>
|
212
248
|
|
213
249
|
|
214
250
|
|
@@ -222,7 +258,8 @@
|
|
222
258
|
|
223
259
|
|
224
260
|
|
225
|
-
<span class="summary_desc"><div class='inline'
|
261
|
+
<span class="summary_desc"><div class='inline'><p>is a short hand for <code>with_init(nil, th)</code> .</p>
|
262
|
+
</div></span>
|
226
263
|
|
227
264
|
</li>
|
228
265
|
|
@@ -230,7 +267,7 @@
|
|
230
267
|
<li class="public ">
|
231
268
|
<span class="summary_signature">
|
232
269
|
|
233
|
-
<a href="#with_init-instance_method" title="#with_init (instance method)">#<strong>with_init</strong>(init, &
|
270
|
+
<a href="#with_init-instance_method" title="#with_init (instance method)">#<strong>with_init</strong>(init, &th) ⇒ A!{e} </a>
|
234
271
|
|
235
272
|
|
236
273
|
|
@@ -244,7 +281,8 @@
|
|
244
281
|
|
245
282
|
|
246
283
|
|
247
|
-
<span class="summary_desc"><div class='inline'
|
284
|
+
<span class="summary_desc"><div class='inline'><p>is a handler to interpret the effect invocations like <em>state monad</em> .</p>
|
285
|
+
</div></span>
|
248
286
|
|
249
287
|
</li>
|
250
288
|
|
@@ -266,7 +304,7 @@
|
|
266
304
|
|
267
305
|
</h3><div class="docstring">
|
268
306
|
<div class="discussion">
|
269
|
-
<p>
|
307
|
+
<p>makes new instances.</p>
|
270
308
|
|
271
309
|
|
272
310
|
</div>
|
@@ -280,17 +318,23 @@
|
|
280
318
|
<pre class="lines">
|
281
319
|
|
282
320
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
321
|
+
13
|
322
|
+
14
|
323
|
+
15
|
324
|
+
16
|
325
|
+
17
|
326
|
+
18
|
327
|
+
19</pre>
|
287
328
|
</td>
|
288
329
|
<td>
|
289
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
330
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 13</span>
|
290
331
|
|
291
332
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
292
|
-
<span class='
|
293
|
-
<span class='
|
333
|
+
<span class='id identifier rubyid_get'>get</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../../Ruff.html" title="Ruff (module)">Ruff</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="../../../Ruff.html#instance-class_method" title="Ruff.instance (method)">instance</a></span></span>
|
334
|
+
<span class='id identifier rubyid_modify'>modify</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../../Ruff.html" title="Ruff (module)">Ruff</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="../../../Ruff.html#instance-class_method" title="Ruff.instance (method)">instance</a></span></span>
|
335
|
+
|
336
|
+
<span class='comment'># delegates effect instances
|
337
|
+
</span> <span class='ivar'>@eff</span> <span class='op'>=</span> <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>get:</span> <span class='id identifier rubyid_get'>get</span><span class='comma'>,</span> <span class='label'>modify:</span> <span class='id identifier rubyid_modify'>modify</span><span class='rparen'>)</span>
|
294
338
|
<span class='kw'>end</span></pre>
|
295
339
|
</td>
|
296
340
|
</tr>
|
@@ -299,6 +343,54 @@
|
|
299
343
|
|
300
344
|
</div>
|
301
345
|
|
346
|
+
<div id="instance_attr_details" class="attr_details">
|
347
|
+
<h2>Instance Attribute Details</h2>
|
348
|
+
|
349
|
+
|
350
|
+
<span id=""></span>
|
351
|
+
<div class="method_details first">
|
352
|
+
<h3 class="signature first" id="eff-instance_method">
|
353
|
+
|
354
|
+
#<strong>eff</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
</h3><div class="docstring">
|
361
|
+
<div class="discussion">
|
362
|
+
<p>You can reimplement the handler using these effect instances
|
363
|
+
with accessing <code>#eff.get</code> and <code>#eff.modify</code> .</p>
|
364
|
+
|
365
|
+
|
366
|
+
</div>
|
367
|
+
</div>
|
368
|
+
<div class="tags">
|
369
|
+
|
370
|
+
|
371
|
+
</div><table class="source_code">
|
372
|
+
<tr>
|
373
|
+
<td>
|
374
|
+
<pre class="lines">
|
375
|
+
|
376
|
+
|
377
|
+
84
|
378
|
+
85
|
379
|
+
86</pre>
|
380
|
+
</td>
|
381
|
+
<td>
|
382
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 84</span>
|
383
|
+
|
384
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_eff'>eff</span>
|
385
|
+
<span class='ivar'>@eff</span>
|
386
|
+
<span class='kw'>end</span></pre>
|
387
|
+
</td>
|
388
|
+
</tr>
|
389
|
+
</table>
|
390
|
+
</div>
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
302
394
|
|
303
395
|
<div id="instance_method_details" class="method_details_list">
|
304
396
|
<h2>Instance Method Details</h2>
|
@@ -307,27 +399,54 @@
|
|
307
399
|
<div class="method_details first">
|
308
400
|
<h3 class="signature first" id="get-instance_method">
|
309
401
|
|
310
|
-
#<strong>get</strong> ⇒ <tt>
|
402
|
+
#<strong>get</strong> ⇒ <tt>S</tt>
|
311
403
|
|
312
404
|
|
313
405
|
|
314
406
|
|
315
407
|
|
316
|
-
</h3><
|
408
|
+
</h3><div class="docstring">
|
409
|
+
<div class="discussion">
|
410
|
+
<p>is a smart method to invoke the effect operation <code>State.get</code> .</p>
|
411
|
+
|
412
|
+
|
413
|
+
</div>
|
414
|
+
</div>
|
415
|
+
<div class="tags">
|
416
|
+
|
417
|
+
<p class="tag_title">Returns:</p>
|
418
|
+
<ul class="return">
|
419
|
+
|
420
|
+
<li>
|
421
|
+
|
422
|
+
|
423
|
+
<span class='type'>(<tt>S</tt>)</span>
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
—
|
428
|
+
<div class='inline'><p>with <code>with</code> , returns <code>S</code> , the current state.</p>
|
429
|
+
</div>
|
430
|
+
|
431
|
+
</li>
|
432
|
+
|
433
|
+
</ul>
|
434
|
+
|
435
|
+
</div><table class="source_code">
|
317
436
|
<tr>
|
318
437
|
<td>
|
319
438
|
<pre class="lines">
|
320
439
|
|
321
440
|
|
322
|
-
|
323
|
-
|
324
|
-
|
441
|
+
24
|
442
|
+
25
|
443
|
+
26</pre>
|
325
444
|
</td>
|
326
445
|
<td>
|
327
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
446
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 24</span>
|
328
447
|
|
329
448
|
<span class='kw'>def</span> <span class='id identifier rubyid_get'>get</span>
|
330
|
-
<span class='ivar'>@get</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span>
|
449
|
+
<span class='ivar'>@eff</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span>
|
331
450
|
<span class='kw'>end</span></pre>
|
332
451
|
</td>
|
333
452
|
</tr>
|
@@ -337,27 +456,70 @@
|
|
337
456
|
<div class="method_details ">
|
338
457
|
<h3 class="signature " id="modify-instance_method">
|
339
458
|
|
340
|
-
#<strong>modify</strong>(&fn) ⇒ <tt>
|
459
|
+
#<strong>modify</strong>(&fn) ⇒ <tt>()</tt>
|
460
|
+
|
461
|
+
|
341
462
|
|
342
463
|
|
343
464
|
|
465
|
+
</h3><div class="docstring">
|
466
|
+
<div class="discussion">
|
467
|
+
<p>is a smart hetmod to invoke the effect operation <code>State.modify</code> .</p>
|
468
|
+
|
469
|
+
|
470
|
+
</div>
|
471
|
+
</div>
|
472
|
+
<div class="tags">
|
473
|
+
<p class="tag_title">Parameters:</p>
|
474
|
+
<ul class="param">
|
475
|
+
|
476
|
+
<li>
|
477
|
+
|
478
|
+
<span class='name'>fn</span>
|
479
|
+
|
480
|
+
|
481
|
+
<span class='type'>(<tt>Proc<S, U></tt>)</span>
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
—
|
486
|
+
<div class='inline'><p>is the function to modify the state <code>S</code> to <code>U</code> .
|
487
|
+
This function has an argument receiving the state.</p>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
</li>
|
491
|
+
|
492
|
+
</ul>
|
344
493
|
|
494
|
+
<p class="tag_title">Returns:</p>
|
495
|
+
<ul class="return">
|
345
496
|
|
346
|
-
|
497
|
+
<li>
|
498
|
+
|
499
|
+
|
500
|
+
<span class='type'>(<tt>()</tt>)</span>
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
</li>
|
505
|
+
|
506
|
+
</ul>
|
507
|
+
|
508
|
+
</div><table class="source_code">
|
347
509
|
<tr>
|
348
510
|
<td>
|
349
511
|
<pre class="lines">
|
350
512
|
|
351
513
|
|
352
|
-
|
353
|
-
|
354
|
-
|
514
|
+
33
|
515
|
+
34
|
516
|
+
35</pre>
|
355
517
|
</td>
|
356
518
|
<td>
|
357
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
519
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 33</span>
|
358
520
|
|
359
521
|
<span class='kw'>def</span> <span class='id identifier rubyid_modify'>modify</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span>
|
360
|
-
<span class='ivar'>@modify</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span> <span class='id identifier rubyid_fn'>fn</span>
|
522
|
+
<span class='ivar'>@eff</span><span class='period'>.</span><span class='id identifier rubyid_modify'>modify</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span> <span class='id identifier rubyid_fn'>fn</span>
|
361
523
|
<span class='kw'>end</span></pre>
|
362
524
|
</td>
|
363
525
|
</tr>
|
@@ -367,27 +529,69 @@
|
|
367
529
|
<div class="method_details ">
|
368
530
|
<h3 class="signature " id="put-instance_method">
|
369
531
|
|
370
|
-
#<strong>put</strong>(s) ⇒ <tt>
|
532
|
+
#<strong>put</strong>(s) ⇒ <tt>()</tt>
|
371
533
|
|
372
534
|
|
373
535
|
|
374
536
|
|
375
537
|
|
376
|
-
</h3><
|
538
|
+
</h3><div class="docstring">
|
539
|
+
<div class="discussion">
|
540
|
+
<p>is a short hand for <code>modify {|_| s }</code></p>
|
541
|
+
|
542
|
+
|
543
|
+
</div>
|
544
|
+
</div>
|
545
|
+
<div class="tags">
|
546
|
+
<p class="tag_title">Parameters:</p>
|
547
|
+
<ul class="param">
|
548
|
+
|
549
|
+
<li>
|
550
|
+
|
551
|
+
<span class='name'>s</span>
|
552
|
+
|
553
|
+
|
554
|
+
<span class='type'>(<tt>S</tt>)</span>
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
—
|
559
|
+
<div class='inline'><p>is the new state.</p>
|
560
|
+
</div>
|
561
|
+
|
562
|
+
</li>
|
563
|
+
|
564
|
+
</ul>
|
565
|
+
|
566
|
+
<p class="tag_title">Returns:</p>
|
567
|
+
<ul class="return">
|
568
|
+
|
569
|
+
<li>
|
570
|
+
|
571
|
+
|
572
|
+
<span class='type'>(<tt>()</tt>)</span>
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
</li>
|
577
|
+
|
578
|
+
</ul>
|
579
|
+
|
580
|
+
</div><table class="source_code">
|
377
581
|
<tr>
|
378
582
|
<td>
|
379
583
|
<pre class="lines">
|
380
584
|
|
381
585
|
|
382
|
-
|
383
|
-
|
384
|
-
|
586
|
+
41
|
587
|
+
42
|
588
|
+
43</pre>
|
385
589
|
</td>
|
386
590
|
<td>
|
387
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
591
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 41</span>
|
388
592
|
|
389
593
|
<span class='kw'>def</span> <span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span>
|
390
|
-
<span class='ivar'>@modify</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid__'>_</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_s'>s</span> <span class='rbrace'>}</span>
|
594
|
+
<span class='ivar'>@eff</span><span class='period'>.</span><span class='id identifier rubyid_modify'>modify</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid__'>_</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_s'>s</span> <span class='rbrace'>}</span>
|
391
595
|
<span class='kw'>end</span></pre>
|
392
596
|
</td>
|
393
597
|
</tr>
|
@@ -397,27 +601,75 @@
|
|
397
601
|
<div class="method_details ">
|
398
602
|
<h3 class="signature " id="with-instance_method">
|
399
603
|
|
400
|
-
#<strong>with</strong>(&
|
604
|
+
#<strong>with</strong>(&th) ⇒ <tt>A!{e}</tt>
|
401
605
|
|
402
606
|
|
403
607
|
|
404
608
|
|
405
609
|
|
406
|
-
</h3><
|
610
|
+
</h3><div class="docstring">
|
611
|
+
<div class="discussion">
|
612
|
+
<p>is a short hand for <code>with_init(nil, th)</code> .</p>
|
613
|
+
|
614
|
+
|
615
|
+
</div>
|
616
|
+
</div>
|
617
|
+
<div class="tags">
|
618
|
+
<p class="tag_title">Parameters:</p>
|
619
|
+
<ul class="param">
|
620
|
+
|
621
|
+
<li>
|
622
|
+
|
623
|
+
<span class='name'>th</span>
|
624
|
+
|
625
|
+
|
626
|
+
<span class='type'>(<tt>Proc<(), A!{<span class='object_link'><a href="../State.html" title="Ruff::Standard::State (module)">State</a></span>.<span class='object_link'><a href="#get-instance_method" title="Ruff::Standard::State::Instance#get (method)">get</a></span>, <span class='object_link'><a href="../State.html" title="Ruff::Standard::State (module)">State</a></span>.<span class='object_link'><a href="#modify-instance_method" title="Ruff::Standard::State::Instance#modify (method)">modify</a></span>,, e}></tt>)</span>
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
—
|
631
|
+
<div class='inline'><p>is a thunk returning <code>A</code> with the possibility to invoke effects,
|
632
|
+
including <code>State.get</code> and <code>State.modify</code> .</p>
|
633
|
+
</div>
|
634
|
+
|
635
|
+
</li>
|
636
|
+
|
637
|
+
</ul>
|
638
|
+
|
639
|
+
<p class="tag_title">Returns:</p>
|
640
|
+
<ul class="return">
|
641
|
+
|
642
|
+
<li>
|
643
|
+
|
644
|
+
|
645
|
+
<span class='type'>(<tt>A!{e}</tt>)</span>
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
—
|
650
|
+
<div class='inline'><p>returns <code>A</code> , without modification by value handler.
|
651
|
+
But it still has the possibility to invoke effects(<code>e</code>).</p>
|
652
|
+
</div>
|
653
|
+
|
654
|
+
</li>
|
655
|
+
|
656
|
+
</ul>
|
657
|
+
|
658
|
+
</div><table class="source_code">
|
407
659
|
<tr>
|
408
660
|
<td>
|
409
661
|
<pre class="lines">
|
410
662
|
|
411
663
|
|
412
|
-
|
413
|
-
|
414
|
-
|
664
|
+
78
|
665
|
+
79
|
666
|
+
80</pre>
|
415
667
|
</td>
|
416
668
|
<td>
|
417
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
669
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 78</span>
|
418
670
|
|
419
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier
|
420
|
-
<span class='id identifier rubyid_with_init'>with_init</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier
|
671
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_th'>th</span><span class='rparen'>)</span>
|
672
|
+
<span class='id identifier rubyid_with_init'>with_init</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_th'>th</span><span class='rparen'>)</span>
|
421
673
|
<span class='kw'>end</span></pre>
|
422
674
|
</td>
|
423
675
|
</tr>
|
@@ -427,47 +679,112 @@
|
|
427
679
|
<div class="method_details ">
|
428
680
|
<h3 class="signature " id="with_init-instance_method">
|
429
681
|
|
430
|
-
#<strong>with_init</strong>(init, &
|
682
|
+
#<strong>with_init</strong>(init, &th) ⇒ <tt>A!{e}</tt>
|
683
|
+
|
684
|
+
|
431
685
|
|
432
686
|
|
433
687
|
|
688
|
+
</h3><div class="docstring">
|
689
|
+
<div class="discussion">
|
690
|
+
<p>is a handler to interpret the effect invocations like <em>state monad</em> .</p>
|
691
|
+
|
434
692
|
|
693
|
+
</div>
|
694
|
+
</div>
|
695
|
+
<div class="tags">
|
696
|
+
<p class="tag_title">Parameters:</p>
|
697
|
+
<ul class="param">
|
435
698
|
|
436
|
-
|
699
|
+
<li>
|
700
|
+
|
701
|
+
<span class='name'>init</span>
|
702
|
+
|
703
|
+
|
704
|
+
<span class='type'>(<tt>S</tt>)</span>
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
—
|
709
|
+
<div class='inline'><p>is the initial state.</p>
|
710
|
+
</div>
|
711
|
+
|
712
|
+
</li>
|
713
|
+
|
714
|
+
<li>
|
715
|
+
|
716
|
+
<span class='name'>th</span>
|
717
|
+
|
718
|
+
|
719
|
+
<span class='type'>(<tt>Proc<(), A!{<span class='object_link'><a href="../State.html" title="Ruff::Standard::State (module)">State</a></span>.<span class='object_link'><a href="#get-instance_method" title="Ruff::Standard::State::Instance#get (method)">get</a></span>, <span class='object_link'><a href="../State.html" title="Ruff::Standard::State (module)">State</a></span>.<span class='object_link'><a href="#modify-instance_method" title="Ruff::Standard::State::Instance#modify (method)">modify</a></span>,, e}></tt>)</span>
|
720
|
+
|
721
|
+
|
722
|
+
|
723
|
+
—
|
724
|
+
<div class='inline'><p>is a thunk returning <code>A</code> with the possibility to invoke effects,
|
725
|
+
including <code>State.get</code> and <code>State.modify</code> .</p>
|
726
|
+
</div>
|
727
|
+
|
728
|
+
</li>
|
729
|
+
|
730
|
+
</ul>
|
731
|
+
|
732
|
+
<p class="tag_title">Returns:</p>
|
733
|
+
<ul class="return">
|
734
|
+
|
735
|
+
<li>
|
736
|
+
|
737
|
+
|
738
|
+
<span class='type'>(<tt>A!{e}</tt>)</span>
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
—
|
743
|
+
<div class='inline'><p>returns <code>A</code> , without modification by value handler.
|
744
|
+
But it still has the possibility to invoke effects(<code>e</code>).</p>
|
745
|
+
</div>
|
746
|
+
|
747
|
+
</li>
|
748
|
+
|
749
|
+
</ul>
|
750
|
+
|
751
|
+
</div><table class="source_code">
|
437
752
|
<tr>
|
438
753
|
<td>
|
439
754
|
<pre class="lines">
|
440
755
|
|
441
756
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
757
|
+
55
|
758
|
+
56
|
759
|
+
57
|
760
|
+
58
|
761
|
+
59
|
762
|
+
60
|
763
|
+
61
|
764
|
+
62
|
765
|
+
63
|
766
|
+
64
|
767
|
+
65
|
768
|
+
66
|
769
|
+
67
|
770
|
+
68</pre>
|
455
771
|
</td>
|
456
772
|
<td>
|
457
|
-
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line
|
773
|
+
<pre class="code"><span class="info file"># File 'lib/ruff/standard/state.rb', line 55</span>
|
458
774
|
|
459
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_with_init'>with_init</span><span class='lparen'>(</span><span class='id identifier rubyid_init'>init</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier
|
460
|
-
<span class='
|
775
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_with_init'>with_init</span><span class='lparen'>(</span><span class='id identifier rubyid_init'>init</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_th'>th</span><span class='rparen'>)</span>
|
776
|
+
<span class='comment'># not a parameter passing style, or so-called *pure* implementation,
|
777
|
+
</span> <span class='comment'># just using mutable assignment
|
778
|
+
</span> <span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_init'>init</span>
|
461
779
|
|
462
780
|
<span class='const'><span class='object_link'><a href="../../../Ruff.html" title="Ruff (module)">Ruff</a></span></span><span class='period'>.</span><span class='id identifier rubyid_handler'><span class='object_link'><a href="../../../Ruff.html#handler-class_method" title="Ruff.handler (method)">handler</a></span></span>
|
463
|
-
<span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='ivar'>@modify</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_fn'>fn</span><span class='op'>|</span>
|
781
|
+
<span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='ivar'>@eff</span><span class='period'>.</span><span class='id identifier rubyid_modify'>modify</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_fn'>fn</span><span class='op'>|</span>
|
464
782
|
<span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_fn'>fn</span><span class='lbracket'>[</span><span class='id identifier rubyid_state'>state</span><span class='rbracket'>]</span>
|
465
783
|
<span class='id identifier rubyid_k'>k</span><span class='lbracket'>[</span><span class='kw'>nil</span><span class='rbracket'>]</span>
|
466
|
-
<span class='kw'>end</span>
|
467
|
-
<span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='ivar'>@get</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span>
|
784
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='ivar'>@eff</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span>
|
468
785
|
<span class='id identifier rubyid_k'>k</span><span class='lbracket'>[</span><span class='id identifier rubyid_state'>state</span><span class='rbracket'>]</span>
|
469
786
|
<span class='kw'>end</span>
|
470
|
-
<span class='period'>.</span><span class='id identifier rubyid_run'>run</span>
|
787
|
+
<span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_th'>th</span><span class='rparen'>)</span>
|
471
788
|
<span class='kw'>end</span></pre>
|
472
789
|
</td>
|
473
790
|
</tr>
|
@@ -479,7 +796,7 @@
|
|
479
796
|
</div>
|
480
797
|
|
481
798
|
<div id="footer">
|
482
|
-
Generated on
|
799
|
+
Generated on Fri Oct 4 13:57:07 2019 by
|
483
800
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
484
801
|
0.9.20 (ruby-2.6.4).
|
485
802
|
</div>
|