Skip to content

Commit

Permalink
Bump ghc-lib to include daml interfaces parser (#10747)
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end
  • Loading branch information
cocreature authored Sep 16, 2021
1 parent b6a6bf7 commit cac8391
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ci/da-ghc-lib/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
variables:
ghc-lib-sha: '42e5c306dcfbc84b83336fdd531023e93bfcc5b2'
base-sha: '9c787d4d24f2b515934c8503ee2bbd7cfac4da20'
patches: '11ec737edc4b81160e1207c02f6c96642bab584a 833ca63be2ab14871874ccb6974921e8952802e9'
patches: '9f72c788c66c1ee913e5439308840afea5727e70 833ca63be2ab14871874ccb6974921e8952802e9'
flavor: 'ghc-8.8.1'
steps:
- checkout: self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ convertPrim _ "UFetch" (TContractId (TCon template) :-> TUpdate (TCon template')
ETmLam (mkVar "this", TContractId (TCon template)) $
EUpdate $ UFetch template (EVar (mkVar "this"))

convertPrim _ "UFetchInterface" (TContractId (TCon iface) :-> TUpdate (TCon iface'))
| iface == iface' =
ETmLam (mkVar "this", TContractId (TCon iface)) $
EUpdate $ UFetchInterface iface (EVar (mkVar "this"))

convertPrim _ "UExercise"
(TContractId (TCon template) :-> TCon choice :-> TUpdate _returnTy) =
ETmLam (mkVar "this", TContractId (TCon template)) $
Expand All @@ -324,6 +329,14 @@ convertPrim _ "UExercise"
where
choiceName = ChoiceName (T.intercalate "." $ unTypeConName $ qualObject choice)

convertPrim _ "UExerciseInterface"
(TContractId (TCon iface) :-> TCon choice :-> TUpdate _returnTy) =
ETmLam (mkVar "this", TContractId (TCon iface)) $
ETmLam (mkVar "arg", TCon choice) $
EUpdate $ UExerciseInterface iface choiceName (EVar (mkVar "this")) (EVar (mkVar "arg"))
where
choiceName = ChoiceName (T.intercalate "." $ unTypeConName $ qualObject choice)

convertPrim _ "ULookupByKey" (key :-> TUpdate (TOptional (TContractId (TCon template)))) =
ETmLam (mkVar "key", key) $ EUpdate $
ULookupByKey $ RetrieveByKey template (EVar $ mkVar "key")
Expand Down
38 changes: 38 additions & 0 deletions compiler/damlc/tests/daml-test-files/Interface.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- 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
-- @WARN Modules compiled with the DatatypeContexts language extension
-- @ERROR Interfaces not supported
{-# LANGUAGE DatatypeContexts #-}

module Interface where

interface Token where
-- getAmount : Decimal
choice Split : (ContractId Token, ContractId Token)
with
splitAmount : Int

choice Transfer : ContractId Token
with
newOwner : Party

template Asset
with
issuer : Party
owner : Party
amount : Decimal
where
signatory issuer, owner
implements Token where
choice Split : (ContractId Token, ContractId Token)
with
splitAmount : Int
controller owner
do error "not implemented"
choice Transfer : ContractId Token
with
newOwner : Party
controller owner, newOwner
do error "not implemented"
8 changes: 4 additions & 4 deletions stack-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

resolver: lts-18.0
packages:
- archive: https://daml-binaries.da-ext.net/da-ghc-lib/ghc-lib-cef264f125f8f22a6d6113786daca39d.tar.gz
sha256: "d893e9c918bd9ec8866366a45e4d322e5cef168f1960b7db8c5be9b3e6c23528"
- archive: https://daml-binaries.da-ext.net/da-ghc-lib/ghc-lib-parser-cef264f125f8f22a6d6113786daca39d.tar.gz
sha256: "dd918f113e7bb5d913ee3d8eb22ac4914b94381ca1410f491f861df1c8af8b20"
- archive: https://daml-binaries.da-ext.net/da-ghc-lib/ghc-lib-12d888a292cb63ac2680ce92bad4ae1f.tar.gz
sha256: "88671cc2376affa82f103aaae930e502f30441ca1a94a78fcfd08b6aef77a7d3"
- archive: https://daml-binaries.da-ext.net/da-ghc-lib/ghc-lib-parser-12d888a292cb63ac2680ce92bad4ae1f.tar.gz
sha256: "492d50a671bb7d9d826c2e9c77c6d0fdf25030f3f953bbd6f2df92f9ebaceed9"
- github: digital-asset/hlint
commit: "c8246c1feb932858ff2b5d7e9e900068a974bf57"
sha256: "3da24baf789c5f00211a92e24153e6b88102befaa946ada1f707935554500fe2"
Expand Down
Loading

0 comments on commit cac8391

Please sign in to comment.