Handle Result Pattern

Use when using the dry-monads Result pattern in Hanami 2.x — wrap outcomes in `Success(value)` or `Failure(error_object)`, chain operations with `Do notation` using `include Dry::Monads::Do.for(:call)` and `yield` inside the `call` method for sequential flows, inject the service object via `Deps["key"]` after registering it in a provider, handle results in Actions with pattern matching (`case result; in Success(v); ...; in Failure(e); ...; end`) rather than unsafe `value!` unwrapping, and model expected failures as data not exceptions. Covers bind/fmap chaining, and use in service objects registered in the DI container.

igmarin 7557e74 2 files · 6.9 KB Updated

File contents

igmarin/hanakai-yaku/tree/main/skills/dry-monads/handle-result-pattern commit 7557e741e6

Frequently asked questions

npx skillmds@latest add igmarin/handle-result-pattern