nubank / matcher-combinators

Library for creating matcher combinator to compare nested data structures
Other
468 stars 23 forks source link

align match? fns #126

Closed dchelimsky closed 4 years ago

dchelimsky commented 4 years ago

There are currently 3 versions of match?:

They all have different semantics, which is cause for much confusion.

This PR aligns them as follows:

What changed?

dchelimsky commented 4 years ago

NOTE: since this is a breaking change, we should hold off on releasing 2.0.0 until this is vetted and merged.

gabrielgiussi commented 4 years ago

Which is the use case for the 1-arity version?

dchelimsky commented 4 years ago

Which is the use case for the 1-arity version?

It separates the details exposed by the match function, used in e.g. the match? assert-expr, from the "matchiness" (boolean result) indicated by those details.

https://github.com/nubank/matcher-combinators/blob/7339a68f8a9e9c0afe80fa86f904426c0fa38a97/src/clj/matcher_combinators/clj_test.clj#L51-L52

We only use the result# in this case when match? returns false in order to report out to the user, but this code doesn't have to know the semantics of the result of match.

dchelimsky commented 4 years ago

Suggestion from @rafaelzlisboa in standup today: perhaps the 2 arities of match? should be different functions. Moving this to Draft state while we explore this further.

dchelimsky commented 4 years ago

We went with #128 instead.