dry-monads 1.3.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +161 -80
  3. data/LICENSE +1 -1
  4. data/README.md +5 -4
  5. data/dry-monads.gemspec +30 -30
  6. data/lib/dry/monads/all.rb +2 -3
  7. data/lib/dry/monads/constants.rb +0 -2
  8. data/lib/dry/monads/curry.rb +2 -2
  9. data/lib/dry/monads/do/all.rb +35 -18
  10. data/lib/dry/monads/do.rb +48 -20
  11. data/lib/dry/monads/errors.rb +8 -5
  12. data/lib/dry/monads/lazy.rb +13 -5
  13. data/lib/dry/monads/list.rb +27 -37
  14. data/lib/dry/monads/maybe.rb +85 -26
  15. data/lib/dry/monads/registry.rb +20 -20
  16. data/lib/dry/monads/result/fixed.rb +31 -24
  17. data/lib/dry/monads/result.rb +37 -19
  18. data/lib/dry/monads/right_biased.rb +38 -31
  19. data/lib/dry/monads/task.rb +25 -28
  20. data/lib/dry/monads/transformer.rb +2 -1
  21. data/lib/dry/monads/traverse.rb +5 -1
  22. data/lib/dry/monads/try.rb +45 -18
  23. data/lib/dry/monads/unit.rb +9 -3
  24. data/lib/dry/monads/validated.rb +18 -18
  25. data/lib/dry/monads/version.rb +1 -1
  26. data/lib/dry/monads.rb +25 -4
  27. data/lib/dry-monads.rb +1 -1
  28. data/lib/json/add/dry/monads/maybe.rb +5 -5
  29. metadata +22 -68
  30. data/.codeclimate.yml +0 -12
  31. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
  32. data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
  33. data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
  34. data/.github/workflows/ci.yml +0 -52
  35. data/.github/workflows/docsite.yml +0 -34
  36. data/.github/workflows/sync_configs.yml +0 -56
  37. data/.gitignore +0 -10
  38. data/.rspec +0 -4
  39. data/.rubocop.yml +0 -101
  40. data/.yardopts +0 -4
  41. data/CODE_OF_CONDUCT.md +0 -13
  42. data/CONTRIBUTING.md +0 -29
  43. data/Gemfile +0 -19
  44. data/Gemfile.devtools +0 -14
  45. data/Rakefile +0 -8
  46. data/bin/.gitkeep +0 -0
  47. data/bin/console +0 -17
  48. data/bin/setup +0 -7
  49. data/docsite/source/case-equality.html.md +0 -42
  50. data/docsite/source/do-notation.html.md +0 -207
  51. data/docsite/source/getting-started.html.md +0 -142
  52. data/docsite/source/index.html.md +0 -179
  53. data/docsite/source/list.html.md +0 -87
  54. data/docsite/source/maybe.html.md +0 -146
  55. data/docsite/source/pattern-matching.html.md +0 -68
  56. data/docsite/source/result.html.md +0 -190
  57. data/docsite/source/task.html.md +0 -126
  58. data/docsite/source/tracing-failures.html.md +0 -32
  59. data/docsite/source/try.html.md +0 -76
  60. data/docsite/source/unit.html.md +0 -36
  61. data/docsite/source/validated.html.md +0 -88
  62. data/lib/dry/monads/either.rb +0 -66
  63. data/log/.gitkeep +0 -0
  64. data/project.yml +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86fbad001116e7a69e01b2f7e8b0c5ee8101a95af73fd9f485880131df364749
4
- data.tar.gz: 5d3a4bf072bfcfe22edb31512a4b29b5952c7aaa674af4b1ef546dc8ce39e302
3
+ metadata.gz: 8ccc6809b903aa20a600330e62b86d8164da8394f2b7c63740d6708c73386578
4
+ data.tar.gz: a1c92edd9908da609bfe9048bf5ca1220d1f7e4c2cc894df9ea025e7df578625
5
5
  SHA512:
