Skip to content

Conversation

@zliu41
Copy link
Member

@zliu41 zliu41 commented Sep 30, 2025

Per discussion and consensus in cardano-foundation/CIPs#1088

@zliu41 zliu41 requested a review from a team September 30, 2025 22:24
@zliu41 zliu41 added the No Changelog Required Add this to skip the Changelog Check label Sep 30, 2025
@zliu41 zliu41 force-pushed the zliu41/more-valueContains branch from 80608be to cf4bf3d Compare September 30, 2025 22:29
{- ^ Total size, i.e., sum total of inner map sizes. This avoids recomputing
the total size during the costing of operations like `unionValue`.
-}
{-# UNPACK #-} !Int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, neat idea!

Maybe Int
-> ( -- Left (old size of inner map) if the total size grows by 1,
-- otherwise, Right (old amount)
Either Int Integer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the concept of "boolean blindness", I prefer to define my own, equivalent, datatypes in these situations.

So, in this case, instead of writing a comment which documents what Either Int Integer represents, you can have the code document itself if you define a type data Growth = OldInner Int | OldAmount Integer (very bad names, but you get the idea).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very local - used only in a local function inside a function, so I'd very much rather not add a dedicated top-level data type just for this.

Just old -> (updateSizes old (old + 1) sizes, size + 1)
Nothing -> (sizes, size)
in pure $ Value outer' sizes' size'
in (maybe (Left (Map.size inner)) Right moldAmt, Just inner')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above, this combination of Maybe, Either and tuples makes it hard to understand what is going on without running the whole function in your head.

Copy link
Contributor

@Unisay Unisay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zliu41 zliu41 merged commit 531f1b8 into master Oct 2, 2025
5 checks passed
@zliu41 zliu41 deleted the zliu41/more-valueContains branch October 2, 2025 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Changelog Required Add this to skip the Changelog Check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants