-
Notifications
You must be signed in to change notification settings - Fork 205
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
First pass at generic order relation in DAML-LF 1.dev spec. #4116
Conversation
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.
Nice, thank you very much! I left a bunch of inline comments for the 3 open points so can can easily keep them apart by replying to those.
daml-lf/spec/daml-lf-1.rst
Outdated
——————————————————————————————————————————————————— GenLtStructCon | ||
⟨ f₁ = v₁, …, fₘ = vₘ ⟩ ~ᵥ ⟨ f₁ = w₁, …, fₘ = wₘ ⟩ | ||
|
||
|
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.
As for Any
and TypeRep
:
- I would like to be able to use
TypeRep
as map keys in DAML triggers. Specifically, the ACS is basically a map indexed by the type of the template. That makesgetContracts
quite efficient. Otherwise, I’m basically stuck doing a linear search through the whole ACS. - For things like
dedupCreate
it would be convenient to have a set of create commands which roughly boils down to having a set ofAnyTemplate
so I can do a fast lookup to see if I have to send it again.
So given that this primitive is intended to be used for map keys, it would be great if we could specify an order for this (I don’t care which one).
That said, I’m totally fine to do this in a separate PR or maybe even as a separate step wtr to the implementation of the spec.
@@ -2327,8 +2418,8 @@ This section lists the built-in functions supported by DAML LF 1. | |||
The functions come with their types and a description of their | |||
behavior. | |||
|
|||
Generic equality function | |||
~~~~~~~~~~~~~~~~~~~~~~~~~ | |||
Generic equality and order functions |
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.
As for maps, given that we want to switch to ordered map, can we define the order of a map based on the order of the result of converting it to a list of key-value pairs (orderered by keys)?
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.
That sounds like the best option :)
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.
I added rules for maps. I think cleaning up the spec to get rid of the dependency on insertion order in generic maps should happen in the next PR (if CI ever accepts this one).
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.
👍
<ᵥ Mod:T @σ₁ … @σₙ { f₁ = w₁, …, fₙ = wₘ } | ||
|
||
Mod:T:V₁ comes before Mod:T:V₂ in the list of | ||
constructors for variant type Mod:T |
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.
This is currently tricky to do in the engine as we do not have enough info at run time.
I was thinking to go lexicographically, but this is definitively better.
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.
I don’t think lexicographic ordering is a reasonable option. The default Ord
instance in DAML works like the one that @associahedron has used in the spec here and diverging from that is going to cause a lot of confusion.
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.
We probably add an index in the variant and the enum.
A first pass at specification of a generic order relation in DAML-LF. Things I left out:
Ordering for maps (what's the right approach?)
Ordering for typerep and anytype (what's the right approach? Do we need to define an ordering on closed types?)
Anything specific about the ordering of contract IDs (I just said "it's up to the ledger").