monadic 0.7.0 → 0.7.1
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.
- data/lib/monadic/maybe.rb +1 -1
- data/lib/monadic/version.rb +1 -1
- data/spec/maybe_spec.rb +4 -2
- data/spec/monad_axioms.rb +4 -4
- metadata +3 -9
data/lib/monadic/maybe.rb
CHANGED
data/lib/monadic/version.rb
CHANGED
data/spec/maybe_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
|
3
4
|
describe Monadic::Maybe do
|
4
5
|
it_behaves_like 'a Monad' do
|
5
6
|
let(:monad) { Maybe }
|
@@ -37,6 +38,7 @@ describe Monadic::Maybe do
|
|
37
38
|
option = Maybe(nil)
|
38
39
|
"#{option}".should == "Nothing"
|
39
40
|
Nothing.to_s.should == "Nothing"
|
41
|
+
Nothing.to_s(1, 2).should == "Nothing"
|
40
42
|
end
|
41
43
|
|
42
44
|
it 'Nothing is always empty' do
|
@@ -100,10 +102,10 @@ describe Monadic::Maybe do
|
|
100
102
|
end
|
101
103
|
|
102
104
|
it 'calling methods on Maybe always returns an Maybe with the transformed value' do
|
103
|
-
Maybe('FOO').downcase.should == Just('foo')
|
105
|
+
Maybe('FOO').downcase.should == Just('foo')
|
104
106
|
end
|
105
107
|
|
106
|
-
it '#fetch returns the value of an option' do
|
108
|
+
it '#fetch returns the value of an option' do
|
107
109
|
Maybe('foo').fetch.should == 'foo'
|
108
110
|
Maybe('foo')._.should == 'foo'
|
109
111
|
end
|
data/spec/monad_axioms.rb
CHANGED
@@ -15,14 +15,14 @@ shared_examples 'a Monad' do
|
|
15
15
|
end.should == monad.unit(1)
|
16
16
|
end
|
17
17
|
|
18
|
-
it '3rd monadic law: associativity' do
|
18
|
+
it '3rd monadic law: associativity' do
|
19
19
|
f = ->(value) { monad.unit(value + 1) }
|
20
|
-
g = ->(value) { monad.unit(value + 100) }
|
20
|
+
g = ->(value) { monad.unit(value + 100) }
|
21
21
|
|
22
22
|
id1 = monad.unit(1).bind do |a|
|
23
23
|
f.(a)
|
24
|
-
end.bind do |b|
|
25
|
-
g.(b)
|
24
|
+
end.bind do |b|
|
25
|
+
g.(b)
|
26
26
|
end
|
27
27
|
|
28
28
|
id2 = monad.unit(1).bind do |a|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monadic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -175,21 +175,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
175
|
- - ! '>='
|
176
176
|
- !ruby/object:Gem::Version
|
177
177
|
version: '0'
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
hash: 494077126848857519
|
181
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
179
|
none: false
|
183
180
|
requirements:
|
184
181
|
- - ! '>='
|
185
182
|
- !ruby/object:Gem::Version
|
186
183
|
version: '0'
|
187
|
-
segments:
|
188
|
-
- 0
|
189
|
-
hash: 494077126848857519
|
190
184
|
requirements: []
|
191
185
|
rubyforge_project:
|
192
|
-
rubygems_version: 1.8.
|
186
|
+
rubygems_version: 1.8.23
|
193
187
|
signing_key:
|
194
188
|
specification_version: 3
|
195
189
|
summary: see README
|