Class: TypedCache::Left
- Inherits:
-
Object
- Object
- TypedCache::Left
- Defined in:
- lib/typed_cache/either.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
(also: #value)
readonly
@rbs! include _Either[E, bot].
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#bind ⇒ Object
: [E2, R2] () { ® -> either[E2, R2] } -> either[E | E2, R2].
-
#deconstruct_keys(keys) ⇒ Object
: (Array) -> ({ error: E }).
-
#fold(left_fn, right_fn) ⇒ Object
: [T, E, R] (^(E) -> T, ^® -> T) -> T.
- #hash ⇒ Object
-
#initialize(error) ⇒ Left
constructor
: (E) -> void.
- #inspect ⇒ Object
-
#left? ⇒ Boolean
: -> true.
-
#map ⇒ Object
: [T] () { ® -> T } -> either[E, T].
-
#map_left ⇒ Object
: [F] () { (E) -> F } -> either[F, R].
-
#right? ⇒ Boolean
: -> false.
-
#right_or_else {|error| ... } ⇒ Object
: (^(E) -> void) -> bot.
-
#right_or_raise! ⇒ Object
: -> bot.
- #to_s ⇒ Object
Constructor Details
#initialize(error) ⇒ Left
: (E) -> void
47 48 49 |
# File 'lib/typed_cache/either.rb', line 47 def initialize(error) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly) Also known as: value
@rbs! include _Either[E, bot]
42 43 44 |
# File 'lib/typed_cache/either.rb', line 42 def error @error end |
Instance Method Details
#==(other) ⇒ Object
91 92 93 |
# File 'lib/typed_cache/either.rb', line 91 def ==(other) other.is_a?(Left) && other.error == error end |
#bind ⇒ Object
: [E2, R2] () { ® -> either[E2, R2] } -> either[E | E2, R2]
73 |
# File 'lib/typed_cache/either.rb', line 73 def bind(&) = self |
#deconstruct_keys(keys) ⇒ Object
: (Array) -> ({ error: E })
86 87 88 |
# File 'lib/typed_cache/either.rb', line 86 def deconstruct_keys(keys) { error: } end |
#fold(left_fn, right_fn) ⇒ Object
: [T, E, R] (^(E) -> T, ^® -> T) -> T
81 82 83 |
# File 'lib/typed_cache/either.rb', line 81 def fold(left_fn, right_fn) left_fn.call(error) end |
#hash ⇒ Object
96 |
# File 'lib/typed_cache/either.rb', line 96 def hash = [Left, error].hash |
#inspect ⇒ Object
102 |
# File 'lib/typed_cache/either.rb', line 102 def inspect = "Left(#{error.inspect})" |
#left? ⇒ Boolean
: -> true
53 |
# File 'lib/typed_cache/either.rb', line 53 def left? = true |
#map ⇒ Object
: [T] () { ® -> T } -> either[E, T]
69 |
# File 'lib/typed_cache/either.rb', line 69 def map(&) = self |
#map_left ⇒ Object
: [F] () { (E) -> F } -> either[F, R]
77 |
# File 'lib/typed_cache/either.rb', line 77 def map_left(&) = Left.new(yield(error)) |
#right? ⇒ Boolean
: -> false
57 |
# File 'lib/typed_cache/either.rb', line 57 def right? = false |
#right_or_else {|error| ... } ⇒ Object
: (^(E) -> void) -> bot
61 |
# File 'lib/typed_cache/either.rb', line 61 def right_or_else(&) = yield(error) |
#right_or_raise! ⇒ Object
: -> bot
65 |
# File 'lib/typed_cache/either.rb', line 65 def right_or_raise! = raise(error) |
#to_s ⇒ Object
99 |
# File 'lib/typed_cache/either.rb', line 99 def to_s = "Left(#{error})" |