-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interfaces: consuming/non-consuming iface choices (#11009)
* interfaces: consuming/non-consuming iface choices We add the consumption behaviour to the interface choice definition and typecheck accordingly. CHANGELOG_BEGIN CHANGELOG_END update to new ghc-lib, conversion implementation * update ghc-lib * pinning stackage on unix * pin stackage on windows
- Loading branch information
Robin Krom
authored
Sep 30, 2021
1 parent
229ce47
commit 9fd6326
Showing
8 changed files
with
122 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
compiler/damlc/tests/daml-test-files/InterfaceConsuming.daml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
-- @SINCE-LF-FEATURE DAML_INTERFACE | ||
-- @ERROR Choice implementation and interface definition for Transfer differ in consuming/non-consuming behaviour. | ||
|
||
module InterfaceConsuming where | ||
|
||
interface Token where | ||
choice Split : (ContractId Token, ContractId Token) | ||
with | ||
splitAmount : Int | ||
|
||
nonconsuming choice Transfer : ContractId Token | ||
with | ||
newOwner : Party | ||
|
||
|
||
template Asset | ||
with | ||
issuer : Party | ||
owner : Party | ||
amount : Int | ||
where | ||
signatory issuer, owner | ||
implements Token where | ||
choice Split : (ContractId Token, ContractId Token) | ||
with | ||
splitAmount : Int | ||
controller owner | ||
do | ||
assert (splitAmount < amount) | ||
cid1 <- create this with amount = splitAmount | ||
cid2 <- create this with amount = amount - splitAmount | ||
pure (toTokenContractId cid1, toTokenContractId cid2) | ||
|
||
choice Transfer : ContractId Token | ||
with | ||
newOwner : Party | ||
controller owner, newOwner | ||
do | ||
cid <- create this with owner = newOwner | ||
pure (toTokenContractId cid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.