ribimaybe 0.0.6 → 0.0.8
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 +8 -8
- data/lib/ribimaybe.rb +13 -12
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2ZiYzYyM2ZhNjJmNjZmZWQ0ODEzNTE5Nzc2ODNhMzZhZTkxODVhZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTBjMmYwM2FkNjUwNDc0MjhiN2Y4MjM4YjMzNGQ0YjQ3MmQ5OTc3Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjE4MGQ5MjNjZTViZjUyMGNhNDRjNWM4MjczZTQ1YzNmMjAzYzNjNDc3NjQw
|
10
|
+
MzdmYjYzOThhZTZlOTY3ZDc1NDFhMzE3MDkyODJjMTc1Njc0NjhkMmJiNDM2
|
11
|
+
MTgzMWY3ZTVmOTVjMTE5NjM1Zjc3YzQ0ZDg3MTk2YjEwYmJkYWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWQzMWIzMTk1ZGVkMDQ0ZTE0OWU1ZjExNGQyZDk2OTBkZmM1YzJhNTYwZGVl
|
14
|
+
NjUwMDJiNTUxYzExYzhiOWY0ZWRmOTBkOGQ2ZjE0Nzg2ZDU2ZjBhNzM4ZTM0
|
15
|
+
ODhhYzhiMGZmNTMzZGFhNzAxMTJjNTIyZDEwNjZlMThmM2ZmNDk=
|
data/lib/ribimaybe.rb
CHANGED
@@ -77,8 +77,8 @@ module Ribimaybe
|
|
77
77
|
#
|
78
78
|
# ==== Attributes
|
79
79
|
#
|
80
|
-
# * +_+ -
|
81
|
-
# * +fn+ - Function to be applied inside
|
80
|
+
# * +_+ - Default value that's never used.
|
81
|
+
# * +fn+ - Function to be applied to value inside Just.
|
82
82
|
#
|
83
83
|
# ==== Examples
|
84
84
|
#
|
@@ -87,7 +87,7 @@ module Ribimaybe
|
|
87
87
|
#
|
88
88
|
Contract Any, Proc => Any
|
89
89
|
def maybe(_, &fn)
|
90
|
-
fn.(@value)
|
90
|
+
fn.curry.(@value)
|
91
91
|
end
|
92
92
|
|
93
93
|
# Applies fn to a value inside Just and re-wraps it in another Just.
|
@@ -98,19 +98,20 @@ module Ribimaybe
|
|
98
98
|
#
|
99
99
|
# ==== Examples
|
100
100
|
#
|
101
|
-
# Just(1).map { |x| x + 1 }
|
101
|
+
# Just(1).map { |x| x + 1 } # => Just(2)
|
102
|
+
# Just { |x, y| x + y }.map { |f| f.(1) } # => Just(#<Proc:...>)
|
102
103
|
#
|
103
104
|
Contract Proc => Just
|
104
105
|
def map(&fn)
|
105
|
-
Just.new(fn.(@value))
|
106
|
+
Just.new(fn.curry.(@value))
|
106
107
|
end
|
107
108
|
|
108
|
-
# Applies fn inside Just to a value in
|
109
|
-
#
|
109
|
+
# Applies fn inside Just to a value in a Just and re-wraps the result in
|
110
|
+
# a Just. Note that functions are curried by default.
|
110
111
|
#
|
111
112
|
# ==== Attributes
|
112
113
|
#
|
113
|
-
# * +value+ - Maybe
|
114
|
+
# * +value+ - Maybe value.
|
114
115
|
#
|
115
116
|
# ==== Examples
|
116
117
|
#
|
@@ -120,7 +121,7 @@ module Ribimaybe
|
|
120
121
|
#
|
121
122
|
Contract Or[Nothing, Just] => Or[Nothing, Just]
|
122
123
|
def apply(value)
|
123
|
-
value.map { |v| @value.(v) }
|
124
|
+
value.map { |v| @value.curry.(v) }
|
124
125
|
end
|
125
126
|
|
126
127
|
# Applies fn to value inside Just (note contract constraint).
|
@@ -137,12 +138,12 @@ module Ribimaybe
|
|
137
138
|
#
|
138
139
|
Contract Proc => Just
|
139
140
|
def bind(&fn)
|
140
|
-
fn.(@value)
|
141
|
+
fn.curry.(@value)
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
144
|
-
# Converts nil to Nothing or lifts value into a Just.
|
145
|
-
# or
|
145
|
+
# Converts nil to Nothing or lifts value into a Just. Accepts a optional
|
146
|
+
# block or value.
|
146
147
|
#
|
147
148
|
# ==== Attributes
|
148
149
|
#
|
data/lib/version.rb
CHANGED