[Dry::Transaction] Pattern matching of steps inside the around step

Hi! I started using dry-transaction gem and noticed a small problem. What I’m trying to do is to replace the huge service classes with dry abstractions. I started with Dry::Transaction by adding steps.
Currently I have a file with 10 steps, and the third one is the around step. And I want the ability to pattern match steps below the around one. I started with the straightforward implementation:

transaction = MyTransaction.new
transaction.(input) do |m|
  m.success { |v| v }
  m.failure :some_step_below_the_around do |v|
    puts "Failed in some step"
  m.failure :around_step do |v|
    puts "Failed in around step"

I noticed that the failure match is called for failure :around_step for all steps above the around one.

I found a workaround to have the ability to pattern match on specific step inside the around:

results = []
transaction.(input) do |m|
  m.success {}

  m.failure :around do |value|
    ::Dry::Transaction::ResultMatcher.(Dry::Monads::Failure(value)) do |n|
      n.success {}

      n.failure :some_step_below_the_around do |v|
        results << "Failed in some step"

results #["Failed in some step"]

But I thought that this is not good enough because api of the gem might change and wanted to share.
I’ve added some specs about this problem here.

Hi @sineed, thanks for writing this up. I think this is a legitimate bug, and we should fix it. I’ve opened https://github.com/dry-rb/dry-transaction/issues/99 to track the issue.