v1.2.0
What's New
New Features
- fold method for Either: Pattern match on
Right/Left/LeftExceptionwith two functions - fold method for Maybe: Pattern match on
Just/Nothingwith two functions - Block version of fold that raises on error cases
Bug Fixes
- Fixed parameter name warnings across
Either,Maybe, andListmodules
Example Usage
# Either fold
result = Monads::Right(String, Int32).new(42).fold(
->(x : Int32) { "success: #{x}" },
->(e : String) { "error: #{e}" }
)
# => "success: 42"
# Maybe fold
value = Monads::Just.new(42).fold(
->(x : Int32) { "value: #{x}" },
->{ "nothing" }
)
# => "value: 42"Full Changelog: v1.1.0...v1.2.0