Module: Literal::Monads
- Included in:
- Types
- Defined in:
- lib/literal/monads.rb
Constant Summary collapse
- Nothing =
Literal::Nothing
- Left =
Literal::Left
- Right =
Literal::Right
- Some =
Literal::Some
- Maybe =
Literal::Maybe
- Either =
Literal::Either
- Result =
Literal::Result
Instance Method Summary collapse
- #Either(left_type, right_type) ⇒ Object
- #Left(type) ⇒ Object
- #Maybe(type) ⇒ Object
- #Result(type) ⇒ Object
- #Right(type) ⇒ Object
- #Some(type) ⇒ Object
- #Success(type) ⇒ Object
Instance Method Details
#Either(left_type, right_type) ⇒ Object
16 17 18 |
# File 'lib/literal/monads.rb', line 16 def Either(left_type, right_type) Literal::EitherType.new(left_type, right_type) end |
#Left(type) ⇒ Object
36 37 38 |
# File 'lib/literal/monads.rb', line 36 def Left(type) Literal::LeftType.new(type) end |
#Maybe(type) ⇒ Object
12 13 14 |
# File 'lib/literal/monads.rb', line 12 def Maybe(type) Literal::MaybeType.new(type) end |
#Result(type) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/literal/monads.rb', line 20 def Result(type, &) if block_given? Literal::ResultType.new(type).try(&) else Literal::ResultType.new(type) end end |
#Right(type) ⇒ Object
40 41 42 |
# File 'lib/literal/monads.rb', line 40 def Right(type) Literal::RightType.new(type) end |
#Some(type) ⇒ Object
32 33 34 |
# File 'lib/literal/monads.rb', line 32 def Some(type) Literal::SomeType.new(type) end |
#Success(type) ⇒ Object
28 29 30 |
# File 'lib/literal/monads.rb', line 28 def Success(type) Literal::SuccessType.new(type) end |