Skip to content

Releases: dry-rb/dry-monads

v0.4.0

03 Dec 13:59
v0.4.0
12c9d7f
Compare
Choose a tag to compare

v0.4.0 2017-11-11

Changed

  • The Either monad was renamed to Result which sounds less nerdy but better reflects the purpose of the type. Either::Right became Result::Success and Either::Left became Result::Failure. This change is backward-compatible overall but you will see the new names when using old Left and Right methods (citizen428)
  • Consequently, Try::Success and Try::Failure were renamed to Try::Value and Try::Error (flash-gordon)

Added

  • Try#or, works as Result#or (flash-gordon)
  • Maybe#success? and Maybe#failure? (aliases for #some? and #none?) (flash-gordon)
  • Either#flip inverts a Result value (flash-gordon)
  • List#map called without a block returns an Enumerator object (flash-gordon)
  • Right-biased monads (Maybe, Result, and Try) now implement the === operator which is used for equality checks in the case statement (flash-gordon)
      case value
      when Some(1..100)       then :ok
      when Some { |x| x < 0 } then :negative
      when Some(Integer)      then :invalid
      else raise TypeError
      end

Deprecated

  • Direct accessing value on right-biased monads has been deprecated, use the value! method instead. value! will raise an exception if it is called on a Failure/None/Error instance (flash-gordon)

Compare v0.3.1...v0.4.0

v0.3.1

17 Mar 22:56
f30c9fa
Compare
Choose a tag to compare

Fixed

  • Fixed unexpected coercing to Hash on .bind call (flash-gordon)

Compare v0.3.1...v0.3.0

v0.3.0

16 Mar 19:56
4659ef6
Compare
Choose a tag to compare

Added

  • Added Either#either that accepts two callbacks, runs the first if it is Right and the second otherwise (nkondratyev)
  • Added #fmap2 and #fmap3 for mapping over nested structures like List Either and Either Some (flash-gordon)
  • Added Try#value_or (dsounded)
  • Added the List monad which acts as an immutable Array and plays nice with other monads. A common example is a list of Eithers (flash-gordon)
  • #bind made to work with keyword arguments as extra parameters to the block (flash-gordon)
  • Added List#traverse that "flips" the list with an embedded monad (flash-gordon + damncabbage)
  • Added #tee for all right-biased monads (flash-gordon)

Compare v0.3.0...v0.2.1