dry-monads 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -3
- data/lib/dry/monads/maybe.rb +7 -0
- data/lib/dry/monads/result.rb +7 -0
- data/lib/dry/monads/right_biased.rb +9 -0
- data/lib/dry/monads/validated.rb +4 -1
- data/lib/dry/monads/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae639cb8c6a7201b6486ed746ea0a07cdd34d39fb3df6565e84a76f4d135693
|
4
|
+
data.tar.gz: afd6150d91c54a90b8b69d3495e4f2408ab250a370b77e066a098eee24c1c100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4eaad835abb5e00b562651d8393a27310e2c6808c3109785d7352123758a7f2e3d54ac293d99c6f1e5ff928b38fc352f0ab6b7637e1399be5444073078528cc
|
7
|
+
data.tar.gz: e2ef0c0ed1a9c759293a09fe640cee08601b0a97f0b8e282f9edd71ce28987e895cd84acf6e2f65e4de58909a6121037378f936ad1f6e68e361df8563c9210d0
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
# v1.0.
|
1
|
+
# v1.0.1 2018-08-11
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
|
5
|
+
* Fixed behavior of `List<Validated>#traverse` in presence of `Valid` values (flash-gordon + SunnyMagadan)
|
6
|
+
|
7
|
+
## Added
|
8
|
+
|
9
|
+
* `to_proc` was added to value constructors (flash-gordon)
|
10
|
+
```ruby
|
11
|
+
[1, 2, 3].map(&Some) # => [Some(1), Some(2), Some(3)]
|
12
|
+
```
|
13
|
+
|
14
|
+
[Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-monads/compare/v1.0.0...v1.0.1)
|
15
|
+
|
16
|
+
# v1.0.0 2018-06-26
|
2
17
|
|
3
18
|
## Added
|
4
19
|
|
@@ -128,7 +143,7 @@
|
|
128
143
|
Failure(:invalid_name).trace # => app/operations/create_user.rb:43
|
129
144
|
```
|
130
145
|
|
131
|
-
* `Dry::Monads::Unit` which can be used as a replacement for `Success(nil)` and in similar situations when you have side effects yet doesn't return anything
|
146
|
+
* `Dry::Monads::Unit` which can be used as a replacement for `Success(nil)` and in similar situations when you have side effects yet doesn't return anything meaningful as a result. There's also the `.discard` method for mapping any successful result (i.e. `Success(?)`, `Some(?)`, `Value(?)`, etc) to `Unit`.
|
132
147
|
|
133
148
|
```ruby
|
134
149
|
# we're making an HTTP request but "forget" any successful result,
|
@@ -147,7 +162,7 @@
|
|
147
162
|
* `Either#value` and `Maybe#value` were both droped, use `value_or` or `value!` when you :100: sure it's safe
|
148
163
|
* `require 'dry/monads'` doesn't load all monads anymore, use `require 'dry/monads/all'` instead or cherry pick them with `require 'dry/monads/maybe'` etc (timriley)
|
149
164
|
|
150
|
-
[Compare v0.4.0...v1.0.0](https://github.com/dry-rb/dry-monads/compare/v0.4.0...
|
165
|
+
[Compare v0.4.0...v1.0.0](https://github.com/dry-rb/dry-monads/compare/v0.4.0...v1.0.0)
|
151
166
|
|
152
167
|
# v0.4.0 2017-11-11
|
153
168
|
|
data/lib/dry/monads/maybe.rb
CHANGED
@@ -37,6 +37,13 @@ module Dry
|
|
37
37
|
def pure(value = Undefined, &block)
|
38
38
|
Some.new(Undefined.default(value, block))
|
39
39
|
end
|
40
|
+
|
41
|
+
# Reutrns a Some wrapper converted to a block
|
42
|
+
#
|
43
|
+
# @return [Proc]
|
44
|
+
def to_proc
|
45
|
+
@to_proc ||= method(:coerce).to_proc
|
46
|
+
end
|
40
47
|
end
|
41
48
|
|
42
49
|
# Returns true for an instance of a {Maybe::None} monad.
|
data/lib/dry/monads/result.rb
CHANGED
@@ -123,6 +123,13 @@ module Dry
|
|
123
123
|
include RightBiased::Left
|
124
124
|
include Dry::Equalizer(:failure)
|
125
125
|
|
126
|
+
# Returns a constructor proc
|
127
|
+
#
|
128
|
+
# @return [Proc]
|
129
|
+
def self.to_proc
|
130
|
+
@to_proc ||= method(:new).to_proc
|
131
|
+
end
|
132
|
+
|
126
133
|
# Line where the value was constructed
|
127
134
|
#
|
128
135
|
# @return [String]
|
data/lib/dry/monads/validated.rb
CHANGED
@@ -163,7 +163,10 @@ module Dry
|
|
163
163
|
# @return [Validated::Invalid]
|
164
164
|
#
|
165
165
|
def apply(val = Undefined)
|
166
|
-
Undefined.
|
166
|
+
Undefined.
|
167
|
+
default(val) { yield }.
|
168
|
+
alt_map { |v| @error + v }.
|
169
|
+
fmap { return self }
|
167
170
|
end
|
168
171
|
|
169
172
|
# Lifts a block/proc over Invalid
|
data/lib/dry/monads/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-monads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Shilnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-equalizer
|