@@ -6,7 +6,7 @@ module Rs
66 VERSION: String
77
88 class TypeError < StandardError
9- def initialize : ( untyped value_type, untyped error_type) -> void
9+ def initialize : [V, E] (T[V] value_type, T[E] error_type) -> void
1010 end
1111
1212 class TypeNilClass < StandardError
@@ -24,94 +24,95 @@ module Rs
2424 class UnwrapErrOnOk < StandardError
2525 end
2626
27- def is_ok : () -> untyped
27+ def is_ok : () -> bool
2828
29- def is_ok_and : () { (? ) -> untyped } -> ( untyped | false)
29+ def is_ok_and : () { (V ) -> bool } -> bool
3030
31- def is_err : () -> untyped
31+ def is_err : () -> bool
3232
33- def is_err_and : () { (? ) -> untyped } -> ( untyped | false)
33+ def is_err_and : () { (E ) -> bool } -> bool
3434
35- def ok : () -> untyped
35+ def ok : () -> Rs::Option[V]
3636
37- def err : () -> untyped
37+ def err : () -> Rs::Option[E]
3838
39- def map : ( untyped value_type) { (? ) -> untyped } -> untyped
39+ def map : [U] (T[U] value_type) { (V ) -> U } -> Result[U, E]
4040
41- def map_or : ( untyped default) { (? ) -> untyped } -> untyped
41+ def map_or : [U] (U default) { (V ) -> U } -> U
4242
43- def map_or_else : ( untyped default) { (? ) -> untyped } -> untyped
43+ def map_or_else : [U] (Proc default) { (V ) -> U } -> U
4444
45- def map_err : ( untyped error_type) { (? ) -> untyped } -> untyped
45+ def map_err : [F] (T[F] error_type) { (E ) -> F } -> Result[V, F]
4646
47- def tap : () { (? ) -> untyped } -> self
47+ def tap : () { (V ) -> void } -> self
4848
49- def tap_err : () { (? ) -> untyped } -> self
49+ def tap_err : () { (E ) -> void } -> self
5050
51- def expect : (untyped msg) -> untyped
51+ def expect : (String msg) -> V
5252
53- def unwrap : () -> untyped
53+ def unwrap : () -> V
5454
55- def expect_err : (untyped msg) -> untyped
55+ def expect_err : (String msg) -> E
5656
57- def unwrap_err : () -> untyped
57+ def unwrap_err : () -> E
5858
59- def and : ( untyped other) -> untyped
59+ def and : [U] (Result[U, E] other) -> Result[U, E]
6060
61- def and_then : ( untyped value_type) { (? ) -> untyped } -> untyped
61+ def and_then : [U] (T[U] value_type) { (V ) -> Result[U, E] } -> Result[U, E]
6262
63- def or : ( untyped other) -> untyped
63+ def or : [F] (Result[V, F] other) -> Result[V, F]
6464
65- def or_else : ( untyped error_type) { (? ) -> untyped } -> untyped
65+ def or_else : [F] (T[F] error_type) { (E ) -> Result[V, F] } -> Result[V, F]
6666
67- def unwrap_or : (untyped default) -> untyped
67+ def unwrap_or : (V default) -> V
6868
69- def unwrap_or_else : () { (? ) -> untyped } -> untyped
69+ def unwrap_or_else : () { (E ) -> V } -> V
7070
71- def self.from_or : (untyped value_type, untyped error) { (?) -> untyped } -> untyped
71+ # type res_init = [V, E] (T[V], E) { () -> V } -> Result[V, E]
72+ def self.from_or : [V, E] (T[V] value_type, E error) { () -> V } -> self
7273
73- def self.from_or? : ( untyped value_type, untyped error) { (? ) -> untyped } -> untyped
74+ def self.from_or? : [V, E] (T[V] value_type, E error) { () -> V? } -> self
7475
75- def self.from_or! : ( untyped value_type, untyped error) { (? ) -> untyped } -> untyped
76+ def self.from_or! : [V, E] (T[V] value_type, E error) { () -> V } -> self
7677 end
7778end
7879
7980class Ok [V, E] < Rs::Result[V, E]
80- @value: untyped
81+ @value: V
8182
82- @value_type: untyped
83+ @value_type: T[V]
8384
84- @error_type: untyped
85+ @error_type: T[E]
8586
86- attr_accessor value_type: untyped
87+ attr_accessor value_type: T[V]
8788
88- attr_accessor error_type: untyped
89+ attr_accessor error_type: T[E]
8990
90- def self.[] : ( untyped value_type, untyped error_type ) { (? ) -> untyped } -> untyped
91+ def self.[] : [V, E] (T[V] value_type, E error ) { () -> V } -> self
9192
9293 def inspect : () -> ::String
9394
94- def == : (untyped other) -> untyped
95+ def == : (Rs::Result[V, E] other) -> Rs::Result[V, E]
9596
96- def initialize : (untyped value) -> void
97+ def initialize : (V value) -> void
9798end
9899
99100class Err [V, E] < Rs::Result[V, E]
100- @error: untyped
101+ @error: E
101102
102- @error_type: untyped
103+ @error_type: T[E]
103104
104- @value_type: untyped
105+ @value_type: T[V]
105106
106- attr_accessor value_type: untyped
107+ attr_accessor value_type: T[V]
107108
108- attr_accessor error_type: untyped
109+ attr_accessor error_type: T[E]
109110
110- def self.[] : ( untyped value_type, untyped error_type ) { (? ) -> untyped } -> untyped
111+ def self.[] : [V, E] (T[V] value_type, E error ) { () -> E } -> self
111112
112113 def inspect : () -> ::String
113114
114- def == : (untyped other) -> untyped
115+ def == : (Rs::Result[V, E] other) -> Rs::Result[V, E]
115116
116- def initialize : (untyped error) -> void
117+ def initialize : (E error) -> void
117118end
0 commit comments