Skip to content

Commit

Permalink
Upgrade ghc-lib, improving parsing of template headers (digital-asset…
Browse files Browse the repository at this point in the history
…#2609)

* Update ghc-libs
* Test for parsing template headers
  • Loading branch information
rohanjr authored Aug 20, 2019
1 parent f4f9aa9 commit 4c53841
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/haskell/BUILD.ghc-lib-parser
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ haskell_library(
"-I/compiler", "-I/compiler/utils"
],
package_name = "ghc-lib-parser",
version = "8.8.0.20190814",
version = "8.8.0.20190819",
)

cc_library(
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ HASKELL_LSP_COMMIT = "bfbd8630504ebc57b70948689c37b85cfbe589da"

HASKELL_LSP_HASH = "a301d9409c3a19a042bdf5763611c6a60af5cbc1ff0f281acbc19b3ee70dde5f"

GHC_LIB_VERSION = "8.8.0.20190814"
GHC_LIB_VERSION = "8.8.0.20190819"

http_archive(
name = "haskell_ghc__lib__parser",
build_file = "//3rdparty/haskell:BUILD.ghc-lib-parser",
sha256 = "ce14e19bbe2a52289c5fb436941f948678a86bd821c17710082131bbe87d997f",
sha256 = "96c1d09bc2345563ce9f2f025a466502c1da5bcc937fcb01bd0541f934f6aa1d",
strip_prefix = "ghc-lib-parser-{}".format(GHC_LIB_VERSION),
urls = ["https://digitalassetsdk.bintray.com/ghc-lib/ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION)],
)
Expand Down Expand Up @@ -530,8 +530,8 @@ hazel_repositories(

# Read [Working on ghc-lib] for ghc-lib update instructions at
# https://github.com/DACH-NY/daml/blob/master/ghc-lib/working-on-ghc-lib.md.
hazel_ghclibs(GHC_LIB_VERSION, "ce14e19bbe2a52289c5fb436941f948678a86bd821c17710082131bbe87d997f", "02482f4fd7691c2e442f9dd4c8d6816325d0bd164f6e03cec6a2db1ef9e65d43") +
hazel_github_external("digital-asset", "hlint", "c57edffa2bd54605637671f7821a2519d34c37bf", "9c81a0822af933dc13240d74218534308c7e5a2db80bad4a33c72890397275fd") +
hazel_ghclibs(GHC_LIB_VERSION, "96c1d09bc2345563ce9f2f025a466502c1da5bcc937fcb01bd0541f934f6aa1d", "d543a49fc15e2895f2cb1be62a957b2397dc02760ee326c0a6cf67a147a59855") +
hazel_github_external("digital-asset", "hlint", "34133de4262f2b472ec855de8858ae0a74fe2b72", "8fd3fddc370929cdc8a16d52cb2e2ab5ac2a68c5f601da403b472cfd38f22e5d") +
hazel_github_external("awakesecurity", "proto3-wire", "4f355bbac895d577d8a28f567ab4380f042ccc24", "b49bd371847b0cffe0673592870e221708d4ec238589c1739a6d3d03f570ed66") +
hazel_github_external(
"awakesecurity",
Expand Down
80 changes: 80 additions & 0 deletions compiler/damlc/tests/daml-test-files/TemplateHeaders.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

-- Test parsing for "template headers", i.e. the types between `template` and `with`.
-- This can include a context (list of constraints), template name and type variables.
-- We test that the parser works for different combinations of these.
-- We also test a couple of template instances while we are at it.

{-# LANGUAGE FlexibleContexts #-}

daml 1.2
module TemplateHeaders where

template A with
pa : Party
where
signatory pa
controller pa can
-- Used in template I
Transfer : ContractId A
with newParty: Party
do create A with pa = newParty

template B a with
pb : Party
xb : a
where
signatory pb

template C a b c with
pc : Party
xc : a
where
signatory pc

template () => D
with
pd: Party
where
signatory pd

template Show a => E a b c
with
pe: Party
where
signatory pe

template (Show a) => F a b c
with
pf: Party
where
signatory pf

template (Show a, Ord b) => G a b c
with
pg: Party
where
signatory pg

template (Show a, Ord b, Eq c) => H a b c
with
ph: Party
where
signatory ph

template Choice a Transfer (ContractId a) => I a
with
pi: Party
aa: ContractId a
where
signatory pi
controller pi can
TransferA: ContractId (I a)
with newParty: Party
do newaa <- exercise aa Transfer with newParty
create this with aa = newaa

template instance BA = B A

template instance CA = C Int (Either Bool Decimal) Text
2 changes: 2 additions & 0 deletions unreleased.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ HEAD — ongoing
+ [DAML Compiler] ``damlc build`` should no longer leak file handles so
``ulimit`` workarounds should no longer be necessary.
+ [DAML-LF] **Breaking** Rename ``NUMERIC`` back to ``DECIMAL`` in Protobuf definition.
+ [DAML Compiler] Allow more contexts in generic templates. Specifically, template constraints can
have arguments besides type variables, if the FlexibleContexts extension is enabled.

0 comments on commit 4c53841

Please sign in to comment.