6
- metadata.gz: aaa55a8f21b5e84d9b4029a59733a72c4bd21ccfd76430faa4eb39c821860e774e0a94e9fddbecd66a6e0c9c876d7178dc66a2364b85851ecbf56fb8b6ac5e86
7
- data.tar.gz: 126cc641f1ba8ba33fd251e63d18668c1360eff70967f86705a333fcd01df95cc3909579a128e270629b4609179db435fdeb0de0d3a5fcdb2ef0693ccc3fcc49
6
+ metadata.gz: 9286042f25cbb89f74d7159ef238cb834f7dddc74890c7d575978a14bd69d8d95aa46728c0f7dbfa81507af068cba4f3efa871eed9ec60d95da62db6f9810320
7
+ data.tar.gz: d723b367ba2014fa7bf907316dd93cff45be330329c83281a8640aaaa480a83c20e222d8d89736caf6acc6675c61927e3e54bf0ecb1b4df73ec1d5e2999f0d9a
data/CHANGELOG.md CHANGED
@@ -1,34 +1,112 @@
1
- # v1.3.5 2020-01-06
1
+ <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- ## Added
3
+ ## 1.6.0 2022-11-04
4
+
5
+
6
+ ### Changed
7
+
8
+ - This version uses dry-core 1.0 (@flash-gordon)
9
+
10
+ [Compare v1.5.0...v1.6.0](https://github.com/dry-rb/dry-monads/compare/v1.5.0...v1.6.0)
11
+
12
+ ## 1.5.0 2022-10-16
13
+
14
+
15
+ ### Changed
16
+
17
+ - Use zeitwerk for auto-loading dry-monads classes (@flash-gordon)
18
+ - `Task#then` is deprecated in favor of `Task#bind` (@flash-gordon)
19
+ - Minimal Ruby version is now 2.7 (@flash-gordon)
20
+ - Either (old name of Result) was removed (@flash-gordon)
21
+
22
+ [Compare v1.4.0...v1.5.0](https://github.com/dry-rb/dry-monads/compare/v1.4.0...v1.5.0)
23
+
24
+ ## 1.4.0 2021-07-20
25
+
26
+
27
+ ### Added
28
+
29
+ - `Unit` destructures to an empty array (flash-gordon)
30
+ - When `.value!` called on a `Failure` value the error references to the value (rewritten + flash-gordon)
31
+ ```ruby
32
+ begin
33
+ Failure("oops").value!
34
+ rescue => error
35
+ error.receiver # => Failure("oops")
36
+ end
37
+ ```
38
+ - `Result#alt_map` for mapping failure values (flash-gordon)
39
+ ```ruby
40
+ Failure("oops").alt_map(&:upcase) # => Failure("OOPS")
41
+ ```
42
+ - `Try#recover` recovers from errors (flash-gordon)
43
+ ```ruby
44
+ error = Try { Hash.new.fetch(:missing) }
45
+ error.recover(KeyError) { 'default' } # => Try::Value("default")
46
+ ```
47
+ - `Maybe#filter` runs a predicate against the wrapped value. Returns `None` if the result is false (flash-gordon)
48
+ ```ruby
49
+ Some(3).filter(&:odd?) # => Some(3)
50
+ Some(3).filter(&:even?) # => None
51
+ # no block given
52
+ Some(3 == 5).filter # => None
53
+ ```
54
+ - `RightBiased#|` is an alias for `#or` (flash-gordon)
55
+ ```ruby
56
+ None() | Some(6) | Some(7) # => Some(6)
57
+ Failure() | Success("one") | Success("two") # => Success("one")
58
+ ```
59
+
60
+ ### Fixed
61
+
62
+ - Do notation preserves method visibility (anicholson + flash-gordon)
63
+
64
+ ### Changed
65
+
66
+ - Coercing `nil` values to `None` with `Some#fmap` is officially deprecated. (flash-gordon)
67
+ Switch to `Some#maybe` when you expect `nil`.
68
+ This behavior will be dropped in 2.0 but you can opt out of warnings for the time being
69
+ ```ruby
70
+ Dry::Monads::Maybe.warn_on_implicit_nil_coercion false
71
+ ```
72
+ - Minimal Ruby version is 2.6
73
+
74
+ [Compare v1.3.5...v1.4.0](https://github.com/dry-rb/dry-monads/compare/v1.3.5...v1.4.0)
75
+
76
+ ## 1.3.5 2020-01-06
77
+
78
+
79
+ ### Added
4
80
 
5
81
  - Smarter keys deconstruction in pattern matching (flash-gordon)
6
82
 
83
+
7
84
  [Compare v1.3.4...v1.3.5](https://github.com/dry-rb/dry-monads/compare/v1.3.4...v1.3.5)
8
85
 
9
- # v1.3.4 2019-12-28
86
+ ## 1.3.4 2019-12-28
87
+
10
88
 
11
- ## Fixed
89
+ ### Fixed
12
90
 
13
91
  - One more delegation warning happenning in do notation (flash-gordon)
14
92
 
93
+
15
94
  [Compare v1.3.3...v1.3.4](https://github.com/dry-rb/dry-monads/compare/v1.3.3...v1.3.4)
16
95
 
17
- # v1.3.3 2019-12-11
96
+ ## 1.3.3 2019-12-11
97
+
18
98
 
19
- ## Fixed
99
+ ### Fixed
20
100
 
21
101
  - Incompatibility with Rails. Internal (!) halt exceptions now use mutable backtraces because spring [mutates](https://github.com/rails/spring/blob/ee687859008e947bc905b95121e306e2948d31c9/lib/spring/application.rb#L295-L311) (!) them. For the record, this a bug in Rails (johnmaxwell)
22
102
 
23
- [Compare v1.3.2...v1.3.3](https://github.com/dry-rb/dry-monads/compare/v1.3.2...v1.3.3)
24
103
 
25
- # v1.3.2 2019-11-30
104
+ [Compare v1.3.2...v1.3.3](https://github.com/dry-rb/dry-monads/compare/v1.3.2...v1.3.3)
26
105
 
27
- ## Fixed
106
+ ## 1.3.2 2019-11-30
28
107
 
29
- - Warnings about keywords from Ruby 2.7 (flash-gordon)
30
108
 
31
- ## Added
109
+ ### Added
32
110
 
33
111
  - Pattern matching syntax was improved by implementing `#deconstruct_keys`. Now curly braces aren't necessary when the wrapped value is a Hash (flash-gordon)
34
112
  ```ruby
@@ -36,28 +114,30 @@
36
114
  in Success(code: 200...300) then :ok
37
115
  end
38
116
  ```
117
+ - ## Internal
118
+ - Performance of do notation was improved for failing cases (1.2x to 1.3x on synthetic benchmarks) (flash-gordon)
39
119
 
40
- ## Internal
120
+ ### Fixed
121
+
122
+ - Warnings about keywords from Ruby 2.7 (flash-gordon)
41
123
 
42
- - Performance of do notation was improved for failing cases (1.2x to 1.3x on synthetic benchmarks) (flash-gordon)
43
124
 
44
125
  [Compare v1.3.1...v1.3.2](https://github.com/dry-rb/dry-monads/compare/v1.3.1...v1.3.2)
45
126
 
46
- # v1.3.1 2019-09-07
127
+ ## 1.3.1 2019-09-07
47
128
 
48
- ## Fixed
129
+
130
+ ### Fixed
49
131
 
50
132
  - Added missing `None#maybe` :sweat_smile: (flash-gordon)
51
133
 
52
- [Compare v1.3.0...v1.3.1](https://github.com/dry-rb/dry-monads/compare/v1.3.0...v1.3.1)
53
134
 
54
- # v1.3.0 2019-08-03
135
+ [Compare v1.3.0...v1.3.1](https://github.com/dry-rb/dry-monads/compare/v1.3.0...v1.3.1)
55
136
 
56
- ## BREAKING CHANGES
137
+ ## 1.3.0 2019-08-03
57
138
 
58
- - Support for Ruby 2.3 was dropped.
59
139
 
60
- ## Added
140
+ ### Added
61
141
 
62
142
  - `Result#either` (waiting-for-dev)
63
143
  ```ruby
@@ -101,7 +181,6 @@
101
181
  Dry::Monads.Success(a + b)
102
182
  end
103
183
  ```
104
-
105
184
  - `{Some,Success,Failure}#[]` shortcuts for building arrays wrapped within monadic value (flash-gordon)
106
185
  ```ruby
107
186
  Success[1, 2] # => Success([1, 2])
@@ -117,7 +196,6 @@
117
196
  end
118
197
  end # => List[1, 2, 3, 4, 5]
119
198
  ```
120
-
121
199
  - Experimental support for pattern matching! :tada: (flash-gordon)
122
200
 
123
201
  ```ruby
@@ -140,15 +218,13 @@
140
218
 
141
219
  Keep in mind this feature is experimental and can be changed by 2.7 release. But it rocks already!
142
220
 
143
- [Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-monads/compare/v1.2.0...v1.3.0)
144
221
 
145
- # v1.2.0 2019-01-12
222
+ [Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-monads/compare/v1.2.0...v1.3.0)
146
223
 
147
- ## BREAKING CHANGES
224
+ ## 1.2.0 2019-01-12
148
225
 
149
- - Support for Ruby 2.2 was dropped. Ruby 2.2 reached its EOL on March 31, 2018.
150
226
 
151
- ## Added
227
+ ### Added
152
228
 
153
229
  - Most of constructors now have `call` alias so you can compose them with Procs nicely if you've switched to Ruby 2.6 (flash-gordon)
154
230
  ```ruby
@@ -177,7 +253,6 @@
177
253
  List[Some(5), None(), Some(3)].collect.map { |x| x * 2 }
178
254
  # => [10, 6]
179
255
  ```
180
-
181
256
  - Right-biased monads got `#flatten` and `#and` (falsh-gordon)
182
257
 
183
258
  `#flatten` removes one level of monadic structure, it's useful when you're dealing with things like `Maybe` of `Maybe` of something:
@@ -209,7 +284,6 @@
209
284
  Some(5).and(None()) # => None()
210
285
  None().and(Some(5)) # => None()
211
286
  ```
212
-
213
287
  - Concise imports with `Dry::Monads.[]`. You're no longer required to require all desired monads and include them one-by-one, the `[]` method handles it for you (flash-gordon)
214
288
 
215
289
  ```ruby
@@ -234,18 +308,15 @@
234
308
  end
235
309
  end
236
310
  ```
237
-
238
311
  - `Task.failed` is a counterpart of `Task.pure`, accepts an exception and returns a failed task immediately (flash-gordon)
239
312
 
240
- [Compare v1.1.0...v1.2.0](https://github.com/dry-rb/dry-monads/compare/v1.1.0...v1.2.0)
241
313
 
242
- # v1.1.0 2018-10-16
314
+ [Compare v1.1.0...v1.2.0](https://github.com/dry-rb/dry-monads/compare/v1.1.0...v1.2.0)
243
315
 
244
- ## Fixed
316
+ ## 1.1.0 2018-10-16
245
317
 
246
- - Do notation was made to work nicely with inheritance. This shouldn't break any existing code but if it does please report (flash-gordon)
247
318
 
248
- ## Added
319
+ ### Added
249
320
 
250
321
  - `Success()`, `Failure()`, and `Some()` now have `Unit` as a default argument:
251
322
 
@@ -261,26 +332,34 @@
261
332
  end
262
333
  ```
263
334
 
264
- [Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-monads/compare/v1.0.1...v1.1.0)
335
+ ### Fixed
265
336
 
266
- # v1.0.1 2018-08-11
337
+ - Do notation was made to work nicely with inheritance. This shouldn't break any existing code but if it does please report (flash-gordon)
267
338
 
268
- ## Fixed
269
339
 
270
- - Fixed behavior of `List<Validated>#traverse` in presence of `Valid` values (flash-gordon + SunnyMagadan)
340
+ [Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-monads/compare/v1.0.1...v1.1.0)
341
+
342
+ ## 1.0.1 2018-08-11
343
+
271
344
 
272
- ## Added
345
+ ### Added
273
346
 
274
347
  - `to_proc` was added to value constructors (flash-gordon)
275
348
  ```ruby
276
349
  [1, 2, 3].map(&Some) # => [Some(1), Some(2), Some(3)]
277
350
  ```
278
351
 
352
+ ### Fixed
353
+
354
+ - Fixed behavior of `List<Validated>#traverse` in presence of `Valid` values (flash-gordon + SunnyMagadan)
355
+
356
+
279
357
  [Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-monads/compare/v1.0.0...v1.0.1)
280
358
 
281
- # v1.0.0 2018-06-26
359
+ ## 1.0.0 2018-06-26
360
+
282
361
 
283
- ## Added
362
+ ### Added
284
363
 
285
364
  - `do`-like notation (the idea comes from Haskell of course). This is the biggest and most important addition to the release which greatly increases the ergonomics of using monads in Ruby. Basically, almost everything it does is passing a block to a given method. You call `yield` on monads to extract the values. If any operation fails i.e. no value can be extracted, the whole computation is halted and the failing step becomes a result. With `Do` you don't need to chain monadic values with `fmap/bind` and block, everything can be done on a single level of indentation. Here is a more or less real-life example:
286
365
 
@@ -332,7 +411,6 @@
332
411
  ```
333
412
 
334
413
  In the code above any `yield` can potentially fail and return the failure reason as a result. In other words, `yield None` acts as `return None`. Internally, `Do` uses exceptions, not `return`, this is somewhat slower but allows to detect failed operations in DB-transactions and roll back the changes which far more useful than an unjustifiable speed boost (flash-gordon)
335
-
336
414
  - The `Task` monad based on `Promise` from the [`concurrent-ruby` gem](https://github.com/ruby-concurrency/concurrent-ruby/). `Task` represents an asynchronous computation which _can be_ (doesn't have to!) run on a separated thread. `Promise` already offers a good API and implemented in a safe manner so `dry-monads` just adds a monad-compatible interface for it. Out of the box, `concurrent-ruby` has three types of executors for running blocks: `:io`, `:fast`, `:immediate`, check out [the docs](http://ruby-concurrency.github.io/concurrent-ruby/root/Concurrent.html#executor-class_method) for details. You can provide your own executor if needed (flash-gordon)
337
415
 
338
416
  ```ruby
@@ -358,9 +436,7 @@
358
436
  Success(create(e, n))
359
437
  end
360
438
  ```
361
-
362
439
  - `Lazy` is a copy of `Task` that isn't run until you ask for the value _for the first time_. It is guaranteed the evaluation is run at most once as opposed to lazy assignment `||=` which isn't synchronized. `Lazy` is run on the same thread asking for the value (flash-gordon)
363
-
364
440
  - Automatic type inference with `.typed` for lists was deprecated. Instead, typed list builders were added
365
441
 
366
442
  ```ruby
@@ -369,7 +445,6 @@
369
445
  ```
370
446
 
371
447
  The code above runs two tasks in parallel and automatically combines their results with `traverse` (flash-gordon)
372
-
373
448
  - `Try` got a new call syntax supported in Ruby 2.5+
374
449
 
375
450
  ```ruby
@@ -377,7 +452,6 @@
377
452
  ```
378
453
 
379
454
  Prior to 2.5, it wasn't possible to pass a block to `[]`.
380
-
381
455
  - The `Validated` “monad” that represents a result of a validation. Suppose, you want to collect all the errors and return them at once. You can't have it with `Result` because when you `traverse` a `List` of `Result`s it returns the first value and this is the correct behavior from the theoretical point of view. `Validated`, in fact, doesn't have a monad instance but provides a useful variant of applicative which concatenates the errors.
382
456
 
383
457
  ```ruby
@@ -401,13 +475,11 @@
401
475
  ```
402
476
 
403
477
  In the example above an array of `Validated` values is implicitly coerced to `List::Validated`. It's supported because it's useful but don't forget it's all about types so don't mix different types of monads in a single array, the consequences are unclear. You always can be explicit with `List::Validated[validate_name(...), ...]`, choose what you like (flash-gordon).
404
-
405
478
  - `Failure`, `None`, and `Invalid` values now store the line where they were created. One of the biggest downsides of dealing with monadic code is lack of backtraces. If you have a long list of computations and one of them fails how do you know where did it actually happen? Say, you've got `None` and this tells you nothing about _what variable_ was assigned to `None`. It makes sense to use `Result` instead of `Maybe` and use distinct errors everywhere but it doesn't always look good and forces you to think more. TLDR; call `.trace` to get the line where a fail-case was constructed
406
479
 
407
480
  ```ruby
408
481
  Failure(:invalid_name).trace # => app/operations/create_user.rb:43
409
482
  ```
410
-
411
483
  - `Dry::Monads::Unit` which can be used as a replacement for `Success(nil)` and in similar situations when you have side effects yet doesn't return anything meaningful as a result. There's also the `.discard` method for mapping any successful result (i.e. `Success(?)`, `Some(?)`, `Value(?)`, etc) to `Unit`.
412
484
 
413
485
  ```ruby
@@ -417,26 +489,19 @@
417
489
  # ... wait for the task to finish ...
418
490
  # => Task(valut=Unit)
419
491
  ```
420
-
421
- ## Deprecations
422
-
492
+ - ## Deprecations
423
493
  - `Either`, the former name of `Result`, is now deprecated
424
-
425
- ## BREAKING CHANGES
426
-
494
+ - ## BREAKING CHANGES
427
495
  - `Either#value` and `Maybe#value` were both droped, use `value_or` or `value!` when you :100: sure it's safe
428
496
  - `require 'dry/monads'` doesn't load all monads anymore, use `require 'dry/monads/all'` instead or cherry pick them with `require 'dry/monads/maybe'` etc (timriley)
429
497
 
498
+
430
499
  [Compare v0.4.0...v1.0.0](https://github.com/dry-rb/dry-monads/compare/v0.4.0...v1.0.0)
431
500
 
432
- # v0.4.0 2017-11-11
501
+ ## 0.4.0 2017-11-11
433
502
 
434
- ## Changed
435
503
 
436
- - The `Either` monad was renamed to `Result` which sounds less nerdy but better reflects the purpose of the type. `Either::Right` became `Result::Success` and `Either::Left` became `Result::Failure`. This change is backward-compatible overall but you will see the new names when using old `Left` and `Right` methods (citizen428)
437
- - Consequently, `Try::Success` and `Try::Failure` were renamed to `Try::Value` and `Try::Error` (flash-gordon)
438
-
439
- ## Added
504
+ ### Added
440
505
 
441
506
  - `Try#or`, works as `Result#or` (flash-gordon)
442
507
  - `Maybe#success?` and `Maybe#failure?` (aliases for `#some?` and `#none?`) (flash-gordon)
@@ -451,24 +516,30 @@
451
516
  else raise TypeError
452
517
  end
453
518
  ```
519
+ - ## Deprecated
520
+ - Direct accessing `value` on right-biased monads has been deprecated, use the `value!` method instead. `value!` will raise an exception if it is called on a Failure/None/Error instance (flash-gordon)
454
521
 
455
- ## Deprecated
522
+ ### Changed
456
523
 
457
- - Direct accessing `value` on right-biased monads has been deprecated, use the `value!` method instead. `value!` will raise an exception if it is called on a Failure/None/Error instance (flash-gordon)
524
+ - The `Either` monad was renamed to `Result` which sounds less nerdy but better reflects the purpose of the type. `Either::Right` became `Result::Success` and `Either::Left` became `Result::Failure`. This change is backward-compatible overall but you will see the new names when using old `Left` and `Right` methods (citizen428)
525
+ - Consequently, `Try::Success` and `Try::Failure` were renamed to `Try::Value` and `Try::Error` (flash-gordon)
458
526
 
459
527
  [Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-monads/compare/v0.3.1...v0.4.0)
460
528
 
461
- # v0.3.1 2017-03-18
529
+ ## 0.3.1 2017-03-18
530
+
462
531
 
463
- ## Fixed
532
+ ### Fixed
464
533
 
465
534
  - Fixed unexpected coercing to `Hash` on `.bind` call (flash-gordon)
466
535
 
536
+
467
537
  [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-monads/compare/v0.3.0...v0.3.1)
468
538
 
469
- # v0.3.0 2017-03-16
539
+ ## 0.3.0 2017-03-16
540
+
470
541
 
471
- ## Added
542
+ ### Added
472
543
 
473
544
  - Added `Either#either` that accepts two callbacks, runs the first if it is `Right` and the second otherwise (nkondratyev)
474
545
  - Added `#fmap2` and `#fmap3` for mapping over nested structures like `List Either` and `Either Some` (flash-gordon)
@@ -478,59 +549,69 @@
478
549
  - Added `List#traverse` that "flips" the list with an embedded monad (flash-gordon + damncabbage)
479
550
  - Added `#tee` for all right-biased monads (flash-gordon)
480
551
 
552
+
481
553
  [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-monads/compare/v0.2.1...v0.3.0)
482
554
 
483
- # v0.2.1 2016-11-13
555
+ ## 0.2.1 2016-11-13
484
556
 
485
- ## Added
557
+
558
+ ### Added
486
559
 
487
560
  - Added `Either#tee` that is similar to `Object#tap` but executes the block only for `Right` instances (saverio-kantox)
488
561
 
489
- ## Fixed
562
+ ### Fixed
490
563
 
491
564
  - `Right(nil).to_maybe` now returns `None` with a warning instead of failing (orisaka)
492
565
  - `Some#value_or` doesn't require an argument because `None#value_or` doesn't require it either if a block was passed (flash-gordon)
493
566
 
567
+
494
568
  [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-monads/compare/v0.2.0...v0.2.1)
495
569
 
496
- # v0.2.0 2016-09-18
570
+ ## 0.2.0 2016-09-18
571
+
497
572
 
498
- ## Added
573
+ ### Added
499
574
 
500
575
  - Added `Maybe#to_json` as an opt-in extension for serialization to JSON (rocknruby)
501
576
  - Added `Maybe#value_or` which returns you the underlying value with a fallback in a single method call (dsounded)
502
577
 
578
+
503
579
  [Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-monads/compare/v0.1.1...v0.2.0)
504
580
 
505
- # v0.1.1 2016-08-25
581
+ ## 0.1.1 2016-08-25
582
+
506
583
 
507
- ## Fixed
584
+ ### Fixed
508
585
 
509
586
  - Added explicit requires of `dry-equalizer`. This allows to safely load only specific monads (artofhuman)
510
587
 
588
+
511
589
  [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-monads/compare/v0.1.0...v0.1.1)
512
590
 
513
- # v0.1.0 2016-08-23
591
+ ## 0.1.0 2016-08-23
514
592
 
515
- ## Added
593
+
594
+ ### Added
516
595
 
517
596
  - Support for passing extra arguments to the block in `.bind` and `.fmap` (flash-gordon)
518
597
 
519
- ## Changed
598
+ ### Changed
520
599
 
521
600
  - Dropped MRI 2.0 support (flash-gordon)
522
601
 
523
602
  [Compare v0.0.2...v0.1.0](https://github.com/dry-rb/dry-monads/compare/v0.0.2...v0.1.0)
524
603
 
525
- # v0.0.2 2016-06-29
604
+ ## 0.0.2 2016-06-29
605
+
526
606
 
527
- ## Added
607
+ ### Added
528
608
 
529
609
  - Added `Either#to_either` so that you can rely on duck-typing when you work with different types of monads (timriley)
530
610
  - Added `Maybe#to_maybe` for consistency with `#to_either` (flash-gordon)
531
611
 
612
+
532
613
  [Compare v0.0.1...v0.0.2](https://github.com/dry-rb/dry-monads/compare/v0.0.1...v0.0.2)
533
614
 
534
- # v0.0.1 2016-05-02
615
+ ## 0.0.1 2016-05-02
535
616
 
536
617
  Initial release containing `Either`, `Maybe`, and `Try` monads.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2020 dry-rb team
3
+ Copyright (c) 2015-2022 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ <!--- this file is synced from dry-rb/template-gem project -->
1
2
  [gem]: https://rubygems.org/gems/dry-monads
2
3
  [actions]: https://github.com/dry-rb/dry-monads/actions
3
4
  [codacy]: https://www.codacy.com/gh/dry-rb/dry-monads
@@ -10,19 +11,19 @@
10
11
  [![CI Status](https://github.com/dry-rb/dry-monads/workflows/ci/badge.svg)][actions]
11
12
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f2eed41bf7f04b38b0a7691c2cf6e73c)][codacy]
12
13
  [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/f2eed41bf7f04b38b0a7691c2cf6e73c)][codacy]
13
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-monads.svg?branch=master)][inchpages]
14
+ [![Inline docs](http://inch-ci.org/github/dry-rb/dry-monads.svg?branch=main)][inchpages]
14
15
 
15
16
  ## Links
16
17
 
17
- * [User documentation](http://dry-rb.org/gems/dry-monads)
18
+ * [User documentation](https://dry-rb.org/gems/dry-monads)
18
19
  * [API documentation](http://rubydoc.info/gems/dry-monads)
19
20
 
20
21
  ## Supported Ruby versions
21
22
 
22
23
  This library officially supports the following Ruby versions:
23
24
 
24
- * MRI >= `2.4`
25
- * jruby >= `9.2`
25
+ * MRI `>= 2.7.0`
26
+ * jruby `>= 9.3` (postponed until 2.7 is supported)
26
27
 
27
28
  ## License
28
29
 
data/dry-monads.gemspec CHANGED
@@ -1,39 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ # this file is synced from dry-rb/template-gem project
4
+
5
+ lib = File.expand_path("lib", __dir__)
4
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'dry/monads/version'
7
+ require "dry/monads/version"
6
8
 
7
9
  Gem::Specification.new do |spec|
8
- spec.name = 'dry-monads'
10
+ spec.name = "dry-monads"
11
+ spec.authors = ["Nikita Shilnikov"]
12
+ spec.email = ["fg@flashgordon.ru"]
13
+ spec.license = "MIT"
9
14
  spec.version = Dry::Monads::VERSION.dup
10
- spec.authors = ['Nikita Shilnikov']
11
- spec.email = ['fg@flashgordon.ru']
12
- spec.license = 'MIT'
13
15
 
14
- spec.summary = 'Common monads for Ruby.'
16
+ spec.summary = "Common monads for Ruby"
15
17
  spec.description = spec.summary
16
- spec.homepage = 'https://github.com/dry-rb/dry-monads'
17
-
18
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
- # delete this section to allow pushing this gem to any host.
20
- if spec.respond_to?(:metadata)
21
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
- else
23
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
24
- end
25
-
26
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
30
- spec.required_ruby_version = '>= 2.4.0'
31
- spec.add_dependency 'concurrent-ruby', '~> 1.0'
32
- spec.add_dependency 'dry-core', '~> 0.4', '>= 0.4.4'
33
- spec.add_dependency 'dry-equalizer'
34
-
35
- spec.add_development_dependency 'bundler'
36
- spec.add_development_dependency 'dry-types', '>= 0.12'
37
- spec.add_development_dependency 'rake'
38
- spec.add_development_dependency 'rspec'
18
+ spec.homepage = "https://dry-rb.org/gems/dry-monads"
19
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-monads.gemspec", "lib/**/*"]
20
+ spec.bindir = "bin"
21
+ spec.executables = []
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-monads/blob/main/CHANGELOG.md"
26
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-monads"
27
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-monads/issues"
28
+
29
+ spec.required_ruby_version = ">= 2.7.0"
30
+
31
+ # to update dependencies edit project.yml
32
+ spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
33
+ spec.add_runtime_dependency "dry-core", "~> 1.0", "< 2"
34
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
35
+
36
+ spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec"
39
39
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads'
4
- require 'dry/monads/registry'
3
+ require "dry/monads"
5
4
 
6
5
  module Dry
7
6
  module Monads
8
- known_monads.each { |m| load_monad(m) }
7
+ known_monads.each { load_monad(_1) }
9
8
  extend(*constructors)
10
9
  end
11
10
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/core/constants'
4
-
5
3
  module Dry
6
4
  module Monads
7
5
  # @private
@@ -7,8 +7,8 @@ module Dry
7
7
  # @private
8
8
  def self.call(value)
9
9
  func = value.is_a?(Proc) ? value : value.method(:call)
10
- seq_args = func.parameters.count { |type, _| type == :req || type == :opt }
11
- seq_args += 1 if func.parameters.any? { |type, _| type == :keyreq }
10
+ seq_args = func.parameters.count { |type, _| type.eql?(:req) || type.eql?(:opt) }
11
+ seq_args += 1 if func.parameters.any? { |type, _| type.eql?(:keyreq) }
12
12
 
13
13
  if seq_args > 1
14
14
  func.curry