mangrove 0.9.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -237,6 +237,14 @@
237
237
 
238
238
 
239
239
  <li class="odd ">
240
+ <div class="item">
241
+ <span class='object_link'><a href="Mangrove/Option.html#from_nilable-class_method" title="Mangrove::Option.from_nilable (method)">from_nilable</a></span>
242
+ <small>Mangrove::Option</small>
243
+ </div>
244
+ </li>
245
+
246
+
247
+ <li class="even ">
240
248
  <div class="item">
241
249
  <span class='object_link'><a href="Mangrove/Result.html#from_results-class_method" title="Mangrove::Result.from_results (method)">from_results</a></span>
242
250
  <small>Mangrove::Result</small>
@@ -244,7 +252,7 @@
244
252
  </li>
245
253
 
246
254
 
247
- <li class="even ">
255
+ <li class="odd ">
248
256
  <div class="item">
249
257
  <span class='object_link'><a href="Mangrove/Option/Some.html#initialize-instance_method" title="Mangrove::Option::Some#initialize (method)">#initialize</a></span>
250
258
  <small>Mangrove::Option::Some</small>
@@ -252,7 +260,7 @@
252
260
  </li>
253
261
 
254
262
 
255
- <li class="odd ">
263
+ <li class="even ">
256
264
  <div class="item">
257
265
  <span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">#initialize</a></span>
258
266
  <small>Mangrove::Result::Ok</small>
@@ -260,7 +268,7 @@
260
268
  </li>
261
269
 
262
270
 
263
- <li class="even ">
271
+ <li class="odd ">
264
272
  <div class="item">
265
273
  <span class='object_link'><a href="Mangrove/Result/Err.html#initialize-instance_method" title="Mangrove::Result::Err#initialize (method)">#initialize</a></span>
266
274
  <small>Mangrove::Result::Err</small>
@@ -268,7 +276,7 @@
268
276
  </li>
269
277
 
270
278
 
271
- <li class="odd ">
279
+ <li class="even ">
272
280
  <div class="item">
273
281
  <span class='object_link'><a href="Mangrove/Option/ControlSignal.html#initialize-instance_method" title="Mangrove::Option::ControlSignal#initialize (method)">#initialize</a></span>
274
282
  <small>Mangrove::Option::ControlSignal</small>
@@ -276,7 +284,7 @@
276
284
  </li>
277
285
 
278
286
 
279
- <li class="even ">
287
+ <li class="odd ">
280
288
  <div class="item">
281
289
  <span class='object_link'><a href="Mangrove/Result/ControlSignal.html#initialize-instance_method" title="Mangrove::Result::ControlSignal#initialize (method)">#initialize</a></span>
282
290
  <small>Mangrove::Result::ControlSignal</small>
@@ -284,7 +292,7 @@
284
292
  </li>
285
293
 
286
294
 
287
- <li class="odd ">
295
+ <li class="even ">
288
296
  <div class="item">
289
297
  <span class='object_link'><a href="Mangrove/Option/ControlSignal.html#inner_value-instance_method" title="Mangrove::Option::ControlSignal#inner_value (method)">#inner_value</a></span>
290
298
  <small>Mangrove::Option::ControlSignal</small>
@@ -292,7 +300,7 @@
292
300
  </li>
293
301
 
294
302
 
295
- <li class="even ">
303
+ <li class="odd ">
296
304
  <div class="item">
297
305
  <span class='object_link'><a href="Mangrove/Result/ControlSignal.html#inner_value-instance_method" title="Mangrove::Result::ControlSignal#inner_value (method)">#inner_value</a></span>
298
306
  <small>Mangrove::Result::ControlSignal</small>
@@ -300,7 +308,7 @@
300
308
  </li>
301
309
 
302
310
 
303
- <li class="odd ">
311
+ <li class="even ">
304
312
  <div class="item">
