ribimaybe 0.0.4 → 0.0.5

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjkxNTVjYWRmMjUzOTA1YmU4ZjUxNzAwMjM0Nzk4YTIxMGRhODEyZQ==
4
+ Y2ZiYjVmMzM2NTJkMmRiNWFiNmNmNDIxMzRmN2Y3YWYxNTFmZTJkMw==
5
5
  data.tar.gz: !binary |-
6
- MTlkZWM2MmJhN2Y5NzcyOTE3NWFmOGRkMjIzNDE0MzE0YmU0OTc1MA==
6
+ NDM2NTVjY2Y1NTI5NzZiZTU0MjdmYTAyYmZkZDgyY2JkNTI0NTM4MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGMwZGYwMDdjNmY3OWUxNTk5ZGE5YmEwOWIxYTEyMzUzNDY3MjljZWE3ZGUw
10
- OGRlY2UzODQ2NDg2YTk2MjAyOGM3Mjk2NjIzMDlkMmRiMzczMzQxNzFjYzMz
11
- NDIwZTg4YTdlMWQ2ZTFmMmI4YWQ2Mzc3MjhmM2U5NDFmMzJlNTc=
9
+ M2ZlNGY0MDU0Y2QzOGUzMDE2NDk3NDJhZDI2M2Q5Nzk0YTk5Zjc3YzI1ZDA1
10
+ YzMzZWZmNmJhOTllOGIzZWZkYzE3ZjhjNGFhNDhiY2Q3ODU1NTU4NTJkNDFj
11
+ OGI2NzBlM2MwZjZmZjRmNTgxOWYxODA0MTEyMmFkZTJkM2M4NDk=
12
12
  data.tar.gz: !binary |-
13
- MGEzNWVjYzEyMGM4MGI4N2FkMGY2ZDE4YWI1YTgyOTdkNThiOGFjZjY1ZTA0
14
- MDIyMDQwMzBlOWM5NzdhNTdhYTgyODgyNjYxOTg5ZDdhMDU1YmQyMmYwODcy
15
- OWI3YjQ1ZjYyZjYwNzAxYTYwNGJjMTMwYzEyMTIzNDdiZjkxMzM=
13
+ ODExNTFhMDIyNDQyOWE3ZTY0YzJkM2QzMGUxZjQ5ZGFjZjllMjBkZTA3Mzc3
14
+ NDk0MWFhNTc3NGVjMmU4OTI4YWY3YmU2ODcwZmZlMTU1MDg2NWU2OTkyMWY3
15
+ NzRlNjhmYjkzNWI5MzcyMDMyMTgyYzZjMzE5NTQxYzNhMTczYTY=
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Ribimaybe
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/ribimaybe.svg)](http://badge.fury.io/rb/ribimaybe)
3
4
  [![Travis](https://travis-ci.org/unsymbol/ribimaybe.svg?branch=master)](http://travis-ci.org/unsymbol/ribimaybe)
4
5
  [![Code Climate](https://codeclimate.com/github/unsymbol/ribimaybe.png)](https://codeclimate.com/github/unsymbol/ribimaybe)
5
6
 
@@ -59,9 +60,9 @@ Nothing.map { |x| x * x } # => Nothing
59
60
  include Ribimaybe::Maybe
60
61
 
61
62
  # Wrap functions inside functors and apply them to other functors!
62
- Just do |x|
63
- x * x
64
- end.apply(pure(42)) # => Just(1764)
63
+ Just do |x, y|
64
+ x * y
65
+ end.apply(pure(42)).apply(pure(42)) # => Just(1764)
65
66
 
66
67
  Just do |x|
67
68
  x * x
data/lib/ribimaybe.rb CHANGED
@@ -176,39 +176,10 @@ module Ribimaybe
176
176
  Contract Any, Or[nil, Proc] => Or[Nothing, Just]
177
177
  def Just(value = nil, &fn)
178
178
  return Nothing unless (value || fn)
179
- Just.new(value || fn)
179
+ Just.new(value || fn.curry)
180
180
  end
181
181
 
182
- # Wraps a value in a Just or returns a Nothing.
183
- #
184
- # ==== Attributes
185
- #
186
- # * +value+ - Value to be wrapped.
187
- #
188
- # ==== Examples
189
- #
190
- # pure(nil) # => Nothing
191
- # pure(1) # => Just(1)
192
- #
193
- Contract Any => Or[Nothing, Just]
194
- def pure(value)
195
- Maybe(value)
196
- end
197
-
198
- # Wraps a value in a Just or returns a Nothing.
199
- #
200
- # ==== Attributes
201
- #
202
- # * +value+ - Value to be wrapped.
203
- #
204
- # ==== Examples
205
- #
206
- # rturn(nil) # => Nothing
207
- # rturn(1) # => Just(1)
208
- #
209
- Contract Any => Or[Nothing, Just]
210
- def rturn(value)
211
- pure(value)
212
- end
182
+ alias_method :pure, :Just
183
+ alias_method :rturn, :Just
213
184
  end
214
185
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ribimaybe
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -28,11 +28,18 @@ describe "Applicative Instance" do
28
28
 
29
29
  context "when i something containing a fn" do
30
30
  it "should be apply to apply that fn to something" do
31
- result = Just do |x|
31
+ result = pure do |x|
32
32
  x + x
33
33
  end.apply Just(21)
34
34
  expect(result).to eq Just(42)
35
35
  end
36
+
37
+ it "should be curried by default" do
38
+ result = pure do |x, y|
39
+ x + y
40
+ end.apply(Just(21)).apply(Just(21))
41
+ expect(result).to eq Just(42)
42
+ end
36
43
  end
37
44
  end
38
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribimaybe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - unsymbol