digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 199 forks source link

DAML-LF annotations #1329

Open filmackay opened 5 years ago

filmackay commented 5 years ago

Could we consider including annotations into DAML-LF such that meta-data can be included for non-interpretation purposes, such as dynamic interoperability & code generation:

One current practice is to z-encode values into DAML identifiers, in order to inject some recoverable metadata useful for interoperability. Ideally we could have some kind of generic annotation capability to inject various types with new information, for any purpose like annotations in other languages.

bitonic commented 5 years ago

@hurryabit @neil-da what do you think about this idea? I think it'd be extremely useful, if done well.

neil-da commented 5 years ago

@bitonic sounds useful - put it in LF and we'll see how we can add it. Haskell has ANN pragmas which look perfectly, but alas are a bit tied up with TemplateHaskell - I'm sure we can come up with something though.

bitonic commented 5 years ago

@neil-da thanks for the pointer to GHC annotations -- I had somehow missed that feature up to now.

A first attempt at this would simply allow to decorate each definition (like ANN) with some DAML-LF value. That would be implementable easily with the ANN pragma. The biggest problem would be that we'd have to define DAML-LF values in DAML-LF syntax... although we could probably recycle literals.