0

在我的模型中,我试图定义一个非泛型模板,该模板具有一个采用泛型参数的选项。我不知道该怎么做。甚至可能吗?如果不是,为什么?

4

1 回答 1

1

这是不可能的,而且是故意的。DAML 的设计原则之一是,当您签署合同时,您确切地知道您同意什么。

想象有一个Transferrable资产类型类,我发布了一个包含空类型类Stealable和模板的包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

我也许可以说服您签署这样一份合同,owner因为您知道没有Stealable.

但是,如果我现在上传另一个带有instance Stealable Cash.

于 2019-09-05T15:30:41.027 回答