305
313
  <span class='object_link'><a href="Mangrove/ControlFlow/ControlSignal.html#inner_value-instance_method" title="Mangrove::ControlFlow::ControlSignal#inner_value (method)">#inner_value</a></span>
306
314
  <small>Mangrove::ControlFlow::ControlSignal</small>
@@ -308,33 +316,9 @@
308
316
  </li>
309
317
 
310
318
 
311
- <li class="even ">
312
- <div class="item">
313
- <span class='object_link'><a href="Mangrove/Result.html#map_err-instance_method" title="Mangrove::Result#map_err (method)">#map_err</a></span>
314
- <small>Mangrove::Result</small>
315
- </div>
316
- </li>
317
-
318
-
319
319
  <li class="odd ">
320
320
  <div class="item">
321
- <span class='object_link'><a href="Mangrove/Result/Ok.html#map_err-instance_method" title="Mangrove::Result::Ok#map_err (method)">#map_err</a></span>
322
- <small>Mangrove::Result::Ok</small>
323
- </div>
324
- </li>
325
-
326
-
327
- <li class="even ">
328
- <div class="item">
329
- <span class='object_link'><a href="Mangrove/Result/Err.html#map_err-instance_method" title="Mangrove::Result::Err#map_err (method)">#map_err</a></span>
330
- <small>Mangrove::Result::Err</small>
331
- </div>
332
- </li>
333
-
334
-
335
- <li class="odd ">
336
- <div class="item">
337
- <span class='object_link'><a href="Mangrove/Option/Some.html#map_none-instance_method" title="Mangrove::Option::Some#map_none (method)">#map_none</a></span>
321
+ <span class='object_link'><a href="Mangrove/Option/Some.html#map-instance_method" title="Mangrove::Option::Some#map (method)">#map</a></span>
338
322
  <small>Mangrove::Option::Some</small>
339
323
  </div>
340
324
  </li>
@@ -342,7 +326,7 @@
342
326
 
343
327
  <li class="even ">
344
328
  <div class="item">
345
- <span class='object_link'><a href="Mangrove/Option/None.html#map_none-instance_method" title="Mangrove::Option::None#map_none (method)">#map_none</a></span>
329
+ <span class='object_link'><a href="Mangrove/Option/None.html#map-instance_method" title="Mangrove::Option::None#map (method)">#map</a></span>
346
330
  <small>Mangrove::Option::None</small>
347
331
  </div>
348
332
  </li>
@@ -350,7 +334,7 @@
350
334
 
351
335
  <li class="odd ">
352
336
  <div class="item">
353
- <span class='object_link'><a href="Mangrove/Option.html#map_none-instance_method" title="Mangrove::Option#map_none (method)">#map_none</a></span>
337
+ <span class='object_link'><a href="Mangrove/Option.html#map-instance_method" title="Mangrove::Option#map (method)">#map</a></span>
354
338
  <small>Mangrove::Option</small>
355
339
  </div>
356
340
  </li>
@@ -358,7 +342,7 @@
358
342
 
359
343
  <li class="even ">
360
344
  <div class="item">
361
- <span class='object_link'><a href="Mangrove/Result.html#map_ok-instance_method" title="Mangrove::Result#map_ok (method)">#map_ok</a></span>
345
+ <span class='object_link'><a href="Mangrove/Result.html#map_err-instance_method" title="Mangrove::Result#map_err (method)">#map_err</a></span>
362
346
  <small>Mangrove::Result</small>
363
347
  </div>
364
348
  </li>
@@ -366,7 +350,7 @@
366
350
 
367
351
  <li class="odd ">
368
352
  <div class="item">
369
- <span class='object_link'><a href="Mangrove/Result/Ok.html#map_ok-instance_method" title="Mangrove::Result::Ok#map_ok (method)">#map_ok</a></span>
353
+ <span class='object_link'><a href="Mangrove/Result/Ok.html#map_err-instance_method" title="Mangrove::Result::Ok#map_err (method)">#map_err</a></span>
370
354
  <small>Mangrove::Result::Ok</small>
371
355
  </div>
372
356
  </li>
@@ -374,7 +358,7 @@
374
358
 
375
359
  <li class="even ">
376
360
  <div class="item">
377
- <span class='object_link'><a href="Mangrove/Result/Err.html#map_ok-instance_method" title="Mangrove::Result::Err#map_ok (method)">#map_ok</a></span>
361
+ <span class='object_link'><a href="Mangrove/Result/Err.html#map_err-instance_method" title="Mangrove::Result::Err#map_err (method)">#map_err</a></span>
378
362
  <small>Mangrove::Result::Err</small>
379
363
  </div>
380
364
  </li>
@@ -382,24 +366,24 @@
382
366
 
383
367
  <li class="odd ">
384
368
  <div class="item">
385
- <span class='object_link'><a href="Mangrove/Option/Some.html#map_some-instance_method" title="Mangrove::Option::Some#map_some (method)">#map_some</a></span>
386
- <small>Mangrove::Option::Some</small>
369
+ <span class='object_link'><a href="Mangrove/Result.html#map_ok-instance_method" title="Mangrove::Result#map_ok (method)">#map_ok</a></span>
370
+ <small>Mangrove::Result</small>
387
371
  </div>
388
372
  </li>
389
373
 
390
374
 
391
375
  <li class="even ">
392
376
  <div class="item">
393
- <span class='object_link'><a href="Mangrove/Option/None.html#map_some-instance_method" title="Mangrove::Option::None#map_some (method)">#map_some</a></span>
394
- <small>Mangrove::Option::None</small>
377
+ <span class='object_link'><a href="Mangrove/Result/Ok.html#map_ok-instance_method" title="Mangrove::Result::Ok#map_ok (method)">#map_ok</a></span>
378
+ <small>Mangrove::Result::Ok</small>
395
379
  </div>
396
380
  </li>
397
381
 
398
382
 
399
383
  <li class="odd ">
400
384
  <div class="item">
401
- <span class='object_link'><a href="Mangrove/Option.html#map_some-instance_method" title="Mangrove::Option#map_some (method)">#map_some</a></span>
402
- <small>Mangrove::Option</small>
385
+ <span class='object_link'><a href="Mangrove/Result/Err.html#map_ok-instance_method" title="Mangrove::Result::Err#map_ok (method)">#map_ok</a></span>
386
+ <small>Mangrove::Result::Err</small>
403
387
  </div>
404
388
  </li>
405
389
 
@@ -462,7 +446,7 @@
462
446
 
463
447
  <li class="odd ">
464
448
  <div class="item">
465
- <span class='object_link'><a href="Mangrove/Option/Some.html#some%3F-instance_method" title="Mangrove::Option::Some#some? (method)">#some?</a></span>
449
+ <span class='object_link'><a href="Mangrove/Option/Some.html#or-instance_method" title="Mangrove::Option::Some#or (method)">#or</a></span>
466
450
  <small>Mangrove::Option::Some</small>
467
451
  </div>
468
452
  </li>
@@ -470,7 +454,7 @@
470
454
 
471
455
  <li class="even ">
472
456
  <div class="item">
473
- <span class='object_link'><a href="Mangrove/Option/None.html#some%3F-instance_method" title="Mangrove::Option::None#some? (method)">#some?</a></span>
457
+ <span class='object_link'><a href="Mangrove/Option/None.html#or-instance_method" title="Mangrove::Option::None#or (method)">#or</a></span>
474
458
  <small>Mangrove::Option::None</small>
475
459
  </div>
476
460
  </li>
@@ -478,13 +462,37 @@
478
462
 
479
463
  <li class="odd ">
480
464
  <div class="item">
481
- <span class='object_link'><a href="Mangrove/Option.html#some%3F-instance_method" title="Mangrove::Option#some? (method)">#some?</a></span>
465
+ <span class='object_link'><a href="Mangrove/Option.html#or-instance_method" title="Mangrove::Option#or (method)">#or</a></span>
482
466
  <small>Mangrove::Option</small>
