linguadata 0.1.0 → 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: aee10a6dc55a1876434e26a5ce69a31f0aa2af115e695119c24725b0be5d7bd4
4
- data.tar.gz: ef7ca5fc1601445335b0d96e2728901e484d481705ac753b1a61f12de70bc69b
3
+ metadata.gz: 73c63c761385db0071d25a86b64374932728d8004849412857382f14412a6fe6
4
+ data.tar.gz: 13db35cd3eb4ca92130227777459243bee1178e20e30ebaa926d7efb64fab3d8
5
5
  SHA512:
6
- metadata.gz: 142baa27ab1b10eeb5ff881fc6fe19b9da083eca4a7b6fc59b825de562dff0622a726b5382123930b4bb437b2b8e8577a4c288afec765a1cd437288c023fd89a
7
- data.tar.gz: 54159013543920cf8a3245ff2805b61605b4fd6f458d9cfb7eb8777fc79f508c4eb647111f2a2f22a9788ccac6937e8ef8e14dc05b5b2cd88e05c881960b578e
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.0)
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.0"
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"
@@ -67,6 +66,10 @@ module Linguadata
67
66
 
68
67
  def unwrap_failure = error
69
68
 
69
+ def success? = true
70
+
71
+ def failure? = false
72
+
70
73
  def success = Option::Some[value]
71
74
 
72
75
  def failure = Option::None[]
@@ -75,6 +78,8 @@ module Linguadata
75
78
 
76
79
  def map_failure(&_block) = self
77
80
 
81
+ def or_else(&_block) = self
82
+
78
83
  def and_then(&block) = block.call(value)
79
84
  end
80
85
 
@@ -85,6 +90,10 @@ module Linguadata
85
90
 
86
91
  def unwrap_failure = error
87
92
 
93
+ def success? = false
94
+
95
+ def failure? = true
96
+
88
97
  def success = Option::None[]
89
98
 
90
99
  def failure = Option::Some[error]
@@ -93,6 +102,8 @@ module Linguadata
93
102
 
94
103
  def map_failure(&block) = Failure[block.call(error)]
95
104
 
105
+ def or_else(&block) = block.call(error)
106
+
96
107
  def and_then(&_block) = self
97
108
  end
98
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
@@ -85,6 +85,10 @@ module Linguadata
85
85
 
86
86
  def unwrap_failure: () -> E
87
87
 
88
+ def success?: () -> bool
89
+
90
+ def failure?: () -> bool
91
+
88
92
  def success: () -> Option::option[T]
89
93
 
90
94
  def failure: () -> Option::option[E]
@@ -93,7 +97,9 @@ module Linguadata
93
97
 
94
98
  def map_failure: [F] { (E) -> F } -> result[T, F]
95
99
 
96
- 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]
97
103
  end
98
104
  end
99
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.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pechersky