-
Notifications
You must be signed in to change notification settings - Fork 23
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
Convert to use typesafe features in data types #37
Conversation
txScriptValidityToIsValid :: TxScriptValidity era -> L.IsValid | ||
txScriptValidityToIsValid = scriptValidityToIsValid . txScriptValidityToScriptValidity | ||
data TxScriptValidityFeature era where | ||
TxScriptValiditySupportedInAlonzoEra :: TxScriptValidityFeature AlonzoEra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, I've not changed the code. I've only renamed TxScriptValiditySupportedInEra
to TxScriptValidityFeature
.
The rename is a suggestion because Feature
is shorter than SupportedInEra
.
As for why the existing code does this.
The constructor serves as a witness that the pair is valid. If someone wants to construct a FeatureValue
for a particular feature/era pair they must supply the witness.
The witness proves the pair is valid and if one cannot be supplied, that means the pair is invalid.
This is how invalid pairs are made into compile errors making the code type-safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the type level checks would be enough, right? So why not use phantom parameters:
data Feature era feature = Feature
You could still have compile-time checks without manually creating a lot of constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add haddocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to add haddocks as soon as I verify the solution is viable for protocol parameters as well.
f8ba1e9
to
d7b9064
Compare
09cce23
to
80f3d5e
Compare
4e5cfdd
to
1abeff1
Compare
…ng new Feature API.
…using new Feature API.
… API. Convert MultiAsseteFeatureSupportedInEra to MultiAssetFeature using new Feature API.
80f3d5e
to
8738685
Compare
This PR is stale because it has been open 45 days with no activity. |
Description
Add your description here, if it fixes a particular issue please provide a
link
to the issue.
Changelog
Checklist
See Runnings tests for more details
CHANGELOG.md
for affected package.cabal
files are updatedhlint
. See.github/workflows/check-hlint.yml
to get thehlint
versionstylish-haskell
. See.github/workflows/stylish-haskell.yml
to get thestylish-haskell
versionghc-8.10.7
andghc-9.2.7
Note on CI
If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.