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

Naming conventions for state-like record constructors

Open carlostome opened this issue 6 months ago • 1 comments
trafficstars

There seems to be no convention on the naming of record constructors for state-like record types. This make it hard to mentally navigate some of the rules.

We currently have:

⟦_,_,_,_,_⟧ᵉ' for EpochState
⟦_,_,_,_⟧ᵘ for UTxOState
⟦_,_,_⟧ᵈ for DState 
⟦_,_,_⟧ˡ for LState 

(There are probably more)

carlostome avatar May 15 '25 08:05 carlostome

I agree it's a bit messy, but I'm not sure how to do better here...

WhatisRT avatar May 15 '25 15:05 WhatisRT

I would group this issue under #763 .

The question is: How do we decompose a record into its constituents in a human-readable and -memorable way?

My personal preference is to use whatever default record the language (Agda) provides, i.e. plain record, because that default has a life outside of our specific domain. Unfortunately, the default tends to be rather verbose. That's why most rules in our domain use the "funny brackets" syntax, e.g. ⟦_,_,_,_,_⟧, sometimes with post-formatting for vertical alignment even.

There are a few rules that use record, though mostly for updates:

Image

HeinrichApfelmus avatar May 19 '25 14:05 HeinrichApfelmus

Generally I like record updates as well. Their downside is that they offer less presentation options than the vectors which, paradoxically, can lead to them being harder to understand. Here's an example:

Image

Compare this with applyRUpd (btw. apparently this is broken again on master, @carlostome or @williamdemeo can one of you have a look?):

Image

Both of these are nested record updates, and the one at the bottom is the more complicated one but I find it much easier to understand what's going on. I find that first giving the shape of something and then describing what to change in that shape is a fantastic way to present record updates, in particular nested ones. Sadly, I don't really know how to have a similar presentation if you don't have some kind of pattern-match, or of the match is far away from the update.

WhatisRT avatar May 21 '25 13:05 WhatisRT