Closed sitch closed 4 years ago
While I can see that in certain scenarios such a syntax would be very convenient.
However the workflow of the example could be written as:
defmodule Workflow do
use Opus.Pipeline, strict: true
step :lookup_member
check :is_member_ready?
tee :send_email, if: &match?(%{status: "NO_GOOD"}, &1)
step :give_vip_status, if: &match?(%{status: "GOOD"}, &1)
tee :expire_partner_code, if: &match?(%{status: "GOOD"}, &1)
tee :send_email, if: &match?(%{status: "GREAT"}, &1)
# Omitted implementation of the stages
end
Which arguable is much easier to follow as there's no nesting of the conditionals.
Explanation:
Thread a
Kernel.match/1
call through children of the:do
block's:if
clauses. Which would have the benefit of avoiding the need to name the eval stepDesign Concerns:
We would need a strict mode to ensure only patching the
pipeline
with maps from ok tuplesIf there were some sort of strict mode, would it be better to use:
PS
Could also name this
bind
,bind_match
,with_match
or otherwise.