483
467
  </div>
484
468
  </li>
485
469
 
486
470
 
487
471
  <li class="even ">
472
+ <div class="item">
473
+ <span class='object_link'><a href="Mangrove/Option/Some.html#some%3F-instance_method" title="Mangrove::Option::Some#some? (method)">#some?</a></span>
474
+ <small>Mangrove::Option::Some</small>
475
+ </div>
476
+ </li>
477
+
478
+
479
+ <li class="odd ">
480
+ <div class="item">
481
+ <span class='object_link'><a href="Mangrove/Option/None.html#some%3F-instance_method" title="Mangrove::Option::None#some? (method)">#some?</a></span>
482
+ <small>Mangrove::Option::None</small>
483
+ </div>
484
+ </li>
485
+
486
+
487
+ <li class="even ">
488
+ <div class="item">
489
+ <span class='object_link'><a href="Mangrove/Option.html#some%3F-instance_method" title="Mangrove::Option#some? (method)">#some?</a></span>
490
+ <small>Mangrove::Option</small>
491
+ </div>
492
+ </li>
493
+
494
+
495
+ <li class="odd ">
488
496
  <div class="item">
489
497
  <span class='object_link'><a href="Mangrove/Result/Ok.html#to_s-instance_method" title="Mangrove::Result::Ok#to_s (method)">#to_s</a></span>
490
498
  <small>Mangrove::Result::Ok</small>
@@ -492,7 +500,7 @@
492
500
  </li>
493
501
 
494
502
 
495
- <li class="odd ">
503
+ <li class="even ">
496
504
  <div class="item">
497
505
  <span class='object_link'><a href="Mangrove/Result/Err.html#to_s-instance_method" title="Mangrove::Result::Err#to_s (method)">#to_s</a></span>
498
506
  <small>Mangrove::Result::Err</small>
@@ -500,7 +508,7 @@
500
508
  </li>
501
509
 
502
510
 
503
- <li class="even ">
511
+ <li class="odd ">
504
512
  <div class="item">
505
513
  <span class='object_link'><a href="Mangrove/Option/Some.html#transpose-instance_method" title="Mangrove::Option::Some#transpose (method)">#transpose</a></span>
506
514
  <small>Mangrove::Option::Some</small>
@@ -508,7 +516,7 @@
508
516
  </li>
509
517
 
510
518
 
511
- <li class="odd ">
519
+ <li class="even ">
512
520
  <div class="item">
513
521
  <span class='object_link'><a href="Mangrove/Option/None.html#transpose-instance_method" title="Mangrove::Option::None#transpose (method)">#transpose</a></span>
514
522
  <small>Mangrove::Option::None</small>
@@ -516,7 +524,7 @@
516
524
  </li>
517
525
 
518
526
 
519
- <li class="even ">
527
+ <li class="odd ">
520
528
  <div class="item">
521
529
  <span class='object_link'><a href="Mangrove/Option.html#transpose-instance_method" title="Mangrove::Option#transpose (method)">#transpose</a></span>
522
530
  <small>Mangrove::Option</small>
@@ -524,7 +532,7 @@
524
532
  </li>
525
533
 
526
534
 
527
- <li class="odd ">
535
+ <li class="even ">
528
536
  <div class="item">
529
537
  <span class='object_link'><a href="Mangrove/Option/Some.html#unwrap-instance_method" title="Mangrove::Option::Some#unwrap (method)">#unwrap</a></span>
530
538
  <small>Mangrove::Option::Some</small>
@@ -532,7 +540,7 @@
532
540
  </li>
533
541
 
534
542
 
535
- <li class="even ">
543
+ <li class="odd ">
536
544
  <div class="item">
537
545
  <span class='object_link'><a href="Mangrove/Option/Some.html#unwrap!-instance_method" title="Mangrove::Option::Some#unwrap! (method)">#unwrap!</a></span>
