Wow. I find it very interesting to say the least.
I notice in your readme (and in your tests) that you are defining the pattern with the string key but matching using the pattern(key: value) which uses the atom keyword syntax. I looked at your macro code, but I’m just not versed enough with macros to quite pin it down…are you somehow converting the keys to atoms in order to match in this way?
Also, am I reading it correctly that the keywords are flattening the keys, e.g. the lat/lng vars in the readme?
And just to “pinch myself” before using this to refactor my controller code, I would be able to do something like the following?:
Before (difficult to read with more form fields):
def fork(conn, %{"fork_form_data" => %{"dest_ib" => dest_ib, "src_ib_gib" => src_ib_gib} = form_data} = params)
to After (composable, and readable):
# Reused patterns
defpat src_ib_gib_p(%{"src_ib_gib" => src_ib_gib})
defpat dest_ib_p(%{"dest_ib" => dest_ib})
# Pattern for just this one function
defpat fork_params_p(%{"fork_form_data" => dest_ib_p(...) = src_ib_gib_p(...)})
def fork(conn, fork_params_p(fork_form_data: form_data, dest_ib: dest_ib, src_ib_gib: src_ib_gib) = params)
Also, I am planning in the future on switching to structs for changeset validation. Would using expat preclude me from using structs?






















