This seems pretty ambiguous, no? It’s not clear why the merge would know to replace the head binding specifically. What if there are two bindings?
It seems like, to get what you want, you’d need to be able to specify “higher order” specs of some kind that explicitly declare the “vars” or whatever that you’re replacing.
var_spec([head], do: [head | _] -> head)
This seems somewhat complex. I wonder if there is a better approach that might allow “nesting” but delegate composition to regular Elixir functions.
s1 = spec(do: {left, right} -> left + right})
spec bind: [head: s1] do
[head | _] -> head
end


















