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

Add full support for maps #300

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

maxnordlund
Copy link

@maxnordlund maxnordlund commented Oct 22, 2022

This is an effort to fix #289 and related issues. Since I've never hacked on PropEr itself I'm not sure if I got it right, and we can always fall back on the ?LET solution, but I figured it would be good to have maps as a first class citizen.

Edit: I removed mentions of the other implementation since ?CONTAINER is the way to go.

@maxnordlund maxnordlund marked this pull request as draft October 22, 2022 14:30
@kostis
Copy link
Collaborator

kostis commented Oct 24, 2022

Thanks for the PR! It's clearly something that PropEr needs.

FYI, I've also started working on this, back in April/May or so, also following the ?CONTAINER approach, but soon hit a wall in some of my tests and then I needed to do other stuff, so I've put it on the side. I'll try to dig up that work and see how I can merge it here.

One thing that currently bothers me (big time, actually) on this PR is that it contains no tests, even though the issues that it references do contain some. I think this is top priority.

@kostis
Copy link
Collaborator

kostis commented Oct 25, 2022

@maxnordlund Rebasing this PR on the current master should now get past the point that GitHub actions fail when generating documentation.

@maxnordlund
Copy link
Author

Thanks for the PR! It's clearly something that PropEr needs.

❤️

FYI, I've also started working on this, back in April/May or so, also following the ?CONTAINER approach, but soon hit a wall in some of my tests and then I needed to do other stuff, so I've put it on the side. I'll try to dig up that work and see how I can merge it here.

That's good; means I was on the right track.

One thing that currently bothers me (big time, actually) on this PR is that it contains no tests, even though the issues that it references do contain some. I think this is top priority.

I was wonder about that. Can I use PropEr to test PropEr itself, or do you use something else? Or just plain ol' EUnit? I also wanted to validate the basic design before spending too much time writing tests.

@maxnordlund
Copy link
Author

maxnordlund commented Oct 25, 2022

I've hacked a bit more on it and hit a major snag. The shrinking framework assumes get_indices works the same for both types and instances. But in the case of maps that doesn't hold because we want to allow proper types as keys.

I'll take another stab at it hopefully tomorrow, and try to teach the shrinkers about keys and not just indices.


A small aside, I found it very confusing how you're supposed to test stuff. I guess I'm used to having EUnit tests at the bottom of the file, but after I found proper_test, I still have a hard time reading it. I just spliced in a couple of examples after fixed_list and it generated some failures, so I assume that's what one needs to do.

@maxnordlund
Copy link
Author

@kostis do you have any ideas of how to go forward with this PR?

I don't want to have to rewrite too much of the shrinking if I can help it. Maybe have separate strategies for maps instead of trying to shoehorn them into the existing shrinkers.

This makes it quick and easy to sump the value of variables during
development of PropEr itself. Don't forget to remove them before
committing though.
@maxnordlund
Copy link
Author

I decided to try the custom shrinker approach and now the tests pass, which is promising. Fixed maps never shrinks their keys, normal maps do (both change and remove keys). Both types shrink their values.

@maxnordlund maxnordlund marked this pull request as ready for review October 29, 2022 17:14
@maxnordlund
Copy link
Author

@kostis I rebased on latest master (and fixuped a couple of commits) and this apparently made it so that you must approve the workflow again.

@maxnordlund
Copy link
Author

So I kept hacking on it yesterday, but now I'm stuck and need your help. You can see what I've done in the two commits, and if you run the tests in ab18886 you get this weird error where it can't find the type map/6, but how/why did it even try such a high arity?

The last commit gets a different error, but I can't figure out why. Also, the code in proper_typeserver is really hard to understand. What/how does rec work? Why is every argument prefixed with a boolean? Etc.

Anyway, could you please take a look and see if you can figure it out?

@maxnordlund
Copy link
Author

Ping @kostis

@asabil
Copy link

asabil commented Jun 26, 2024

Any update on this?

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

Successfully merging this pull request may close these issues.

Generators inside maps
3 participants