dry-monads
dry-monads copied to clipboard
Useful, common monads in idiomatic Ruby
This is a gotcha that I myself run into frequently when I attempt to write `Operation` / `Command` / `UseCase` / `Service` (_shudder_) classes with `Result` / `Do`. It's definitely...
`Do::Halt` is a `StandardError`. Because of that rescue block can unexpectedly catch it in a wrapped method. This problem has been reported at https://github.com/dry-rb/dry-monads/issues/72 If `Do::Halt` was a direct `Exception`...
`Dry::Monads::Task` has an alias for [its `bind` method as `then`](https://github.com/dry-rb/dry-monads/blob/35d742fe872372a644eb7a3cf9d875736874b3e2/lib/dry/monads/task.rb#L129). Ruby 2.6 itself [added `Kernel#then` as an alias to `Kernel#yield_self`](https://www.ruby-lang.org/en/news/2018/12/25/ruby-2-6-0-released/) (first note) ~11 months after `dry-monads` added its alias. `dry-monads`'s...
## Describe the bug When pattern matching inside a class method an `include Dry::Monads[:maybe]` is needed, the `extend Dry::Monads[:maybe]` is not enough and causes a crash. ## To Reproduce Simple...
## Describe the bug When a right-biased type is wrapping an array value, it's not possible to unwrap it via pattern-matching. ## To Reproduce ```ruby require "dry/monads" include Dry::Monads[:result] Success(1)...
This allows deconstruct to work correctly Fixes: #176
## Describe the bug The following code should work: ```ruby case Try { n / d } in Value(x) puts "n / d = #{x}" in Error(ZeroDivisionError => ex) puts...