Skip to content

v1.2.0

Choose a tag to compare

@alex-lairan alex-lairan released this 17 Jan 11:51
· 9 commits to master since this release

What's New

New Features

  • fold method for Either: Pattern match on Right/Left/LeftException with two functions
  • fold method for Maybe: Pattern match on Just/Nothing with two functions
  • Block version of fold that raises on error cases

Bug Fixes

  • Fixed parameter name warnings across Either, Maybe, and List modules

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