You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspired by "extensible records" in Elm programming language, a record type that is constrained to having a set of specific fields, while free to have arbitrary fields otherwise, can be defined as a constrained polymorphic record.
What is the advantage?
Allows for defining more abstract functions, which can potentially pave the way for having more developer-friendly packages with minimal overhead.
A sample use case can be:
fnvalidate_output(datum:Datum,redeemer:{a | output_index:Int},ctx:ScriptContext,) -> Bool{// Use `output_index` to pick the continued UTxO.// This helper function can be used for any `redeemer` as// long as it is a record type (i.e. single constructor)// with an `output_index` field with type `Int`.}
How can this be accomplished?
As pointed out by @rvcas, order of values matter in UPLC, therefore this may not be a trivial feature to add. However, at this stage it's probably best to first discuss whether this is desirable in the first place, and what are its pros/cons.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What are Constrained Polymorphic Records?
Inspired by "extensible records" in Elm programming language, a record type that is constrained to having a set of specific fields, while free to have arbitrary fields otherwise, can be defined as a constrained polymorphic record.
What is the advantage?
Allows for defining more abstract functions, which can potentially pave the way for having more developer-friendly packages with minimal overhead.
A sample use case can be:
How can this be accomplished?
As pointed out by @rvcas, order of values matter in UPLC, therefore this may not be a trivial feature to add. However, at this stage it's probably best to first discuss whether this is desirable in the first place, and what are its pros/cons.
Beta Was this translation helpful? Give feedback.
All reactions