mprelude 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2f63ad7edffa0ca7d09d0f162bdf253e34cccf1f182f23360e5e0ee45b76bf8
4
- data.tar.gz: 680b19d4359642670d74876d44715cfa26f9156317df4275caf761c31501ee68
3
+ metadata.gz: f41b72673c3d3d33030bf04fa7de7fd8ec875b79f5a408601d6c83d6b64cdf86
4
+ data.tar.gz: cb2b0c662dc4c00d8626245579750e1d472550ff9ce69b4dd4be047dc1dd4587
5
5
  SHA512:
6
- metadata.gz: 381d73dae951033421d881ef7114c06c6d33bdbc927c8aa9841eaf18c24061e8eff7528f28e088d904d903764cf6946d4a5fd853bdb82cb122fbd6b61afd47dd
7
- data.tar.gz: 01a108b78ad032393c9e76ef0f2d988bb47480d1ed7428d138591549fa9e2d450be22c8e3505ac257f0a6ef6eca7870f8c9d17bb8e16098ec8891a1fb107f956
6
+ metadata.gz: 7e013c91f2f15500728b3a57a592ad359b0d87d56b948bb1fec485196c288293cbc3b9cee3985c7f50d9d25d3442fb92881e25eefb93776cf2ffc6467443888f
7
+ data.tar.gz: dd114660d4dbfb284fe7c172f31541a7e89885b7eb5709f94ac7b239785a790ea5d8443d084a3ca4f006b139432de5abe3677eb9c58683016160d29a69c242ff
@@ -5,11 +5,9 @@ require 'adamantium'
5
5
  require 'concord'
6
6
 
7
7
  module MPrelude
8
- module Functor
8
+ module RequireBlock
9
9
  include AbstractType
10
10
 
11
- abstract_method :fmap
12
-
13
11
  private
14
12
 
15
13
  # Raise error unless block is provided
@@ -22,13 +20,13 @@ module MPrelude
22
20
  fail LocalJumpError unless block_given?
23
21
  self
24
22
  end
25
- end # Functor
23
+ end # RequireBLock
26
24
 
27
25
  class Maybe
28
26
  include(
29
27
  AbstractType,
30
28
  Adamantium::Flat,
31
- Functor
29
+ RequireBlock
32
30
  )
33
31
 
34
32
  class Nothing < self
@@ -46,7 +44,7 @@ module MPrelude
46
44
  # Evaluate applicative block
47
45
  #
48
46
  # @return [Maybe::Nothing]
49
- def apply(&block)
47
+ def bind(&block)
50
48
  require_block(&block)
51
49
  end
52
50
  end # Nothing
@@ -64,7 +62,7 @@ module MPrelude
64
62
  # Evalute applicative block
65
63
  #
66
64
  # @return [Maybe]
67
- def apply
65
+ def bind
68
66
  yield(value)
69
67
  end
70
68
  end # Just
@@ -75,7 +73,7 @@ module MPrelude
75
73
  AbstractType,
76
74
  Adamantium::Flat,
77
75
  Concord.new(:value),
78
- Functor
76
+ RequireBlock
79
77
  )
80
78
 
81
79
  # Execute block and wrap error in left
@@ -114,7 +112,7 @@ module MPrelude
114
112
  # Evaluate applicative block
115
113
  #
116
114
  # @return [Either::Left<Object>]
117
- def apply(&block)
115
+ def bind(&block)
118
116
  require_block(&block)
119
117
  end
120
118
 
@@ -166,7 +164,7 @@ module MPrelude
166
164
  # Evaluate applicative block
167
165
  #
168
166
  # @return [Either<Object>]
169
- def apply
167
+ def bind
170
168
  yield(value)
171
169
  end
172
170
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mprelude'
5
- gem.version = '0.0.3'
5
+ gem.version = '0.1.0'
6
6
  gem.authors = ['Markus Schirp']
7
7
  gem.email = ['mbj@schirp-dso.com']
8
8
  gem.description = 'Minimal prelude alike classes'
@@ -28,7 +28,7 @@ RSpec.shared_examples 'returns self' do
28
28
  end
29
29
  end
30
30
 
31
- RSpec.shared_examples '#apply block evaluation' do
31
+ RSpec.shared_examples '#bind block evaluation' do
32
32
  it 'evaluates block and returns its wrapped result' do
33
33
  expect { expect(apply).to eql(block_result) }
34
34
  .to change(yields, :to_a)
@@ -113,9 +113,9 @@ RSpec.describe MPrelude::Either::Left do
113
113
  include_examples 'returns self'
114
114
  end
115
115
 
116
- describe '#apply' do
116
+ describe '#bind' do
117
117
  def apply
118
- subject.apply(&block)
118
+ subject.bind(&block)
119
119
  end
120
120
 
121
121
  include_examples 'no block evaluation'
@@ -186,7 +186,7 @@ RSpec.describe MPrelude::Either::Left do
186
186
  subject.either(block, -> { fail })
187
187
  end
188
188
 
189
- include_examples '#apply block evaluation'
189
+ include_examples '#bind block evaluation'
190
190
  end
191
191
 
192
192
  describe '#left?' do
@@ -233,13 +233,13 @@ RSpec.describe MPrelude::Either::Right do
233
233
  include_examples 'Functor#fmap block evaluation'
234
234
  end
235
235
 
236
- describe '#apply' do
236
+ describe '#bind' do
237
237
  def apply
238
- subject.apply(&block)
238
+ subject.bind(&block)
239
239
  end
240
240
 
241
241
  include_examples 'requires block'
242
- include_examples '#apply block evaluation'
242
+ include_examples '#bind block evaluation'
243
243
  end
244
244
 
245
245
  describe '#from_left' do
@@ -309,7 +309,7 @@ RSpec.describe MPrelude::Either::Right do
309
309
  subject.either(-> { fail }, block)
310
310
  end
311
311
 
312
- include_examples '#apply block evaluation'
312
+ include_examples '#bind block evaluation'
313
313
  end
314
314
 
315
315
  describe '#left?' do
@@ -15,9 +15,9 @@ RSpec.describe MPrelude::Maybe::Nothing do
15
15
  include_examples 'returns self'
16
16
  end
17
17
 
18
- describe '#apply' do
18
+ describe '#bind' do
19
19
  def apply
20
- subject.apply(&block)
20
+ subject.bind(&block)
21
21
  end
22
22
 
23
23
  include_examples 'no block evaluation'
@@ -49,12 +49,12 @@ RSpec.describe MPrelude::Maybe::Just do
49
49
  include_examples 'Functor#fmap block evaluation'
50
50
  end
51
51
 
52
- describe '#apply' do
52
+ describe '#bind' do
53
53
  def apply
54
- subject.apply(&block)
54
+ subject.bind(&block)
55
55
  end
56
56
 
57
57
  include_examples 'requires block'
58
- include_examples '#apply block evaluation'
58
+ include_examples '#bind block evaluation'
59
59
  end
60
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mprelude
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2020-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.0.6
134
+ rubygems_version: 3.0.3
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Mostly an either type