fear 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +27 -0
- data/.github/workflows/rubocop.yml +39 -0
- data/.github/workflows/spec.yml +42 -0
- data/.rubocop.yml +4 -60
- data/.simplecov +17 -0
- data/CHANGELOG.md +29 -1
- data/Gemfile +5 -5
- data/Gemfile.lock +86 -50
- data/README.md +240 -209
- data/Rakefile +72 -65
- data/examples/pattern_extracting.rb +10 -8
- data/examples/pattern_matching_binary_tree_set.rb +7 -2
- data/examples/pattern_matching_number_in_words.rb +48 -42
- data/fear.gemspec +33 -34
- data/lib/dry/types/fear/option.rb +125 -0
- data/lib/dry/types/fear.rb +8 -0
- data/lib/fear/await.rb +33 -0
- data/lib/fear/awaitable.rb +28 -0
- data/lib/fear/either.rb +15 -4
- data/lib/fear/either_api.rb +4 -0
- data/lib/fear/either_pattern_match.rb +9 -5
- data/lib/fear/empty_partial_function.rb +3 -1
- data/lib/fear/failure.rb +7 -7
- data/lib/fear/failure_pattern_match.rb +4 -0
- data/lib/fear/for.rb +4 -2
- data/lib/fear/for_api.rb +5 -1
- data/lib/fear/future.rb +157 -82
- data/lib/fear/future_api.rb +17 -4
- data/lib/fear/left.rb +3 -9
- data/lib/fear/left_pattern_match.rb +2 -0
- data/lib/fear/none.rb +28 -10
- data/lib/fear/none_pattern_match.rb +2 -0
- data/lib/fear/option.rb +30 -2
- data/lib/fear/option_api.rb +4 -0
- data/lib/fear/option_pattern_match.rb +8 -3
- data/lib/fear/partial_function/and_then.rb +4 -2
- data/lib/fear/partial_function/any.rb +2 -0
- data/lib/fear/partial_function/combined.rb +3 -1
- data/lib/fear/partial_function/empty.rb +6 -0
- data/lib/fear/partial_function/guard/and.rb +2 -0
- data/lib/fear/partial_function/guard/and3.rb +2 -0
- data/lib/fear/partial_function/guard/or.rb +2 -0
- data/lib/fear/partial_function/guard.rb +8 -6
- data/lib/fear/partial_function/lifted.rb +2 -0
- data/lib/fear/partial_function/or_else.rb +5 -1
- data/lib/fear/partial_function.rb +18 -9
- data/lib/fear/partial_function_class.rb +3 -1
- data/lib/fear/pattern_match.rb +3 -11
- data/lib/fear/pattern_matching_api.rb +6 -28
- data/lib/fear/promise.rb +7 -5
- data/lib/fear/right.rb +3 -9
- data/lib/fear/right_biased.rb +5 -3
- data/lib/fear/right_pattern_match.rb +4 -0
- data/lib/fear/some.rb +35 -8
- data/lib/fear/some_pattern_match.rb +2 -0
- data/lib/fear/struct.rb +237 -0
- data/lib/fear/success.rb +7 -8
- data/lib/fear/success_pattern_match.rb +4 -0
- data/lib/fear/try.rb +8 -2
- data/lib/fear/try_api.rb +4 -0
- data/lib/fear/try_pattern_match.rb +9 -5
- data/lib/fear/unit.rb +6 -2
- data/lib/fear/utils.rb +14 -2
- data/lib/fear/version.rb +4 -1
- data/lib/fear.rb +26 -44
- data/spec/dry/types/fear/option/constrained_spec.rb +22 -0
- data/spec/dry/types/fear/option/core_spec.rb +77 -0
- data/spec/dry/types/fear/option/default_spec.rb +21 -0
- data/spec/dry/types/fear/option/hash_spec.rb +58 -0
- data/spec/dry/types/fear/option/option_spec.rb +97 -0
- data/spec/fear/awaitable_spec.rb +19 -0
- data/spec/fear/done_spec.rb +7 -5
- data/spec/fear/either/mixin_spec.rb +4 -2
- data/spec/fear/either_pattern_match_spec.rb +10 -8
- data/spec/fear/either_pattern_matching_spec.rb +28 -0
- data/spec/fear/either_spec.rb +26 -0
- data/spec/fear/failure_spec.rb +57 -70
- data/spec/fear/for/mixin_spec.rb +15 -0
- data/spec/fear/for_spec.rb +19 -17
- data/spec/fear/future_spec.rb +477 -237
- data/spec/fear/guard_spec.rb +136 -24
- data/spec/fear/left_spec.rb +57 -70
- data/spec/fear/none_spec.rb +39 -43
- data/spec/fear/option/mixin_spec.rb +9 -7
- data/spec/fear/option_pattern_match_spec.rb +10 -8
- data/spec/fear/option_pattern_matching_spec.rb +34 -0
- data/spec/fear/option_spec.rb +142 -0
- data/spec/fear/partial_function/any_spec.rb +25 -0
- data/spec/fear/partial_function/empty_spec.rb +12 -10
- data/spec/fear/partial_function_and_then_spec.rb +39 -37
- data/spec/fear/partial_function_composition_spec.rb +46 -44
- data/spec/fear/partial_function_or_else_spec.rb +92 -90
- data/spec/fear/partial_function_spec.rb +91 -61
- data/spec/fear/pattern_match_spec.rb +19 -51
- data/spec/fear/pattern_matching_api_spec.rb +31 -0
- data/spec/fear/promise_spec.rb +23 -23
- data/spec/fear/right_biased/left.rb +28 -26
- data/spec/fear/right_biased/right.rb +51 -49
- data/spec/fear/right_spec.rb +48 -68
- data/spec/fear/some_spec.rb +30 -40
- data/spec/fear/success_spec.rb +40 -60
- data/spec/fear/try/mixin_spec.rb +19 -3
- data/spec/fear/try_api_spec.rb +23 -0
- data/spec/fear/try_pattern_match_spec.rb +10 -8
- data/spec/fear/try_pattern_matching_spec.rb +34 -0
- data/spec/fear/utils_spec.rb +16 -14
- data/spec/spec_helper.rb +13 -7
- data/spec/struct_pattern_matching_spec.rb +36 -0
- data/spec/struct_spec.rb +194 -0
- data/spec/support/dry_types.rb +6 -0
- metadata +128 -87
- data/.travis.yml +0 -13
- data/lib/fear/extractor/anonymous_array_splat_matcher.rb +0 -8
- data/lib/fear/extractor/any_matcher.rb +0 -15
- data/lib/fear/extractor/array_head_matcher.rb +0 -34
- data/lib/fear/extractor/array_matcher.rb +0 -38
- data/lib/fear/extractor/array_splat_matcher.rb +0 -14
- data/lib/fear/extractor/empty_list_matcher.rb +0 -18
- data/lib/fear/extractor/extractor_matcher.rb +0 -42
- data/lib/fear/extractor/grammar.rb +0 -201
- data/lib/fear/extractor/grammar.treetop +0 -129
- data/lib/fear/extractor/identifier_matcher.rb +0 -16
- data/lib/fear/extractor/matcher/and.rb +0 -36
- data/lib/fear/extractor/matcher.rb +0 -54
- data/lib/fear/extractor/named_array_splat_matcher.rb +0 -15
- data/lib/fear/extractor/pattern.rb +0 -55
- data/lib/fear/extractor/typed_identifier_matcher.rb +0 -24
- data/lib/fear/extractor/value_matcher.rb +0 -17
- data/lib/fear/extractor.rb +0 -108
- data/lib/fear/extractor_api.rb +0 -33
- data/spec/fear/extractor/array_matcher_spec.rb +0 -228
- data/spec/fear/extractor/extractor_matcher_spec.rb +0 -151
- data/spec/fear/extractor/grammar_array_spec.rb +0 -23
- data/spec/fear/extractor/identified_matcher_spec.rb +0 -47
- data/spec/fear/extractor/identifier_matcher_spec.rb +0 -66
- data/spec/fear/extractor/pattern_spec.rb +0 -32
- data/spec/fear/extractor/typed_identifier_matcher_spec.rb +0 -62
- data/spec/fear/extractor/value_matcher_number_spec.rb +0 -77
- data/spec/fear/extractor/value_matcher_string_spec.rb +0 -86
- data/spec/fear/extractor/value_matcher_symbol_spec.rb +0 -69
- data/spec/fear/extractor_api_spec.rb +0 -113
- data/spec/fear/extractor_spec.rb +0 -59
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: lru_redux
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: treetop
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: benchmark-ips
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +100,14 @@ dependencies:
|
|
128
100
|
requirements:
|
129
101
|
- - "~>"
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
103
|
+
version: '13.0'
|
132
104
|
type: :development
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
136
108
|
- - "~>"
|
137
109
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
110
|
+
version: '13.0'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
112
|
name: rspec
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,21 +123,21 @@ dependencies:
|
|
151
123
|
- !ruby/object:Gem::Version
|
152
124
|
version: '3.1'
|
153
125
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: rubocop
|
126
|
+
name: rubocop-rspec
|
155
127
|
requirement: !ruby/object:Gem::Requirement
|
156
128
|
requirements:
|
157
129
|
- - '='
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
131
|
+
version: 1.34.0
|
160
132
|
type: :development
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
136
|
- - '='
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
138
|
+
version: 1.34.0
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
|
-
name: rubocop
|
140
|
+
name: rubocop
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
170
142
|
requirements:
|
171
143
|
- - '='
|
@@ -178,6 +150,20 @@ dependencies:
|
|
178
150
|
- - '='
|
179
151
|
- !ruby/object:Gem::Version
|
180
152
|
version: 1.32.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ruby_coding_standard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: yard
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +178,62 @@ dependencies:
|
|
192
178
|
- - ">="
|
193
179
|
- !ruby/object:Gem::Version
|
194
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: dry-types
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: fear-rspec
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: simplecov
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: simplecov-lcov
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
195
237
|
description: Ruby port of some Scala's monads.
|
196
238
|
email:
|
197
239
|
- abolshakov@spbtv.com
|
@@ -199,10 +241,13 @@ executables: []
|
|
199
241
|
extensions: []
|
200
242
|
extra_rdoc_files: []
|
201
243
|
files:
|
244
|
+
- ".github/dependabot.yml"
|
245
|
+
- ".github/workflows/rubocop.yml"
|
246
|
+
- ".github/workflows/spec.yml"
|
202
247
|
- ".gitignore"
|
203
248
|
- ".rspec"
|
204
249
|
- ".rubocop.yml"
|
205
|
-
- ".
|
250
|
+
- ".simplecov"
|
206
251
|
- ".yardopts"
|
207
252
|
- CHANGELOG.md
|
208
253
|
- Gemfile
|
@@ -226,29 +271,15 @@ files:
|
|
226
271
|
- examples/pattern_matching_binary_tree_set.rb
|
227
272
|
- examples/pattern_matching_number_in_words.rb
|
228
273
|
- fear.gemspec
|
274
|
+
- lib/dry/types/fear.rb
|
275
|
+
- lib/dry/types/fear/option.rb
|
229
276
|
- lib/fear.rb
|
277
|
+
- lib/fear/await.rb
|
278
|
+
- lib/fear/awaitable.rb
|
230
279
|
- lib/fear/either.rb
|
231
280
|
- lib/fear/either_api.rb
|
232
281
|
- lib/fear/either_pattern_match.rb
|
233
282
|
- lib/fear/empty_partial_function.rb
|
234
|
-
- lib/fear/extractor.rb
|
235
|
-
- lib/fear/extractor/anonymous_array_splat_matcher.rb
|
236
|
-
- lib/fear/extractor/any_matcher.rb
|
237
|
-
- lib/fear/extractor/array_head_matcher.rb
|
238
|
-
- lib/fear/extractor/array_matcher.rb
|
239
|
-
- lib/fear/extractor/array_splat_matcher.rb
|
240
|
-
- lib/fear/extractor/empty_list_matcher.rb
|
241
|
-
- lib/fear/extractor/extractor_matcher.rb
|
242
|
-
- lib/fear/extractor/grammar.rb
|
243
|
-
- lib/fear/extractor/grammar.treetop
|
244
|
-
- lib/fear/extractor/identifier_matcher.rb
|
245
|
-
- lib/fear/extractor/matcher.rb
|
246
|
-
- lib/fear/extractor/matcher/and.rb
|
247
|
-
- lib/fear/extractor/named_array_splat_matcher.rb
|
248
|
-
- lib/fear/extractor/pattern.rb
|
249
|
-
- lib/fear/extractor/typed_identifier_matcher.rb
|
250
|
-
- lib/fear/extractor/value_matcher.rb
|
251
|
-
- lib/fear/extractor_api.rb
|
252
283
|
- lib/fear/failure.rb
|
253
284
|
- lib/fear/failure_pattern_match.rb
|
254
285
|
- lib/fear/for.rb
|
@@ -282,6 +313,7 @@ files:
|
|
282
313
|
- lib/fear/right_pattern_match.rb
|
283
314
|
- lib/fear/some.rb
|
284
315
|
- lib/fear/some_pattern_match.rb
|
316
|
+
- lib/fear/struct.rb
|
285
317
|
- lib/fear/success.rb
|
286
318
|
- lib/fear/success_pattern_match.rb
|
287
319
|
- lib/fear/try.rb
|
@@ -290,22 +322,19 @@ files:
|
|
290
322
|
- lib/fear/unit.rb
|
291
323
|
- lib/fear/utils.rb
|
292
324
|
- lib/fear/version.rb
|
325
|
+
- spec/dry/types/fear/option/constrained_spec.rb
|
326
|
+
- spec/dry/types/fear/option/core_spec.rb
|
327
|
+
- spec/dry/types/fear/option/default_spec.rb
|
328
|
+
- spec/dry/types/fear/option/hash_spec.rb
|
329
|
+
- spec/dry/types/fear/option/option_spec.rb
|
330
|
+
- spec/fear/awaitable_spec.rb
|
293
331
|
- spec/fear/done_spec.rb
|
294
332
|
- spec/fear/either/mixin_spec.rb
|
295
333
|
- spec/fear/either_pattern_match_spec.rb
|
296
|
-
- spec/fear/
|
297
|
-
- spec/fear/
|
298
|
-
- spec/fear/extractor/grammar_array_spec.rb
|
299
|
-
- spec/fear/extractor/identified_matcher_spec.rb
|
300
|
-
- spec/fear/extractor/identifier_matcher_spec.rb
|
301
|
-
- spec/fear/extractor/pattern_spec.rb
|
302
|
-
- spec/fear/extractor/typed_identifier_matcher_spec.rb
|
303
|
-
- spec/fear/extractor/value_matcher_number_spec.rb
|
304
|
-
- spec/fear/extractor/value_matcher_string_spec.rb
|
305
|
-
- spec/fear/extractor/value_matcher_symbol_spec.rb
|
306
|
-
- spec/fear/extractor_api_spec.rb
|
307
|
-
- spec/fear/extractor_spec.rb
|
334
|
+
- spec/fear/either_pattern_matching_spec.rb
|
335
|
+
- spec/fear/either_spec.rb
|
308
336
|
- spec/fear/failure_spec.rb
|
337
|
+
- spec/fear/for/mixin_spec.rb
|
309
338
|
- spec/fear/for_spec.rb
|
310
339
|
- spec/fear/future_spec.rb
|
311
340
|
- spec/fear/guard_spec.rb
|
@@ -313,12 +342,16 @@ files:
|
|
313
342
|
- spec/fear/none_spec.rb
|
314
343
|
- spec/fear/option/mixin_spec.rb
|
315
344
|
- spec/fear/option_pattern_match_spec.rb
|
345
|
+
- spec/fear/option_pattern_matching_spec.rb
|
346
|
+
- spec/fear/option_spec.rb
|
347
|
+
- spec/fear/partial_function/any_spec.rb
|
316
348
|
- spec/fear/partial_function/empty_spec.rb
|
317
349
|
- spec/fear/partial_function_and_then_spec.rb
|
318
350
|
- spec/fear/partial_function_composition_spec.rb
|
319
351
|
- spec/fear/partial_function_or_else_spec.rb
|
320
352
|
- spec/fear/partial_function_spec.rb
|
321
353
|
- spec/fear/pattern_match_spec.rb
|
354
|
+
- spec/fear/pattern_matching_api_spec.rb
|
322
355
|
- spec/fear/promise_spec.rb
|
323
356
|
- spec/fear/right_biased/left.rb
|
324
357
|
- spec/fear/right_biased/right.rb
|
@@ -326,17 +359,19 @@ files:
|
|
326
359
|
- spec/fear/some_spec.rb
|
327
360
|
- spec/fear/success_spec.rb
|
328
361
|
- spec/fear/try/mixin_spec.rb
|
362
|
+
- spec/fear/try_api_spec.rb
|
329
363
|
- spec/fear/try_pattern_match_spec.rb
|
364
|
+
- spec/fear/try_pattern_matching_spec.rb
|
330
365
|
- spec/fear/utils_spec.rb
|
331
366
|
- spec/spec_helper.rb
|
367
|
+
- spec/struct_pattern_matching_spec.rb
|
368
|
+
- spec/struct_spec.rb
|
369
|
+
- spec/support/dry_types.rb
|
332
370
|
homepage: https://github.com/bolshakov/fear
|
333
371
|
licenses:
|
334
372
|
- MIT
|
335
373
|
metadata: {}
|
336
|
-
post_install_message:
|
337
|
-
Fear v0.11.0 introduces backwards-incompatible changes.
|
338
|
-
Please see https://github.com/bolshakov/fear/blob/master/CHANGELOG.md#0110 for details.
|
339
|
-
Successfully installed fear-1.0.0
|
374
|
+
post_install_message:
|
340
375
|
rdoc_options: []
|
341
376
|
require_paths:
|
342
377
|
- lib
|
@@ -344,34 +379,31 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
344
379
|
requirements:
|
345
380
|
- - ">="
|
346
381
|
- !ruby/object:Gem::Version
|
347
|
-
version:
|
382
|
+
version: 2.6.0
|
348
383
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
349
384
|
requirements:
|
350
385
|
- - ">="
|
351
386
|
- !ruby/object:Gem::Version
|
352
387
|
version: '0'
|
353
388
|
requirements: []
|
354
|
-
rubygems_version: 3.
|
355
|
-
signing_key:
|
389
|
+
rubygems_version: 3.3.7
|
390
|
+
signing_key:
|
356
391
|
specification_version: 4
|
357
392
|
summary: "%q{Ruby port of some Scala's monads.}"
|
358
393
|
test_files:
|
394
|
+
- spec/dry/types/fear/option/constrained_spec.rb
|
395
|
+
- spec/dry/types/fear/option/core_spec.rb
|
396
|
+
- spec/dry/types/fear/option/default_spec.rb
|
397
|
+
- spec/dry/types/fear/option/hash_spec.rb
|
398
|
+
- spec/dry/types/fear/option/option_spec.rb
|
399
|
+
- spec/fear/awaitable_spec.rb
|
359
400
|
- spec/fear/done_spec.rb
|
360
401
|
- spec/fear/either/mixin_spec.rb
|
361
402
|
- spec/fear/either_pattern_match_spec.rb
|
362
|
-
- spec/fear/
|
363
|
-
- spec/fear/
|
364
|
-
- spec/fear/extractor/grammar_array_spec.rb
|
365
|
-
- spec/fear/extractor/identified_matcher_spec.rb
|
366
|
-
- spec/fear/extractor/identifier_matcher_spec.rb
|
367
|
-
- spec/fear/extractor/pattern_spec.rb
|
368
|
-
- spec/fear/extractor/typed_identifier_matcher_spec.rb
|
369
|
-
- spec/fear/extractor/value_matcher_number_spec.rb
|
370
|
-
- spec/fear/extractor/value_matcher_string_spec.rb
|
371
|
-
- spec/fear/extractor/value_matcher_symbol_spec.rb
|
372
|
-
- spec/fear/extractor_api_spec.rb
|
373
|
-
- spec/fear/extractor_spec.rb
|
403
|
+
- spec/fear/either_pattern_matching_spec.rb
|
404
|
+
- spec/fear/either_spec.rb
|
374
405
|
- spec/fear/failure_spec.rb
|
406
|
+
- spec/fear/for/mixin_spec.rb
|
375
407
|
- spec/fear/for_spec.rb
|
376
408
|
- spec/fear/future_spec.rb
|
377
409
|
- spec/fear/guard_spec.rb
|
@@ -379,12 +411,16 @@ test_files:
|
|
379
411
|
- spec/fear/none_spec.rb
|
380
412
|
- spec/fear/option/mixin_spec.rb
|
381
413
|
- spec/fear/option_pattern_match_spec.rb
|
414
|
+
- spec/fear/option_pattern_matching_spec.rb
|
415
|
+
- spec/fear/option_spec.rb
|
416
|
+
- spec/fear/partial_function/any_spec.rb
|
382
417
|
- spec/fear/partial_function/empty_spec.rb
|
383
418
|
- spec/fear/partial_function_and_then_spec.rb
|
384
419
|
- spec/fear/partial_function_composition_spec.rb
|
385
420
|
- spec/fear/partial_function_or_else_spec.rb
|
386
421
|
- spec/fear/partial_function_spec.rb
|
387
422
|
- spec/fear/pattern_match_spec.rb
|
423
|
+
- spec/fear/pattern_matching_api_spec.rb
|
388
424
|
- spec/fear/promise_spec.rb
|
389
425
|
- spec/fear/right_biased/left.rb
|
390
426
|
- spec/fear/right_biased/right.rb
|
@@ -392,6 +428,11 @@ test_files:
|
|
392
428
|
- spec/fear/some_spec.rb
|
393
429
|
- spec/fear/success_spec.rb
|
394
430
|
- spec/fear/try/mixin_spec.rb
|
431
|
+
- spec/fear/try_api_spec.rb
|
395
432
|
- spec/fear/try_pattern_match_spec.rb
|
433
|
+
- spec/fear/try_pattern_matching_spec.rb
|
396
434
|
- spec/fear/utils_spec.rb
|
397
435
|
- spec/spec_helper.rb
|
436
|
+
- spec/struct_pattern_matching_spec.rb
|
437
|
+
- spec/struct_spec.rb
|
438
|
+
- spec/support/dry_types.rb
|
data/.travis.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Fear
|
2
|
-
module Extractor
|
3
|
-
# Part of recursive array matcher. Match against its head.
|
4
|
-
# @see ArrayMatcher
|
5
|
-
class ArrayHeadMatcher < Matcher
|
6
|
-
# @!attribute matcher
|
7
|
-
# @return [Matcher]
|
8
|
-
# @!attribute index
|
9
|
-
# @return [Types::Strict::Integer]
|
10
|
-
|
11
|
-
# @param other [<>]
|
12
|
-
def defined_at?(other)
|
13
|
-
if other.empty?
|
14
|
-
false
|
15
|
-
else
|
16
|
-
matcher.defined_at?(other.first)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# @param other [<>]
|
21
|
-
def bindings(other)
|
22
|
-
if other.empty?
|
23
|
-
super
|
24
|
-
else
|
25
|
-
matcher.bindings(other.first)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def failure_reason(other)
|
30
|
-
matcher.failure_reason(other.first)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Fear
|
2
|
-
module Extractor
|
3
|
-
# Recursive array matcher. Match against its head and tail
|
4
|
-
#
|
5
|
-
class ArrayMatcher < Matcher
|
6
|
-
# @!attribute head
|
7
|
-
# @return [ArrayHeadMatcher]
|
8
|
-
# @!attribute tail
|
9
|
-
# @return [ArrayMatcher | EmptyListMatcher]
|
10
|
-
|
11
|
-
def defined_at?(other)
|
12
|
-
if other.is_a?(Array)
|
13
|
-
head.defined_at?(other) && tail.defined_at?(other.slice(1..-1))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def bindings(other)
|
18
|
-
if head.is_a?(ArraySplatMatcher)
|
19
|
-
head.bindings(other)
|
20
|
-
else
|
21
|
-
head.bindings(other).merge(tail.bindings(other.slice(1..-1)))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def failure_reason(other)
|
26
|
-
if other.is_a?(Array)
|
27
|
-
if head.defined_at?(other)
|
28
|
-
tail.failure_reason(other.slice(1..-1))
|
29
|
-
else
|
30
|
-
head.failure_reason(other)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Fear
|
2
|
-
module Extractor
|
3
|
-
# Match only if array is empty
|
4
|
-
#
|
5
|
-
class EmptyListMatcher < Matcher
|
6
|
-
# @!attribute index
|
7
|
-
# @return [Types::Strict::Integer]
|
8
|
-
#
|
9
|
-
def defined_at?(other)
|
10
|
-
other.empty?
|
11
|
-
end
|
12
|
-
|
13
|
-
def bindings(_)
|
14
|
-
EMPTY_HASH
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Fear
|
2
|
-
module Extractor
|
3
|
-
# Match and extract pattern using registered extractor objects
|
4
|
-
# E.g. +Some(a : Integer)+
|
5
|
-
# @see Extractor.register_extractor
|
6
|
-
class ExtractorMatcher < Matcher
|
7
|
-
# @!attribute name
|
8
|
-
# @return [Types::Strict::String]
|
9
|
-
# @!attribute arguments_matcher
|
10
|
-
# @return [ArrayMatcher | EmptyListMatcher]
|
11
|
-
#
|
12
|
-
|
13
|
-
def initialize(*)
|
14
|
-
super
|
15
|
-
@extractor = Extractor.find_extractor(name)
|
16
|
-
end
|
17
|
-
attr_reader :extractor
|
18
|
-
private :extractor
|
19
|
-
|
20
|
-
def defined_at?(other)
|
21
|
-
extractor
|
22
|
-
.call(other)
|
23
|
-
.map { |v| arguments_matcher.defined_at?(v) }
|
24
|
-
.get_or_else(false)
|
25
|
-
end
|
26
|
-
|
27
|
-
def call_or_else(arg)
|
28
|
-
extractor.call(arg)
|
29
|
-
.map { |v| arguments_matcher.call_or_else(v) { yield arg } }
|
30
|
-
.get_or_else { yield arg }
|
31
|
-
end
|
32
|
-
|
33
|
-
def failure_reason(other)
|
34
|
-
extractor.call(other).match do |m|
|
35
|
-
m.some(->(v) { arguments_matcher.defined_at?(v) }) { Fear.none }
|
36
|
-
m.some { |v| arguments_matcher.failure_reason(v) }
|
37
|
-
m.none { super }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|