Skip to content

Releases: dry-rb/dry-monads

v1.8.3

04 Apr 09:23
v1.8.3
Compare
Choose a tag to compare

Fixed

Compare v1.8.2...v1.8.3

v1.8.2

15 Mar 15:06
v1.8.2
Compare
Choose a tag to compare

Fixed

Compare v1.8.1...v1.8.2

v1.8.1

12 Mar 19:25
v1.8.1
8ae07a2
Compare
Choose a tag to compare

Fixed

Compare v1.8.0...v1.8.1

v1.8.0

12 Mar 12:05
v1.8.0
Compare
Choose a tag to compare

Added

  • New extension for RSpec (@flash-gordon in #183):
    One of the pain points of testing monads is referencing class constants from specs.
    This extension catches missing class constants, analyzes the call site and
    returns a matching constant.

    Before, this code would raise a NameError because Failure is a constant
    that is missing in Object:

    example "missing constant" do
      expect(call_operation).to eql(Failure[:some_error, "some message"])
    end

    Now, after enabling the extension, it will return the correct constant:

    Dry::Monads.load_extensions(:rspec)
    
    example "missing constant" do
      Failure[:some_error, "some message"] # => Failure[:some_error, "some message"]
    end

    Out of the box, the extension will check if Success, Failure, Some, and
    None are referenced from a file ending with _spec.rb.

    More involved analysis is possible if you add debug_inspector to your Gemfile:

    group :test do
      gem "debug_inspector"
    end

    This will allow referencing constants from other modules, such as rspec helpers.

    The extension also adds new matchers for Success, Failure, Some, and
    None values.

    expect(Success(1)).to be_success
    expect(Success(1)).to be_success(1)
    expect(Success(1)).to be_success { |x| x > 0 }
    expect(Success(1)).to be_a_success { |x| x > 0 }
    
    expect(Failure(1)).to be_failure(1)
    
    expect(Some(1)).to be_some
    expect(Some(1)).to be_success
    
    expect(None()).to be_none
    expect(None()).to be_failure
  • New extension for super_diff (@flash-gordon in #184):

    Adds support for improved diff output in specs when using the super_diff gem.
    This makes it easier to understand the differences between monad values in test failures.

    To use this extension:

    1. Add super_diff to your Gemfile's test group:
      group :test do
        gem "super_diff"
      end
    2. Load the extension:
      require "dry/monads"
      Dry::Monads.load_extensions(:super_diff)

    This will change the diff output for monad values to be more readable.

    Before:

    -Success({a: 2, c: 2})
    +Success({a: 1, b: 2})
    

    After:

    Success(
    -   a: 2,
    +   a: 1,
    -   c: 2
    +   b: 2
    )
    

Compare v1.7.1...v1.8.0

v1.7.1

21 Jan 11:37
v1.7.1
Compare
Choose a tag to compare

Fixed

Compare v1.7.0...v1.7.1

v1.7.0

07 Jan 16:16
v1.7.0
Compare
Choose a tag to compare

Fixed

Changed

Compare v1.6.0...v1.7.0

v1.6.0

04 Nov 17:55
v1.6.0
8c42280
Compare
Choose a tag to compare

Changed

Compare v1.5.0...v1.6.0

v1.5.0

16 Oct 17:54
v1.5.0
Compare
Choose a tag to compare

Changed

Compare v1.4.0...v1.5.0

v1.4.0

20 Jul 08:19
v1.4.0
e2b762a
Compare
Choose a tag to compare

Added

  • Unit destructures to an empty array (flash-gordon)
  • When .value! called on a Failure value the error references to the value (rewritten + flash-gordon)
    begin
      Failure("oops").value!
    rescue => error
      error.receiver # => Failure("oops")
    end
  • Result#alt_map for mapping failure values (flash-gordon)
    Failure("oops").alt_map(&:upcase) # => Failure("OOPS")
  • Try#recover recovers from errors (flash-gordon)
    error = Try { Hash.new.fetch(:missing) }
    error.recover(KeyError) { 'default' } # => Try::Value("default")
  • Maybe#filter runs a predicate against the wrapped value. Returns None if the result is false (flash-gordon)
    Some(3).filter(&:odd?)  # => Some(3)
    Some(3).filter(&:even?) # => None
    # no block given
    Some(3 == 5).filter     # => None
  • RightBiased#| is an alias for #or (flash-gordon)
    None() | Some(6) | Some(7) # => Some(6)
    Failure() | Success("one") | Success("two") # => Success("one")

Fixed

  • Do notation preserves method visibility (anicholson + flash-gordon)

Changed

  • Coercing nil values to None with Some#fmap is officially deprecated. (flash-gordon)
    Switch to Some#maybe when you expect nil.
    This behavior will be dropped in 2.0 but you can opt-out of warnings for the time being
    Dry::Monads::Maybe.warn_on_implicit_nil_coercion false
  • Minimal Ruby version is 2.6

Compare v1.3.5...v1.4.0

v1.3.5

06 Jan 12:22
v1.3.5
895ece7
Compare
Choose a tag to compare

Added

  • Smarter keys deconstruction in pattern matching (flash-gordon)

Compare v1.3.4...v1.3.5