ribimaybe 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/ribimaybe.rb +13 -12
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjBmMGVlZWNhZmRjMjE3ZjQzODZmYzVjYTIwNTE5MzUwYTBhZjQ3ZA==
4
+ Y2ZiYzYyM2ZhNjJmNjZmZWQ0ODEzNTE5Nzc2ODNhMzZhZTkxODVhZA==
5
5
  data.tar.gz: !binary |-
6
- Nzk2ZDNjMDBhZjIwYzI4ZGY2ZjNlYWM0MzZmYThlZDQ2MDYwYThjMQ==
6
+ YTBjMmYwM2FkNjUwNDc0MjhiN2Y4MjM4YjMzNGQ0YjQ3MmQ5OTc3Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTA5NmVjYzAwZDc5YjExYmNhYzU3ODIzODg2OWZjMTdhN2EyNDYxMDlmODYx
10
- NGI1ZmFhNGYzMGJlZjc5YzZhOTUwOTIzNDNhZmJhZjcwMjNlMDc2MWQxODk5
11
- YmIwNGQxMTZmOTY3ZmNjZGZlNWFhZmYyMTRmYjU4Y2NhYjQyMDE=
9
+ NjE4MGQ5MjNjZTViZjUyMGNhNDRjNWM4MjczZTQ1YzNmMjAzYzNjNDc3NjQw
10
+ MzdmYjYzOThhZTZlOTY3ZDc1NDFhMzE3MDkyODJjMTc1Njc0NjhkMmJiNDM2
11
+ MTgzMWY3ZTVmOTVjMTE5NjM1Zjc3YzQ0ZDg3MTk2YjEwYmJkYWE=
12
12
  data.tar.gz: !binary |-
13
- M2I4NDU1NjRiOTQwYTUzNzFjOTNkZTRhMWVmYzViYTY3OTBjMjM0OTQxYmI0
14
- MWE4YzA5MDNhNWM4ZmZhYjI1NmI3M2YyNzQzYzUwYmI2NWMyNzA2NzY5ZWZk
15
- Y2UzNzNmOTg1YjU3NGYwZTQ1YmE4NDMxY2VmODczYTZlZjY3ODg=
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
- # * +_+ - Irrelevant default.
81
- # * +fn+ - Function to be applied inside our Just.
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 } # => Just(2)
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 another Just and re-wraps the
109
- # result in another Just.
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 whose value will be use in function application.
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. Pass either a block
145
- # or a function.
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
@@ -1,3 +1,3 @@
1
1
  module Ribimaybe
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  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.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - unsymbol