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

[FR] - Use classy era constraints in generators. #702

Closed
locallycompact opened this issue Dec 6, 2024 · 6 comments
Closed

[FR] - Use classy era constraints in generators. #702

locallycompact opened this issue Dec 6, 2024 · 6 comments

Comments

@locallycompact
Copy link
Contributor

In the hedgehog generators we have generators such as

genAddressInEra :: ShelleyBasedEra era -> Gen (AddressInEra era)
genAddressInEra sbe = shelleyAddressInEra sbe <$> genAddressShelley

I think without loss of generality these could all be the type class versions

genAddressInEra :: IsShelleyBasedEra era => Gen (AddressInEra era)
genAddressInEra sbe = shelleyAddressInEra shelleyBasedEra <$> genAddressShelley
@carbolymer
Copy link
Contributor

They're both practically interchangeable. What's the rationale for this change?

@locallycompact
Copy link
Contributor Author

The rational is that we are using these generators downstream, and providing the argument, when we want to construct say a validity interval, seems like unnecessary noise when it can be inferred from the era type.

1 similar comment
@locallycompact
Copy link
Contributor Author

The rational is that we are using these generators downstream, and providing the argument, when we want to construct say a validity interval, seems like unnecessary noise when it can be inferred from the era type.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

@github-actions github-actions bot added the Stale label Jan 30, 2025
@carbolymer
Copy link
Contributor

Having an era just on a type level seems like an inconvenience when working with multiple eras. See this test for example:

AnyShelleyBasedEra sbe <- H.forAll H.enumBounded

How would you rewrite it without value level era witnesses generators? This des not seem to work for me:

let genCert' :: IsShelleyBasedEra era => H.Gen (Certificate era)
    genCert' = genCertificate shelleyBasedEra
AnyShelleyBasedEra (sbe :: ShelleyBasedEra era) <- H.forAll H.enumBounded
cert1 <- H.forAll $  genCert' @era

@github-actions github-actions bot removed the Stale label Jan 31, 2025
@locallycompact
Copy link
Contributor Author

Yeah I think I agree with this now.

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 a pull request may close this issue.

2 participants