-
Notifications
You must be signed in to change notification settings - Fork 217
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
Generalize UTxO identifier type within UTxOIndex
.
#3154
Generalize UTxO identifier type within UTxOIndex
.
#3154
Conversation
UTxOIndex
UTxOIndex
.
de16df5
to
3e8aa22
Compare
@@ -505,7 +508,7 @@ prop_selectRandom_one_withAdaOnly u = checkCoverage $ monadicIO $ do | |||
-- This should only succeed if there is at least one element with a non-zero | |||
-- quantity of the asset. | |||
-- | |||
prop_selectRandom_one_withAsset :: UTxOIndex -> AssetId -> Property | |||
prop_selectRandom_one_withAsset :: UTxOIndex InputId -> AssetId -> Property |
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.
All these properties would work with any Ord i => UTxOIndex i
right?
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.
All these properties would work with any Ord i => UTxOIndex i right?
Yes, precisely!
I haven't converted the test suites yet, but I'm thinking of making a simple TestUTxOKey
type with generators and shrinkers for it.
I haven't done this yet, because I predict some effort (though not too much) with be required to maintain the coverage conditions.
@@ -234,7 +234,7 @@ toList = fold (\ubs u b -> (u, b) : ubs) [] | |||
-- Consider using 'fold' if your goal is to consume all entries in the output. | |||
-- | |||
toUTxO :: UTxOIndex u -> Map u TokenBundle | |||
toUTxO = utxo | |||
toUTxO = universe |
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.
utxos
? allUTxOs
? rawUTxO
? Maybe universe
is a bit too "dressed up"
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.
utxos
?allUTxOs
?rawUTxO
? Maybeuniverse
is a bit too dressed up
I take your point. 😄
How about everything
?
59c9fbe
to
a269694
Compare
We use the following convention for identifier names: - `u` represents a unique identifier for an individual UTxO (unspent transaction output). - `b` represents a `TokenBundle` value. - `i` represents an index of type `UTxOIndex`.
The former field name was confusing because it overloaded the term "UTxO" (used elsewhere in the module to refer to a single UTxO) with the complete set of UTxOs in the index.
These names better reflect the types involved.
3e8aa22
to
6d8a198
Compare
82c8e38
into
jonathanknowles/coin-selection-compound-input-id
Issue Number
ADP-1418
Summary
This PR adds the type parameter
u
to theUTxOIndex
type, to represent unique UTxO identifiers. The parameteru
can be instantiated to any type for which there is anOrd
instance.Additional Work
This PR also:
UTxOIndex
module to reflect theUTxOIndex
type's generality.UTxOIndex
according to the following scheme:-
u
represents a unique identifier for an individual UTxO (unspent transaction output).-
b
represents aTokenBundle
value.-
i
represents an index of typeUTxOIndex
.UTxOIndex.{to,from}UTxO
toUTxOIndex.{to,from}Map
, since these functions really do produce and consume values of typeMap
.utxo
of typeUTxOIndex
touniverse
, to avoid overloading the termUTxO
, which refers to a single unspent transaction output in this module.