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

Isolate mutations from calls to Gen.bind #51

Merged
merged 4 commits into from
Sep 4, 2021

Conversation

TysonMN
Copy link
Member

@TysonMN TysonMN commented Sep 3, 2021

Revolves #52

...by working around hedgehogqa/fsharp-hedgehog#192.

@dharmaturtle, after this completes and a new version is released, you should update Hedgehog.Xunit to require this new version and make a release so that users get this bug fix.

@TysonMN
Copy link
Member Author

TysonMN commented Sep 3, 2021

The string/keyword mutable no longer occurs in the main project. There are still mutations though such as those in shuffle and shuffleCase (c.f. hedgehogqa/fsharp-hedgehog#192). I will fix those soon in a separate PR.

@TysonMN
Copy link
Member Author

TysonMN commented Sep 3, 2021

Quoting @cmeeren from hedgehogqa/fsharp-hedgehog#192 (comment)

...should I prioritize implementing them without immutability? (That might impact performance, so I'd rather not.)

I think correctness is more important than efficiency, so I think we should merge this PR because it fixes bugs and worry about performance another day.

@cmeeren
Copy link
Collaborator

cmeeren commented Sep 3, 2021

Thanks a lot! I don't have the capacity to do a thorough review of this. If you think it is ready to go, I'll merge and release a new version. Could you also update the changelog and fsproj version?

@cmeeren
Copy link
Collaborator

cmeeren commented Sep 3, 2021

Alternatively, if you'd rather wait to release this until other PRs are merged, don't increment the fsproj version (that triggers a release).

@cmeeren
Copy link
Collaborator

cmeeren commented Sep 3, 2021

I think correctness is more important than efficiency

I agree. I wanted to hold out for a couple of days in case it was fixed upstream, and then I forgot all about it.

@cmeeren
Copy link
Collaborator

cmeeren commented Sep 3, 2021

And if this closes #52, could you add that to the OP so it's done automatically?

return fun dt -> shape.Set dt f } }
member _.Visit(shape: ShapeMember<'DeclaringType, 'MemberType>) =
autoInner<'MemberType> config recursionDepths
|> Gen.map (fun mt -> fun dt -> shape.Set dt mt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. (Pity that we can't |> Gen.map shape.Set though.)

@TysonMN
Copy link
Member Author

TysonMN commented Sep 4, 2021

Oh, I think the issue with efficiency was that your immutable code was quadratic (due to repeatedly concatenating a single character to a string accumulator). Pretty sure the runtime of my code is linear.

@TysonMN
Copy link
Member Author

TysonMN commented Sep 4, 2021

Alternatively, if you'd rather wait to release this until other PRs are merged, don't increment the fsproj version (that triggers a release).

Let's wait until I also fix the shuffle functions.

@TysonMN
Copy link
Member Author

TysonMN commented Sep 4, 2021

I don't have the capacity to do a thorough review of this. If you think it is ready to go, I'll merge [...]

Yes, it's ready. In particular, I first added tests that fail send now they pass.

@cmeeren
Copy link
Collaborator

cmeeren commented Sep 4, 2021

Excellent! Could you also update the changelog (repo root) and fsproj version? It will then be released automatically once I merge.

@TysonMN
Copy link
Member Author

TysonMN commented Sep 4, 2021

I updated the changelog.

Can we wait to release a new version until after I fix the same bugs in shuffle and shuffleCase?

The exact same mutations still happen, but now they happen all at once instead of alternating with calls to Gen.bind (via let! in gen CE)
@TysonMN TysonMN force-pushed the bug_fix_333_Hedgehog branch from a4a8f72 to fada582 Compare September 4, 2021 12:38
@TysonMN
Copy link
Member Author

TysonMN commented Sep 4, 2021

(Force pushed to improve the names of the tests)

@cmeeren cmeeren merged commit 58f8076 into hedgehogqa:master Sep 4, 2021
@cmeeren
Copy link
Collaborator

cmeeren commented Sep 4, 2021

Excellent, thank you very much!

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.

3 participants