formal-ledger-specifications
formal-ledger-specifications copied to clipboard
Use dependent types for PParams
Change PParams to use dependent types in the spirit of the Shelley spec. For this, we replace the record by:
data PParamName : Type
maxBlockSize : PParamName
typeOfPParam : PParamName -> Type
PParams : Type
PParams = (ppn : PParamName) -> typeOfPParam ppn
PParamsUpdate : Type
PParamsUpdate = (ppn : PParamName) -> Maybe (typeOfPParam ppn)
PParamGroup : PParamName -> PParamGroup
This solves some awkwardness, for example, in that the current specification doesn't formally link parameter groups to parameters.
The potential downsides here are:
- this uses dependent types visibly in the documentation
- we can't do
open PParams ppanymore (thought I guess we could make a bigPParamsHelpermodule that contains definitions such asmaxBlockSize pp = pp maxBlockSize'wheremaxBlockSize'is the renamedmaxBlockSizefrom above) - no more postfix projections
Now that I think about it, I feel that these slightly outweigh the upsides. But maybe there are things that I haven't yet considered?