linguadata 0.1.1 → 0.1.2

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,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2042e08625e0a7b40800f328540e6d180ada08331d4cac04899d432cd5663d5a
4
- data.tar.gz: e888738880b183d226e258248d9315c6f3b12d05d5aa421b5d85bc807eebe4de
3
+ metadata.gz: 73c63c761385db0071d25a86b64374932728d8004849412857382f14412a6fe6
4
+ data.tar.gz: 13db35cd3eb4ca92130227777459243bee1178e20e30ebaa926d7efb64fab3d8
5
5
  SHA512:
6
- metadata.gz: 6d002bbc8ad073beedc8314c60f7d1a83731c382057d49e2cb9bfc58d70a0f6d898d0c6f0e2ea0e8b812b2a55c4b202eca50a3381f4d975ac7876265f71c2e59
7
- data.tar.gz: '005090ea3dfbd9a31a16f574c5384cda251ba615e8693445a0d86e8bfb5a8df381a46f6ea4f8eedd4902ca7e4eba622777a0c06ae19dbb39b2cd8865cc7656aa'
6
+ metadata.gz: 4bcbee3fb2455fed89cb8081dd2816e5cdaa23282dee13c3cd357a4474d4d907a15239519d5c28935f8a80fadc10c5a5a780299832e0e317162fab27aa1d1981
7
+ data.tar.gz: bf6e4aec32b7d892fd10513ad7f627b623b41ed1a61eda25b4559302d58f65f1fe70de06650061eb5a428971caf03f9e12b15386fa9711f7d296d542a0bd7ac4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linguadata (0.1.1)
4
+ linguadata (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,5 @@
1
- # typed: strict
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Linguadata
5
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
6
5
  end
data/lib/linguadata.rb CHANGED
@@ -1,4 +1,3 @@
1
- # typed: strict
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require_relative "linguadata/version"
@@ -79,6 +78,8 @@ module Linguadata
79
78
 
80
79
  def map_failure(&_block) = self
81
80
 
81
+ def or_else(&_block) = self
82
+
82
83
  def and_then(&block) = block.call(value)
83
84
  end
84
85
 
@@ -101,6 +102,8 @@ module Linguadata
101
102
 
102
103
  def map_failure(&block) = Failure[block.call(error)]
103
104
 
105
+ def or_else(&block) = block.call(error)
106
+
104
107
  def and_then(&_block) = self
105
108
  end
106
109
  end
data/sig/linguadata.rbs CHANGED
@@ -3,26 +3,22 @@ module Linguadata
3
3
 
4
4
  module DataHelpers
5
5
  class ZeroItemData < Data
6
- def self.new: () -> instance
7
-
8
- def self.[]: () -> instance
9
-
10
6
  def deconstruct: () -> [ ]
11
7
 
12
8
  def deconstruct_keys: (?Array[Symbol]?) -> { }
13
9
  end
14
10
 
15
- class OneItemData[T] < Data
11
+ class OneItemData[out T] < Data
16
12
  def deconstruct: () -> [T]
17
13
 
18
- def deconstruct_keys: (?Array[Symbol]?) -> { Symbol: T }
14
+ def deconstruct_keys: (?Array[Symbol]?) -> ({ } | { Symbol: T })
19
15
  end
20
16
  end
21
17
 
22
18
  module Option
23
- type option[T] = Some[T] | None
19
+ type option[out T] = Some[T] | None
24
20
 
25
- class Some[T] < DataHelpers::OneItemData[T]
21
+ class Some[out T] < DataHelpers::OneItemData[T]
26
22
  include _Option[T]
27
23
 
28
24
  def self.new: [T] (T) -> Some[T]
@@ -32,9 +28,13 @@ module Linguadata
32
28
 
33
29
  class None < DataHelpers::ZeroItemData
34
30
  include _Option[bot]
31
+
32
+ def self.new: () -> None
33
+
34
+ def self.[]: () -> None
35
35
  end
36
36
 
37
- interface _Option[T]
37
+ interface _Option[out T]
38
38
  def value: () -> T
39
39
 
40
40
  def unwrap: () -> T
@@ -58,9 +58,9 @@ module Linguadata
58
58
  end
59
59
 
60
60
  module Result
61
- type result[T, E] = Success[T] | Failure[E]
61
+ type result[out T, out E] = Success[T] | Failure[E]
62
62
 
63
- class Success[T] < DataHelpers::OneItemData[T]
63
+ class Success[out T] < DataHelpers::OneItemData[T]
64
64
  include _Result[T, bot]
65
65
 
66
66
  def self.new: [T] (T) -> Success[T]
@@ -68,7 +68,7 @@ module Linguadata
68
68
  def self.[]: [T] (T) -> Success[T]
69
69
  end
70
70
 
71
- class Failure[E] < DataHelpers::OneItemData[E]
71
+ class Failure[out E] < DataHelpers::OneItemData[E]
72
72
  include _Result[bot, E]
73
73
 
74
74
  def self.new: [E] (E) -> Failure[E]
@@ -76,7 +76,7 @@ module Linguadata
76
76
  def self.[]: [E] (E) -> Failure[E]
77
77
  end
78
78
 
79
- interface _Result[T, E]
79
+ interface _Result[out T, out E]
80
80
  def value: () -> T
81
81
 
82
82
  def error: () -> E
@@ -97,7 +97,9 @@ module Linguadata
97
97
 
98
98
  def map_failure: [F] { (E) -> F } -> result[T, F]
99
99
 
100
- def and_then: [U] { (T) -> result[U, E] } -> result[U, E]
100
+ def or_else: [U, F] { (E) -> result[U, F] } -> result[T | U, F]
101
+
102
+ def and_then: [U, F] { (T) -> result[U, F] } -> result[U, E | F]
101
103
  end
102
104
  end
103
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linguadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pechersky