T.dedupExercisebyKey, how do I use it

I think I’m having some knowledge gaps here, and it would be helpful to point out where I can narrow those gaps.

Looking at the below:

dedupExerciseByKey

: (Eq c, Eq k, Choice t c r, TemplateKey t k) => k → c → TriggerA s ()

Exercise the choice on the given contract if it is not already in flight.

Note that this will send the exercise as a single-command transaction. If you need to send multiple commands in one transaction, use emitCommands with exerciseCmd and handle filtering yourself.

Question:
What is Eq C, eq k ?

I can’t seem to find an example where dedupExerciseByKey is used. I found
https://raw.githubusercontent.com/digital-asset/daml/11e5dd37e730156b97748d67914b5e3f14a48625/triggers/tests/daml/ExerciseByKey.daml

The example above is
dedupExerciseByKey @T party C

I’ve written
txApproval <- T.dedupExerciseByKey @AssetHoldingAccount (m.asset.assetType, p) Preapprove_Transfer_In with asset = m.asset
which is basically
T.dedupExerciseByKey @templateName (key field 1, keyfield 2) choice_name with choiceArg = someArg

Is that correct? I feel like I’m trying to guess this function signature, a real life example would be super helpful, thanks!

Eq c, Eq k are typeclass constraints that require that c (the choice type) and k (the key type) can be compared for equality. This is satisfied for any template so you don’t really need to worry about it when you use it.

Your example looks very sensible. You can use exerciseByKey just like exercise except that you specify the contract key instead of the contract id.