538
546
  <small>Mangrove::Option::Some</small>
@@ -540,7 +548,7 @@
540
548
  </li>
541
549
 
542
550
 
543
- <li class="odd ">
551
+ <li class="even ">
544
552
  <div class="item">
545
553
  <span class='object_link'><a href="Mangrove/Option/None.html#unwrap!-instance_method" title="Mangrove::Option::None#unwrap! (method)">#unwrap!</a></span>
546
554
  <small>Mangrove::Option::None</small>
@@ -548,7 +556,7 @@
548
556
  </li>
549
557
 
550
558
 
551
- <li class="even ">
559
+ <li class="odd ">
552
560
  <div class="item">
553
561
  <span class='object_link'><a href="Mangrove/Option.html#unwrap!-instance_method" title="Mangrove::Option#unwrap! (method)">#unwrap!</a></span>
554
562
  <small>Mangrove::Option</small>
@@ -556,7 +564,7 @@
556
564
  </li>
557
565
 
558
566
 
559
- <li class="odd ">
567
+ <li class="even ">
560
568
  <div class="item">
561
569
  <span class='object_link'><a href="Mangrove/Result.html#unwrap!-instance_method" title="Mangrove::Result#unwrap! (method)">#unwrap!</a></span>
562
570
  <small>Mangrove::Result</small>
@@ -564,7 +572,7 @@
564
572
  </li>
565
573
 
566
574
 
567
- <li class="even ">
575
+ <li class="odd ">
568
576
  <div class="item">
569
577
  <span class='object_link'><a href="Mangrove/Result/Ok.html#unwrap!-instance_method" title="Mangrove::Result::Ok#unwrap! (method)">#unwrap!</a></span>
570
578
  <small>Mangrove::Result::Ok</small>
@@ -572,7 +580,7 @@
572
580
  </li>
573
581
 
574
582
 
575
- <li class="odd ">
583
+ <li class="even ">
576
584
  <div class="item">
577
585
  <span class='object_link'><a href="Mangrove/Result/Err.html#unwrap!-instance_method" title="Mangrove::Result::Err#unwrap! (method)">#unwrap!</a></span>
578
586
  <small>Mangrove::Result::Err</small>
@@ -580,7 +588,7 @@
580
588
  </li>
581
589
 
582
590
 
583
- <li class="even ">
591
+ <li class="odd ">
584
592
  <div class="item">
585
593
  <span class='object_link'><a href="Mangrove/Option/Some.html#unwrap_or-instance_method" title="Mangrove::Option::Some#unwrap_or (method)">#unwrap_or</a></span>
586
594
  <small>Mangrove::Option::Some</small>
@@ -588,7 +596,7 @@
588
596
  </li>
589
597
 
590
598
 
591
- <li class="odd ">
599
+ <li class="even ">
592
600
  <div class="item">
593
601
  <span class='object_link'><a href="Mangrove/Option/None.html#unwrap_or-instance_method" title="Mangrove::Option::None#unwrap_or (method)">#unwrap_or</a></span>
594
602
  <small>Mangrove::Option::None</small>
@@ -596,7 +604,7 @@
596
604
  </li>
597
605
 
598
606
 
599
- <li class="even ">
607
+ <li class="odd ">
600
608
  <div class="item">
601
609
  <span class='object_link'><a href="Mangrove/Option.html#unwrap_or-instance_method" title="Mangrove::Option#unwrap_or (method)">#unwrap_or</a></span>
602
610
  <small>Mangrove::Option</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Tue Oct 24 12:49:57 2023 by
103
+ Generated on Tue Oct 24 20:35:17 2023 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.34 (ruby-3.1.2).
106
106
  </div>
@@ -18,6 +18,20 @@ module Mangrove
18
18
 
19
19
  InnerType = type_member
20
20
 
