Hey José, thanks for your input!
haven’t explored this, but will try and report back how it goes.
Actually, I’m doing nothing with operators in expat. It’s just that if you define a pattern like
defpat foo %{"a" => a}
defpat bar %{"b" => b}
defpat baz(foo() = bar())
baz(...) = %{a: "missing b", c: "unused"} # this would expand to
%{"a" => a} = %{"b" => b} = %{a: "missing b", c: "unused"}
so you are just using the standard = operator to match on two patterns at the same time. I just mentioned it on the README so people could know how to intersect two patterns (will s/mixing/intersect/ that part on the guide)
That would be a nice idea to explore, not sure if guards should be inside of patterns in Elixir tho, and not sure if we do need to extend Elixir for it. Actually when I was writing Expat I got tempted to allow guards but didnt for the sake of simplicity and time (just being lazy actually, got things to do at Spec). But I was thinking of things like:
defpat foo(%{"foo" => x, "bar" => y}) when x in [:foo, :bar] and is_binary(y)
# but the way Expat currenly works, doing
foo(y: 1) # would expand to
%{"foo" => _, "bar" => 1) when _ in [:foo, :bar] and is_binary(1)
# so when ignoring `x` like in the previous example, I'd need to also
# ignore any guard that uses it
# so just to KISS I went for not yet implementing guards
# (wanted to release early an gather feedback)
would be really nice, will see how far I can get and report back to you.
Thanks for reading!






















