Reputation: 741
In my model I'm trying to define a non-generic template that has a choice which takes a generic parameter. I can't figure out how to do that. Is it even possible? If not, why?
Upvotes: 0
Views: 92
Reputation: 995
It's not possible, and deliberately so. One of DAML's design principles is that when you sign a contract you know exactly what you are agreeing to.
Imagine there was a type class Transferrable
for assets and I published a package containing an empty type class Stealable
and a template PermissionToSteal
:
class (Template a, Transferrable a) => Stealable a where
template PermissionToSteal
with
owner : Party
thief : Party
where
signatory owner, thief
controller thief can
(Stealable a) => Steal : (ContractId a)
with
asset : a
do
transfer asset thief
I may be able to convince you to sign such a contract as owner
as you feel safe in the knowledge that there are no instances of Stealable
.
But what if I now uploaded another package with an instance Stealable Cash
?
Upvotes: 1