21
+ class << self
22
+ extend ::T::Sig
23
+
24
+ sig { type_parameters(:InnerType).params(nilable: T.nilable(T.type_parameter(:InnerType))).returns(Mangrove::Option[T.type_parameter(:InnerType)]) }
25
+ def from_nilable(nilable)
26
+ case nilable
27
+ when NilClass
28
+ Mangrove::Option::None.new
29
+ else
30
+ Mangrove::Option::Some.new(nilable)
31
+ end
32
+ end
33
+ end
34
+
21
35
  # Option::Some
22
36
  class Some
23
37
  extend T::Sig
@@ -77,13 +91,13 @@ module Mangrove
77
91
  sig { override.returns(T::Boolean) }
78
92
  def none? = false
79
93
 
80
- sig { override.params(block: T.proc.params(inner: InnerType).returns(Option[InnerType])).returns(Option[InnerType]) }
81
- def map_some(&block)
94
+ sig { override.type_parameters(:NewInnerType).params(block: T.proc.params(inner: InnerType).returns(Option[T.type_parameter(:NewInnerType)])).returns(::Mangrove::Option[T.type_parameter(:NewInnerType)]) }
95
+ def map(&block)
82
96
  block.call(@inner)
83
97
  end
84
98
 
85
- sig { override.params(_block: T.proc.returns(Option[InnerType])).returns(Option::Some[InnerType]) }
86
- def map_none(&_block)
99
+ sig { override.params(_default: Option[InnerType]).returns(Option[InnerType]) }
100
+ def or(_default)
87
101
  self
88
102
  end
89
103
 
@@ -147,14 +161,14 @@ module Mangrove
147
161
  sig { override.returns(T::Boolean) }
148
162
  def none? = true
149
163
 
150
- sig { override.params(_block: T.proc.params(inner: InnerType).returns(Option[InnerType])).returns(Option::None[InnerType]) }
151
- def map_some(&_block)
152
- self
164
+ sig { override.type_parameters(:NewInnerType).params(_block: T.proc.params(inner: InnerType).returns(Option[T.type_parameter(:NewInnerType)])).returns(Option[T.type_parameter(:NewInnerType)]) }
165
+ def map(&_block)
166
+ T.cast(self, Option[T.type_parameter(:NewInnerType)])
153
167
  end
154
168
 
155
- sig { override.params(block: T.proc.returns(Option[InnerType])).returns(Option[InnerType]) }
156
- def map_none(&block)
157
- block.call
169
+ sig { override.params(default: Option[InnerType]).returns(Option[InnerType]) }
170
+ def or(default)
171
+ default
158
172
  end
159
173
 
160
174
  sig { override.type_parameters(:ErrType).params(err: T.type_parameter(:ErrType)).returns(Mangrove::Result[InnerType, T.type_parameter(:ErrType)]) }
@@ -184,11 +198,11 @@ module Mangrove
184
198
  sig { abstract.returns(T::Boolean) }
185
199
  def none?; end
186
200
 
187
- sig { abstract.params(block: T.proc.params(inner: InnerType).returns(Option[InnerType])).returns(Option[InnerType]) }
188
- def map_some(&block); end
201
+ sig { abstract.type_parameters(:NewInnerType).params(block: T.proc.params(inner: InnerType).returns(Option[T.type_parameter(:NewInnerType)])).returns(::Mangrove::Option[T.type_parameter(:NewInnerType)]) }
202
+ def map(&block); end
189
203
 
190
- sig { abstract.params(block: T.proc.returns(Option[InnerType])).returns(Option[InnerType]) }
191
- def map_none(&block); end
204
+ sig { abstract.params(default: Option[InnerType]).returns(Option[InnerType]) }
205
+ def or(default); end
192
206
 
193
207
  sig { abstract.type_parameters(:ErrType).params(err: T.type_parameter(:ErrType)).returns(Mangrove::Result[InnerType, T.type_parameter(:ErrType)]) }
194
208
  def transpose(err); end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Mangrove
5
- VERSION = "0.9.2"
5
+ VERSION = "0.11.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangrove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuma Murata