formal-ledger-specifications icon indicating copy to clipboard operation
formal-ledger-specifications copied to clipboard

Use dependent types for PParams

Open carlostome opened this issue 10 months ago • 1 comments

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.

carlostome avatar Feb 04 '25 17:02 carlostome

The potential downsides here are:

  • this uses dependent types visibly in the documentation
  • we can't do open PParams pp anymore (thought I guess we could make a big PParamsHelper module that contains definitions such as maxBlockSize pp = pp maxBlockSize' where maxBlockSize' is the renamed maxBlockSize from 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?

WhatisRT avatar Feb 05 '25 13:02 WhatisRT