Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty raw maps as suggested match patterns #57

Closed
zachallaun opened this issue Nov 5, 2023 · 2 comments
Closed

Remove empty raw maps as suggested match patterns #57

zachallaun opened this issue Nov 5, 2023 · 2 comments

Comments

@zachallaun
Copy link
Owner

Proposal

Mneme should no longer generate empty maps as a pattern for maps that contain keys. Note that the behavior for structs would remain the same.

# Maps:
auto_assert %{id: 1, name: "Zach"}
# would NO LONGER SUGGEST
auto_assert %{} <- %{id: 1, name: "Zach"}

# Structs:
auto_assert %User{id: 1, name: "Zach"}
# would still suggest
auto_assert %User{} <- %User{id: 1, name: "Zach"}

Note that if you edited a match to assert an empty map, it would still succeed and be offered as a suggestion when updating. For instance:

auto_assert %{x: 1, y: %{}} <- %{x: 2, y: %{z: 3}}
# would still suggest
auto_assert %{x: 2, y: %{}} <- %{x: 2, y: %{z: 3}}

Context

Two recent issues got me thinking about the utility of suggesting empty maps as patterns: #55, #56.

In my own usage, empty raw maps are rarely useful patterns, whereas empty structs often are, especially when nested.

Request for comment

I'd greatly appreciate any feedback on whether this change would be beneficial/detrimental/neutral to your usage of Mneme. Do you ever use empty raw maps in patterns? Would you miss them?

@axelson
Copy link
Contributor

axelson commented Nov 12, 2023

Big 👍 from me. I don't think that there's any use in a top-level empty map pattern.

@zachallaun
Copy link
Owner Author

Going to move forward with this!

@zachallaun zachallaun changed the title Proposal: Remove empty raw maps as suggested match patterns Remove empty raw maps as suggested match patterns Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants