ribimaybe 0.0.9 → 0.0.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6db212d9c3464928b07c3bb761205ed07313e566
4
- data.tar.gz: ca60246d186c728d0f4da756826523f26b3ba814
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDI0OGM5YTQyNzcyMTE2N2Q1NWNhNjAxMjY3MmRmYzMyYTViNWFhYw==
5
+ data.tar.gz: !binary |-
6
+ OTU3ZDdhMWJkNzliZDBjYWUyZTJiNzIzYTM2YmVmMjZhNjcyOWM3Nw==
5
7
  SHA512:
6
- metadata.gz: 84aa2de634c9d305c7d27fed5a267ce2a275bd87bed2f73aed3b47e2170e609da37742bacda67af1324d0d5337311a3ae9ea40abb06bfc58a15dd5d8986dc7df
7
- data.tar.gz: 6bd80d6844bd70110234b5e75686d26a7ab7a4d05f022e6181064c7f5b5f1fe2110119b4365ee8a63897710f0ee272b7047ee1bed261d71898b08000224036d8
8
+ metadata.gz: !binary |-
9
+ MzQ2ODU0OWI1MzE1OTQ5MGY3OTk0NjE1MTE2ZWZjMDc5YTI1Y2ZjODIzMjdj
10
+ Njc3ODNkMGFlMDFiYzZhM2RhMWEzMGU3YjA3YWNlNDEwNjYwNDk3OTBkOGMw
11
+ M2VlOWNlZjc0OTRjNjU0YWVhZTM0OTE1YWZiMDE4YzQxNWY5NWM=
12
+ data.tar.gz: !binary |-
13
+ YmNkNWVmYWExYjNiYmM1OTE5MTM3ZjVkN2VmYjE2ODAxZjMxNmM4NDA3ODI0
14
+ OTQxNjhiNGZjMDM1M2YzZWFlZWMxMWFjMWUxYTM4YWIzOTJhNmIwNTMwYmFi
15
+ NTFhNTI3ZTFlNjk4ZmNhY2FiNjQyMzEwZWEyMWU5Mzk1MmMxZjM=
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Ribimaybe
2
2
 
3
+ > "Flavouring the ocean with a teaspoon of sugar."
4
+
3
5
  [![Gem Version](https://badge.fury.io/rb/ribimaybe.svg)](http://badge.fury.io/rb/ribimaybe)
4
6
  [![Travis](https://travis-ci.org/unsymbol/ribimaybe.svg?branch=master)](http://travis-ci.org/unsymbol/ribimaybe)
5
7
  [![Code Climate](https://codeclimate.com/github/unsymbol/ribimaybe.png)](https://codeclimate.com/github/unsymbol/ribimaybe)
@@ -7,7 +9,7 @@
7
9
  ![](maybe.gif)
8
10
 
9
11
  A tiny Ruby library that provides a Maybe datatype which is a Functor,
10
- Applicative Functor and Monad instance.
12
+ Applicative Functor and Monad.
11
13
 
12
14
  ## Installation
13
15
 
data/lib/ribimaybe.rb CHANGED
@@ -142,7 +142,7 @@ module Ribimaybe
142
142
  # rturn(x + x)
143
143
  # end # => Just(2)
144
144
  #
145
- Contract Proc => Just
145
+ Contract Proc => Or[Nothing, Just]
146
146
  def bind(&fn)
147
147
  fn.curry.(@value)
148
148
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ribimaybe
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/spec/bug_spec.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+ include Ribimaybe::Maybe
3
+ describe "Bugs" do
4
+ describe "issue17" do
5
+ it do
6
+ result = Just(1).bind{ |x|
7
+ Nothing.bind{ |y|
8
+ rturn(x + y)
9
+ }
10
+ }
11
+ expect(result).to eq(Nothing)
12
+ end
13
+ end
14
+ end
data/spec/monad_spec.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require "spec_helper"
2
2
  include Ribimaybe::Maybe
3
3
  describe "Monad Instance" do
4
+ let(:id) do
5
+ ->(x) { x }
6
+ end
7
+
8
+ let(:lifted_id) do
9
+ ->(x) { id.(rturn(x)) }
10
+ end
11
+
4
12
  let(:f) do
5
13
  ->(x){ ->(y) { rturn(x) } }.(SecureRandom.base64(1000))
6
14
  end
@@ -13,13 +21,13 @@ describe "Monad Instance" do
13
21
  describe "left identity" do
14
22
  context "when i have nothing" do
15
23
  it do
16
- expect(Nothing.bind(&f)).to eq(Nothing)
24
+ expect(Nothing.bind(&lifted_id)).to eq(Nothing)
17
25
  end
18
26
  end
19
27
 
20
28
  context "when i have just :x" do
21
29
  it do
22
- expect(rturn(:x).bind(&f)).to eq(f.(:a))
30
+ expect(rturn(:x).bind(&lifted_id)).to eq(lifted_id.(:x))
23
31
  end
24
32
  end
25
33
  end
@@ -28,13 +36,13 @@ describe "Monad Instance" do
28
36
  describe "right identity" do
29
37
  context "when i have nothing" do
30
38
  it do
31
- expect(Nothing.bind { |x| rturn(x) }).to eq(Nothing)
39
+ expect(Nothing.bind(&lifted_id)).to eq(Nothing)
32
40
  end
33
41
  end
34
42
 
35
43
  context "when i have just :x" do
36
44
  it do
37
- expect(Just(:x).bind { |x| rturn(x) }).to eq(Just(:x))
45
+ expect(Just(:x).bind(&lifted_id)).to eq(Just(:x))
38
46
  end
39
47
  end
40
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribimaybe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - unsymbol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,42 +28,42 @@ dependencies:
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -98,6 +98,7 @@ files:
98
98
  - maybe.gif
99
99
  - ribimaybe.gemspec
100
100
  - spec/applicative_functor_spec.rb
101
+ - spec/bug_spec.rb
101
102
  - spec/functor_spec.rb
102
103
  - spec/maybe_spec.rb
103
104
  - spec/monad_spec.rb
@@ -112,23 +113,24 @@ require_paths:
112
113
  - lib
113
114
  required_ruby_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
- - - '>='
116
+ - - ! '>='
116
117
  - !ruby/object:Gem::Version
117
118
  version: 1.9.3
118
119
  required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  requirements:
120
- - - '>='
121
+ - - ! '>='
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
125
  rubyforge_project:
125
- rubygems_version: 2.0.2
126
+ rubygems_version: 2.1.11
126
127
  signing_key:
127
128
  specification_version: 4
128
129
  summary: A tiny Ruby library that provides a Maybe datatype which is a Functor, Applicative
129
130
  Functor and Monad instance.
130
131
  test_files:
131
132
  - spec/applicative_functor_spec.rb
133
+ - spec/bug_spec.rb
132
134
  - spec/functor_spec.rb
133
135
  - spec/maybe_spec.rb
134
136
  - spec/monad_spec.rb