Commit Graph

682 Commits

Author SHA1 Message Date
Moritz Kiefer
bd19291632 Fix superclass detection for Numeric (#3316)
For numeric, the superclass dicts can be of the for `dict @10` so only
handling variables doesn’t work. Now we walk down applications and
check the name on the left.
2019-11-01 16:15:23 +00:00
Rohan Jacob-Rao
8ec9c324fb Store extension version in global state (#3309)
* Store extension version in global state

* Fix synchronicity
2019-10-31 21:18:11 +00:00
Shayne Fletcher
11c1bf0fba
Upgrade hlint (#3306) 2019-10-31 15:08:21 -04:00
Martin Huschenbett
6211d74193 Add filter function to TextMap and Next.Map (#3305)
This closes #2760.
2019-10-31 15:41:32 +00:00
associahedron
8c8cd5f433 Refactoring the handling of data types in LFConversion.hs (#3251)
* Add some type signatures to make MonoLocalBinds happy

* Extract applyDataCon function

* rename applyDataCon

* Refactor convertDataCon

* ß reduction

* Delint

* Refactor convertTypeDef

* Rewrite convertTemplateInstanceDef

* pass sanitization function to convertRecordFields

* Extract out the newtype worker definition

* Move mkWorkerName to UtilLF

* Simplify getTag conversion

* Simplify tagToEnum# conversion

* Eliminate Ctors and toCtors

* Reviewer comments
2019-10-31 13:46:48 +00:00
Remy
5812a1246d
daml-lf: to_text_template_id -> to_text_type_con_name (#3293)
* simplify to_text_template_id

* to_text_template_id -> to_text_type_con_name
2019-10-30 17:32:36 +01:00
Remy
bd054b4955 daml-lf: interned strings/names in scenarios (#3255)
* daml-lf: interned strings/names in scenarios

* clean up

* Address Moritz's comments
2019-10-30 10:25:46 +00:00
Martin Huschenbett
8cfbd50c17 Don't cache the GHC Core produced during compilation (#3269)
* Don't cache the GHC Core produced during compilation

In our experiments, this reduced the memory footprint by ca. 18% on a very
big code base.

* Adapt integration tests

* Fix integration tests
2019-10-29 15:30:59 +00:00
Rohan Jacob-Rao
00fc6bf100 Log when user views scenario results (#3271)
* Extend Priority type with Telemetry value

* Include Telemetry logging level in logger

* Log viewing of scenario results

* Update ghcide with telemetry logging level
2019-10-28 23:42:20 +00:00
Robin Krom
d4f8db05f0
language: parse sdk version from manifest (#3262)
This is in preparation for the support of cross sdk imports, where we
need to know whether imports have different sdk versions or not.
2019-10-28 17:45:06 +01:00
Andreas Herrmann
2bd1db490a
Replace bazel-deps by rules_jvm_external (#3253)
* Update bazel-common to fix javadoc issues

Specifically, to fix the following error

```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel:7:1: in javadoc_library rule //ledger-api/rs-grpc-bridge:rs-grpc-bridge_javadoc:
Traceback (most recent call last):
        File "/home/aj/tweag.io/da/da-bazel-1.1/ledger-api/rs-grpc-bridge/BUILD.bazel", line 7
                javadoc_library(name = 'rs-grpc-bridge_javadoc')
        File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/com_github_google_bazel_common/tools/javadoc/javadoc.bzl", line 27, in _javadoc_library
                dep.java.transitive_deps
object of type 'JavaSkylarkApiProvider' has no field 'transitive_deps'
```

* Define Maven deps using rules_jvm_external

* Pin artifacts

* Remove bazel-deps generated targets

* Remove bazel-deps

* Switch to rules_jvm_external targets

* update bazel documentation

* pom_file: There are no more bazel-deps targets

* BAZEL-JVM.md `maven_install` typo
2019-10-28 13:53:14 +01:00
Andreas Herrmann
dc2f10ebe6 Use TemplateTypeRep in DAML Trigger API (#3245)
* Add TemplateTypeRep to AnyContractId

* Define Trigger.ContractId t

* Use Trigger.ContractId t

* Implement fromCreated and fromArchived

* instance MapKey TemplateTypeRep

* More efficient ACS access using Map TemplateTypeRep

* ./fmt.sh

* toString and fromString for Identifier

* Replace Identifier by TemplateTypeRep

* TheContractId --> AbsoluteContractId

https://github.com/digital-asset/daml/pull/3245#discussion_r338033546
2019-10-23 13:56:59 +00:00
Moritz Kiefer
319d43ac26
Clear package db before reinitializing it (#3241)
fixes #3240
2019-10-21 14:04:10 -04:00
Andreas Herrmann
4a5b74b93d
Warn if module name mismatches file name (#3228)
* Test: Warn if module name mismatches file name

* Update ghcide

* Add module name mismatch preprocessor
2019-10-21 13:17:41 +02:00
associahedron
1d52cdb4bc
Add damlc test to list of cammands that care about build-options (#3227) 2019-10-21 11:36:21 +01:00
Shayne Fletcher
040a4531de
Update DLint (#3234) 2019-10-21 05:31:58 -04:00
Shayne Fletcher
3e17d482c3
Update DLint; welcome pattern rules (#3230) 2019-10-18 12:19:29 -04:00
Moritz Kiefer
525521a850 Only match identifiers from DA.Internal.LF if they are in the right module (#3220) 2019-10-18 10:37:01 +00:00
Moritz Kiefer
36719717fa
Update to current state of progress reporting in LSP (#3211)
* Update to current state of progress reporting in LSP

* fix ide-debug-driver

* Fix tests

* Fix build of ghcide executable
2019-10-17 16:14:49 +02:00
Gerolf Seitz
a5921e0274 Properly fill eventId for active contracts (#3126)
* Properly fill eventId for active contracts

This gets rid of the last remaining bit that assumes
contractId==eventId.

Fixes #65.
Contributes to #2068.

* Do not conflate eventId and contractId in the daml-lf interpreter

* Do not treat contractId as eventId in Ledger.scala

* Remember the transaction that divulged a contract.

* In this scope we can treat divulged contracts the same as disclosed ones

* revert a few more syntactical changes to make the overall diff smaller

* retain the same behavior on the scenario service api

* fix unreleased after rebase
2019-10-16 17:02:04 +00:00
associahedron
a90a1e1e8e Add Numeric support to migrate. (#3195)
* Add Numeric support to migrate

* Generate GHC.Types definitions based on LF version.

* Add a migration test with Numerics.
2019-10-16 15:56:49 +00:00
Moritz Kiefer
f4766ad903 Forbid quantifiers in Any in the Haskell typechecker (#3200)
This is a followup to #3196 which updated the Scala typechecker
2019-10-16 15:10:45 +00:00
Remy
506a3be6e5 Revert "Revert "Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)"" (#3120)
This reverts commit 4596c1bde6.
2019-10-16 12:12:07 +00:00
Robin Krom
29424af721
language: dalf imports and a test (#3176)
* language: dalf imports and a test

This adds the possibility to directly import dalfs in a project. We test
that we can import the `simple-dalf` in the daml-assistant integation
tests. For now we only check that data type generation works, not yet
the template instance.

The following was fixed: When rewriting package self references, this
changes the hash of the package later on and leads to different package
hashes. Also we need to be careful to write the orignal binary
representation to this and not re-encode it because the encoding might
have changed with a different sdk.

* addressing moritz's comments.

* windows doesnt like bazel paths
2019-10-15 17:20:53 +02:00
Andreas Herrmann
3a94812b97 Test templateTypeRef across modules (#3185) 2019-10-15 15:04:30 +00:00
Moritz Kiefer
b568827563
Add createAndExercise to the standard library (#3182) 2019-10-15 15:03:25 +02:00
Andreas Herrmann
a49c6469c7 Implement templateTypeRep in DAML (#3174)
* Improve comment

https://github.com/digital-asset/daml/pull/3118#discussion_r332894977

* Implement templateTypeRep in DAML

* TemplateTypeRep tests: use === and =/=

https://github.com/digital-asset/daml/pull/3174#discussion_r334775937

* Switch to bintray ghc-lib 20191015
2019-10-15 10:08:41 +00:00
Remy
e45b585307 daml-lf: repackage daml-lf archive proto (daml_lf -> daml_lf_dev) (#3169) 2019-10-15 09:36:11 +00:00
Remy
d64df4b5f7 daml-lf: clean achive bazel build (#3175)
* clean the mess in daml-lf achive bazel build

* add release note

* Address Moritz's comments

* more release notes
2019-10-15 08:36:46 +00:00
associahedron
70b025b691 damldocs: change External:Archive to Archive in template docs (#3165)
* damldocs: change External:Archive to Archive in template docs

* Update tests
2019-10-14 16:32:13 +00:00
Remy
fc1a000090 daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader (#3168)
* daml-lf: rename daml_lf_archive_scala target to daml_lf_archive_reader

* fix release
2019-10-14 14:53:50 +00:00
Remy
217405e883 daml-lf: Move archive protofile to a more usual place. (#3166)
* move daml-lf archive protobug to a more usual place

* formatting

* fix kvutils proto

* fix csharp namespace
2019-10-14 13:22:22 +00:00
Robin Krom
ca87b9c601
language: some small fixes to the daml source gen from dalfs. (#3151)
Two changes: Make sure `DA.Internal.Tempalte` is imported is necessary
and convert variants with unit argument correctly.
2019-10-14 11:44:25 +02:00
associahedron
bcf4aff2ab
damldocs: Do not filter templates and choices by export set (#3161)
* Do not filter choices or template fields by export list

* Add Template0
2019-10-14 09:43:18 +01:00
Moritz Kiefer
48eb360a4f Add AnyChoice type to DAML (#3152)
* Add AnyChoice type to DAML

fixes #3131

* Fix ProposalDesugared

* Fix trigger tests

* Use the proper ghc-lib urls
2019-10-10 16:46:55 +00:00
associahedron
172996e4db Restrict type-level nats to [0,37]. (#3139)
* Restrict type-level nats to [0,37]

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/TypeLevelNat.hs

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-10-10 12:20:24 +00:00
Robin Krom
09fa4cf588
language: fix: don't look for daml files in hidden directories (#3144)
* language: fix: don't look for daml files in hidden directories

Fixes #3134. When locating daml source files, we need to make sure we're
not recursing into the .daml directory, because it contains source files
of the dependencies.

* Update daml-assistant/integration-tests/src/Main.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2019-10-10 12:33:19 +02:00
Moritz Kiefer
dcdcf7f0c0
Generalize AnyTemplate type to Any in DAML-LF (#3141)
* Generalize AnyTemplate type to Any in DAML-LF

See #3131 for the motivation for this. The tl;dr is that we need
something like AnyTemplate for choice types as well.

Since the protobuf was already more general in anticipation of such a
change, this change only changes the internal AST on the Haskell and
Scala side.

Since AnyTemplate change has never made it out of 1.dev, I updated the
changelog in the LF spec instead of adding a new entry.

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* windows debugging

* more windows debugging

* clean expunge

* don’t cat the config file

* remove comment on type equality

* windows …

* gnah

* foobar

* foobar

* does anything ever work?

* reenable caching

* Do not build daml-lf-ast separately
2019-10-10 08:51:52 +02:00
Robin Krom
f28dc104ca
language: create the package database from dalfs (#3140)
This moves the creation of a package database from given dalfs out of
the migrate command and into the init command. In particular, this makes
the process of creating a package database independent of the migrate
command.

It also changes the way this package database is created to be only
dependend on given dalf files.
2019-10-09 17:40:03 +02:00
Moritz Kiefer
f18c393866 Fix location of interface files in created dars (#3137)
fixes #3135
2019-10-09 08:39:50 +00:00
Moritz Kiefer
3b1d8dfe33 Remove custom State monad from daml-trigger (#3136) 2019-10-09 07:42:48 +00:00
Moritz Kiefer
7f58c5a0c8
Add DA.Action.State (#3133) 2019-10-08 18:04:48 +02:00
Robin Krom
0671d7b905
language: add internal command for generating source from dalf. (#3129)
* language: add internal command for generating source from dalf.

We add an internal command for generating DAML source code from .dalf
packages. Also adds an internal flag to tell the compiler, that it is
compiling generated source.
2019-10-08 17:35:33 +02:00
Andreas Herrmann
5266b042b2 Implement ToTextTemplateId in proto (#3118) 2019-10-07 14:56:52 +00:00
Remy
449500bad8 Revert "Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)" (#3114)
This reverts commit 68e4453324.
2019-10-04 16:13:27 +02:00
Martin Huschenbett
68e4453324 Intern all strings and dotted names in the DAML-LF protobuf encoding (#3067)
* Intern all strings and dotted names in the DAML-LF protobuf encoding

On one of our huge DAML code bases this has brought down the size of the
DALF by 60% and cut the memory usage during decoding by 50%.

The `@QUERY-LF` tests in the damlc integration tests check that the
interning actually works.

* Add scala decoder support for interned strings

* Memoize versionisOlderThan. Speeds up decoding by 6x.

* Properly fix the performance problem with version ordering

LanguageVersion.ordering was a `def` and not `val` causing us to
recreate the ordering tables every time.

* Clean up //daml-lf/archive:decode-test

* Use int32 for interning indices

* Adapt QUERY-LF tests

* Strip a few useless field_ prefixes

* Add test for uniqueness in interning tables

* Drop field_ prefix from jq queries

* Fix Scala encoder

* Fix bond-trading tests

* Rename decode-test to decode-tester

* Address @cocreature's comments

* daml-lf: proper versioning for reading internedStrings

* daml-lf repl: revert change
2019-10-04 11:26:31 +00:00
Moritz Kiefer
a25c2e9de3
Avoid normalizing include dirs (#3103)
* Avoid normalizing include dirs

Fixes #3099

See https://github.com/digital-asset/ghcide/pull/152 for the
corresponding PR in ghcide

* bump to proper ghcide rev

* bump haskell-lsp rev
2019-10-04 10:41:44 +02:00
Martin Huschenbett
6b1f65f006
Add a tool to generate simple DALF for plain DALF import test (#3102)
We're working on a feature to import plain DALFs without any attached
source or interface files into a DAML project. This PR provides a tool to
generate a simple DALF file for testing this feature.
2019-10-04 09:55:25 +02:00
associahedron
e4956ce4da
Forbid polymorphic Numeric literals. (#3085)
* Remove polymorphic literals from library

* Add BECastNumeric and BEShiftNumeric in DAML-LF AST.

* Update rest

* Copyright header

* Remove polymorphic literals from LF conversion.

* Update tests

* Add test for forbidden polymorphic literals

* Add newline in DA.Numeric

* use MulNumeric instead of CastNumeric in DA.Internal.Prelude
2019-10-02 16:01:13 +01:00
Martin Huschenbett
a5ff470929
Prepare @QUERY-LF tests for string interning (#3081)
After string interning we won't have direct access to string anymore but
rather need to go through the interning tables. This PR implements the
required infrastructure for that endeavour.
2019-10-01 20:31:30 +02:00
Martin Huschenbett
1128d83492
Write JSON files in damlc integration test (#3075)
* Write JSON files in damlc integration test

There were quite a few occurences where I needed to look at the JSON
representation of the generated DALF in the past. Particularly, when
trying to come up with the `@QUERY-LF` pragmas for new tests.

This PR writes the JSON files to disk next to the (pretty printed)
DALF files.

* Remove useless rewriting of numbers into strings
2019-10-01 17:04:55 +02:00
associahedron
125317cff0
Update rest of standard library for Numeric (#3063)
* Update rest of standard library for Numeric

* Fix position of CPP pragma
2019-09-30 11:03:16 +01:00
Andreas Herrmann
98bb580aa2 Bundle packages with SDK releases (#3056)
* Enable SDK daml-lib package dependencies

* integration-test: SDK daml-libs dependency

* trigger --> daml-trigger

Rename the trigger library package to match other builtin packages.

* Bundle daml-trigger.dar in SDK release tarball

* Describe SDK bundled packages in changelog

* Push case match inside expand

Addressing review comment
8208277747 (r329428240)
2019-09-30 09:15:11 +00:00
Rohan Jacob-Rao
32e3099ddf Template instance type synonym polish (#3054)
* Release note

* Desugaring is hard to type

* Upgrade hlint version to new ghc lib

* Use template instance type synonym in some tests

* Rm space
2019-09-27 18:07:39 +00:00
Anup Kalburgi
3686162c02
Adding visual -web command (#3009)
adding the visual-web command to damlc
2019-09-27 10:26:20 -04:00
Martin Huschenbett
3b42a447f3 Refactor DAML-LF encoder/decoder in prep for string interning (#3060)
* Refactor DAML-LF encoder/decoder in prep for string interning

Refactor the encoder/decoder such that all the functions concerned with
interning live next to each other and code will break once the types of
the protobuf messages change.

This PR is a pure refactoring and does not change any functionality.

* Fix typos
2019-09-27 12:40:05 +00:00
Martin Huschenbett
bb309794db Simplify the Haskell implementation of the DAML-LF decoder (#3053)
Right now, some functions are polymorphic in the monad we use. This is
absolutely unnecessary.

This PR fixes one monad and uses it all over the place. This is a pure
refactoring which doesn't change any functionality.
2019-09-26 18:29:46 +00:00
Rohan Jacob-Rao
5bcdb3e8a0
Desugar template instances to type synonyms instead of newtypes (#3013)
* Upgrade ghc-libs
* Convert template instances as type synonyms to DAML-LF
* Look for TEMPLATE_INSTANCE suffix for daml docs
* Update desugaring documentation
2019-09-26 14:05:47 -04:00
Martin Huschenbett
2df59be8b5 Fix issue with template instance constraint rewriting (#3010)
The compiler rewrites constraints like `Template (Foo t) => ...` into
`FooInstance t => ...`. Unfortunately, this rewriting does not yet kick in
when the constraint contains superfluous parentheses as in
`(Template (Foo t)) => ...`.

This PR fixes the problem.

Fixes #2994.
2019-09-26 15:24:21 +00:00
Martin Huschenbett
1f2a257208
Merge package reference detection into package id encoding (#3039)
* Merge package reference detection into package id encoding

Currently, the encoding of a DAML-LF package works in two phases:
1. We compute the set of all package ids refernced by the package to encode.
2. We use this set of package ids to form a table for interning that is then
   consulted during the encoding of package ids.

This PR changes it such that the interning table is computed while the
package is being encoded. New package ids are added to the table whenever
they are encountered for the first time.

This is in preparation for the general inlining of all strings, which will
use the same approach to building the interning table.

This PR is a pure refactoring and does not change any functionality.

* Addess @cocreature's comments

* Add unordered-containers as a dependency
2019-09-26 16:37:36 +02:00
Moritz Kiefer
51cc7cf509
Shorten test names in //compiler/damlc:integration-dev (#3046)
Previously the test names consisted of the full absolute file paths
which got unreadable very quickly. Sadly the absolute file paths still
leak into the error messages since I don’t know of a nice way to get
relative paths here (just making them relative to cwd doesn’t work)
but this is still much more readable.
2019-09-26 15:33:16 +02:00
Moritz Kiefer
39e60acb2b Unflake dlint in integration tests (#3045)
Previously, we sometimes missed the dlint hints because we got killed
due to a typechecking error before they were produced. Now, we
force them to be generated which should hopefully fix that.
2019-09-26 13:30:12 +00:00
Moritz Kiefer
5e9c950164 Fix damlc build error messages if LOCALE_ARCHIVE is not set (#3041)
* Fix damlc build error messages if LOCALE_ARCHIVE is not set

* Fix tests

* fix more tests
2019-09-26 12:00:44 +00:00
associahedron
a943287e8b Refactor Numeric literal conversion and add tests. (#3038)
* Refactoring numeric literals

* More refactoring.

* Simplify convertRationalNumericPoly logic

* Positive numeric literal tests.

* Fix error message

* Remove duplicate periods

* Add negative tests

* Add separate type signature in existing rational tests.
2019-09-26 09:47:36 +00:00
Martin Huschenbett
78e08c2119 Wait for lints in damlc integration tests (#3020)
Currently, the integration tests fail sometimes because of missing lints.
Our suspicion is that the linter gets killed when the type checker fails
before it managed to produce the lints. This change makes sure we wait for
the linter.
2019-09-25 22:58:37 +00:00
Moritz Kiefer
dade80afe1 Add a --target flag to the IDE (#3019)
It is really annoying to not be able to load code that requires 1.dev
in the IDE.
2019-09-25 11:45:14 +00:00
associahedron
46051e8d11
Start adding Numeric to the standard library. (#2950)
* Numeric implementation

* Dealing with all sorts of numeric literals.

* Fix DA.Generics

* Reduce code duplication with IF_NUMERIC

* Simplify Prelude with IF_NUMERIC

* Fix daml-lf validation for MUL_NUMERIC and DIV_NUMERIC
2019-09-25 10:56:33 +01:00
Remy
23c3c33fe1
scenario-service: run no validation, when called from ide (#3003) 2019-09-25 11:06:47 +02:00
Martin Huschenbett
2ac81ce4b8
Change Haskell implementation of DAML-LF encoder to monadic style (#3007)
This is in preparation for interning all strings during encoding, which
will replace the current reader monad by a state monad.

This PR does not change or add any functionality. It is purely a
refactoring.
2019-09-25 09:14:11 +02:00
Shayne Fletcher
f6173c0037 Update hlint (#2999)
* Sync to f65e69951032a4c2ab308fd3c3471cd833925abf

* In the DAML parse tree, ListComps are coming through as MonadComps

* Linting smoke tests for lists

* Punctuate test header for readability
2019-09-25 03:17:13 +00:00
Rohan Jacob-Rao
4d641dbb66 Fix a bug in template resugaring (#2942)
Under very specific circumstances, as presented in `TemplateSuperClassD`, the
template resugaring would fail and the compiler crash. This PR fixes the
problem.

It also adds test case `TemplateSuperClassF` for similar very specific
circumstances under which template resugaring would fail.
2019-09-24 21:38:13 +00:00
Shayne Fletcher
044560ad70
Update hlint (cabal changes) (#3011)
* Update hlint (cabal changes)

* Fix the now failing test
2019-09-24 17:21:20 -04:00
Moritz Kiefer
1d593f2a16 Deduce pkgname in damlc migrate from dalf not dar (#3000)
The filename of the dar is not something that you should rely on as
evidenced by the fact that we have a -o option to change it to
something completely different.
2019-09-24 15:13:57 +00:00
Moritz Kiefer
78e51090df Fix Windows CPP issues (#2991)
The issue was actually not really related to CPP but to the lack of
sandboxing on Windows. That resulted in us overwriting Prelude.hi from
the 1.dev rule with the Prelude.hi from the 1.6 rule in some cases
which caused the error we were seeing.

fixes #2983
2019-09-24 13:42:48 +00:00
Moritz Kiefer
2644c98508
Update comments for getSrcRoot to new semantics (#2990) 2019-09-24 10:12:38 +02:00
Moritz Kiefer
9decc6b25f Fix getSrcRoot for A/B.daml (#2989)
Previuosly we would return A for module A.B in A/B.daml which resulted
in us including /B.daml in the DAR instead of /A/B.daml.
2019-09-24 00:31:52 +00:00
Moritz Kiefer
2e9f300563 Address comments on AnyTemplate PRs (#2986)
* Address comments on AnyTemplate PRs

* Remove unnecessary HIDE
2019-09-23 17:58:02 +00:00
associahedron
db04b57f3e Name collision checking within a module. (#2981)
* Implement name collision check

* Better error messages

* Update copyright header

* Make the map strict

* Update collision test
2019-09-23 17:17:38 +00:00
Moritz Kiefer
bf3f0063d2
Get rid of ./build.sh scripts for damlc migrate (#2984)
Now that we have the build-options fields that makes for a much nicer
interface.
2019-09-23 19:08:30 +02:00
Martin Huschenbett
2eb538e1d1 Remove outdated comment regarding feature flags in compiler (#2985) 2019-09-23 16:34:53 +00:00
Moritz Kiefer
2ab06da199 Use a consistant include dir for cwd (#2978)
* Use a consistant include dir for cwd

See https://github.com/digital-asset/ghcide/pull/114 for the actual
fix.
This PR just bumps ghcide and adds a regression test. I’ll change the
revision before merging, I just want to test CI for now.

fixes #2929

* Switch to proper ghcide revision

* writeIfacesAndHie no longer exists

* Add changelog entry

* Maybe I should try to compile code before committing but I don’t want to

* Fix ghcide exe
2019-09-23 14:33:06 +00:00
Moritz Kiefer
7a2e12d6d2
[daml-triggers] Expose template data in CreateEvents (#2973)
Now that we have AnyTemplate, we can actually make the template data accessible.
2019-09-23 12:49:01 +02:00
Moritz Kiefer
2de32b7419
Include all daml files in dar if source points to a file (#2970)
Previously, we only included the source file itself but not its
dependencies which didn’t make much sense.

This fixes #2960
2019-09-23 11:14:35 +02:00
Moritz Kiefer
20b182fcf2 Workaround Windows CPP issues (#2966)
Not sure why this is failing but given that I won’t have the time to
investigate this today, feel free to merge this as a workaround for
now.

My current suspicion is that caching is broken somehow so maybe if the
nodes get recycled it will fix itself.
2019-09-20 11:14:38 +01:00
Shayne Fletcher
f7c52d4228 Disable redundant $ rule by default (#2962) 2019-09-19 19:12:21 +00:00
Moritz Kiefer
69da1d6379 Implement AnyTemplate in DAML (#2947)
* Implement AnyTemplate in DAML

* Fix doctest path

* Shuffle around CPP

* Do not hide anything

* Hide it again

* Clean build

* Enable caching again

* debug windows crap

* more tests

* reinstantiate full tests
2019-09-19 08:42:55 +00:00
Shayne Fletcher
11f29469fe Move the dump parse tree logic slightly (#2949) 2019-09-18 15:00:36 +00:00
Moritz Kiefer
b2b94ac835
Remove redundant dropWhile isTypeArg (#2943)
(_, args) is already the result of calling "span isTypeArg" so isTypeArg
can never return true here.
2019-09-18 13:37:08 +02:00
Moritz Kiefer
afde28f1da
Bump ghc-ghcide (#2936) 2019-09-18 10:29:02 +02:00
Remy
220a03c9e8 Daml-LF: make MUL_NUMERIC and DIV_NUMERIC multi-scale (#2921)
* daml-lf: Make MUL_NUMERIC and DIV_NUMERIC multi-scale

* update release notes

* compiler: fix with type change
2019-09-17 14:32:49 +00:00
Moritz Kiefer
36e95f6cf3
Add Any type and to_any/from_any primitives to protobuf (#2930)
* Add Any type and to_any/from_any primitives to protobuf

Following a suggestion by Rémy, the protobuf representation is more
general and is associated with an arbitrary type instead of a
typecon. This allows us to easily extend this later to a full Any
type.

I’ve still called the type in the protobuf Any instead of Haskell’s
Dynamic since I find AnyTemplate more clear than DynamicTemplate and
having AnyTemplate and Dynamic seems confusing.

Right now, the decoder enforces that the type is a TypeCon.

* Fix some mistakes in the spec

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Add evaluation rule for to_any_template

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>
2019-09-17 15:02:59 +02:00
Jost Berthold
277bfcbb70 HOTFIX damldoc: suppress instance docs when --data-only (#2927) 2019-09-17 11:55:51 +00:00
Remy
dc9429be1d Daml-LF: Add CAST_NUMERIC and SHIFT_NUMERIC (#2919)
* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC internally

* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC to archive proto

* daml-lf: update spec with CAST_NUMERIC and SHIFT_NUMERIC

* update release notes

* fix spec

* Address comments from Fran and Gerolf

* fix unrel
2019-09-17 08:52:54 +00:00
Martin Huschenbett
9a4735a9b3 Allow qualified import of generic templates (#2892)
* Allow for importig generic templates qualified

Currently, there's a bug which breaks `template instance` declarations when
the module containing the generic template definition is imported qualified.

This PR fixes this problem.

* Update ghc-lib, allowing qualified import of generic templates
2019-09-16 17:00:21 +00:00
Shayne Fletcher
4140b9e028
Don't disable $ rules (#2909) 2019-09-16 10:17:00 -04:00
Robin Krom
0f015e965f
language: support for automatic embeddings/projections in migation (#2893)
* language: support for automatic embeddings/projections in migation

This adds support to automatically generate embeddings/projections if an
optional field to a contract template is added. This allows generation
of migration contracts for these kind of updates.

* only project None entries

* added a test for optional field embedding/projection.
2019-09-16 14:31:38 +02:00
associahedron
dc32abb220
Add a CPP flag for each available DAML-LF feature. (#2896)
* Expose Daml LF features as a CPP flags.

* Add missing text dependency
2019-09-16 11:34:02 +01:00
Shayne Fletcher
c4c658dcb3
Add syntax tree dump support to damlc compile command (#2895) 2019-09-13 10:14:48 -04:00
Rohan Jacob-Rao
e1ff195cee
Update ghc-lib, adding locations to errors with generic templates (#2894)
* Update ghc-lib, adding some locations to errors with generic templates

* Test for template instance location
2019-09-13 10:11:00 -04:00
Jussi Mäki
868cb785ad
Preload packages to engine during upload (#2860)
* Preload packages to engine during upload

* Improve logging in KeyValueCommitting and add timing information

* Fix scenario service tests now that logging is done in interpreter
2019-09-13 14:31:52 +02:00
associahedron
183d28995f Make CPP work in damldocs. (#2891)
* Make CPP work in damldocs.

* buildifier

* Use getTemporaryDirectory

* lint
2019-09-13 11:09:39 +00:00
Shayne Fletcher
546a52e745
Remove two redundant parenthesizations (#2873)
* Remove two redundant parenthesizations

* Add test and improve comments

* Improve comments, start on some more tests (more to come)

* Bind to the newest hlint; more tests.
2019-09-11 12:41:33 -04:00
associahedron
2027d39206 Enable {-# LANGUAGE CPP #-} for daml. (#2878)
* Passing the preprocessor

* Add ghcversion.h

* Remove {-# LANGUAGE CPP #-} for now.

* Remove spurious #line

* Always add platform info, and pass -P flag

* buildifier

* Generate blank ghcversion.h to get around copyright headers check.

* Reviewer suggestions
2019-09-11 15:28:34 +00:00
Shayne Fletcher
388af4c29a
Default disable "Use camelCase" (#2885) 2019-09-11 10:30:45 -04:00
Robin Krom
41aa03c711
language: fix: missing template instances in package (#2884)
The package compiled via daml migrate was missing the actual
Upgrade/Rollback templates. This is because we used `type` instead of
`template instance` to define those templates. Also, apparently we need
to export UpgradeInstance/RollbackInstance from DA.Upgrade in the
standard library.
2019-09-11 16:05:46 +02:00
Moritz Kiefer
e2c3474f1c Upgrade ghcide to incorporate the latest changes (#2879) 2019-09-11 13:19:11 +00:00
Martin Huschenbett
2411fdb0e0 Allow exercising choices on generic templates in a generic context (#2871)
* Allow exercising choices on generic templates in a generic context

Every `template T a_1 a_n` gets desugared into a `class TInstance a_1 ... a_n`,
an instance
```
(*)    instance TInstance a_1 ... a_n => Template (T a_1 ... a_n)
```
and instances `instance TInstance a_1 ... a_n => Choice (T a_1 ... a_n) C R`
for each choice `C`.

Thus, a _generic_ exercise of a choice on `T t_1 ... t_n` needs to have the
`TInstance t_1 ... t_n` constraint in scope. However, we want to keep the
existence of the `TInstance` class an implementation detail and not expose
it to our users. Instead we want our users to add a `Template (T t_1 ... t_n)`
constraint when they want to perform the generic exercise.

Due to the (*) instance above, the constraint `Template (T t_1 ... t_n)`
is satisfied if and only if the constraint `TInstance t_1 ... t_n` is
satisfied. For the intent described above it would be necessary that GHC
conlcudes the latter from the former. Unfortunately, GHC's type system only
allows for concluding the former from the latter.

Thus, we add a preprocessing step which rewrites all constraints of
the form `Template (T t_1 ... t_n)` into `TInstance t_1 ... t_n`.

* Add test for fetchByKey
2019-09-11 09:41:21 +00:00
Moritz Kiefer
f7befca723
Get ghcide from the new upstream repo (#2867)
* Get ghcide from the new upstream repo

* Update azure-pipelines.yml

Co-Authored-By: Gary Verhaegen <gary.verhaegen@digitalasset.com>
2019-09-11 08:57:48 +02:00
Robin Krom
29b8aed5f1
language: fix: forgot to archive contract id in Update template. (#2869)
This makes sure the in-contract of the update gets archived before the
new updated contract is created.
2019-09-10 20:38:23 +02:00
Shayne Fletcher
5b6a809433
Remove (one) redundant parenthesization (#2865) 2019-09-10 12:19:49 -04:00
Gary Verhaegen
5234236639
add build-options to daml.yaml (#2772) 2019-09-10 18:16:33 +02:00
Martin Huschenbett
cb60a6d26e Avoid duplicate variant constructors (#2840)
GHC produces a function `$WFoo` for every variant data constructor `Foo`.
The conversion to DAML-LF produces a function `$ctor:Foo` which does exactly
the same. We stop doing this and use the `$WFoo` function instead.

The resulting code looks quite messy. I'll clean it up in a separate PR,
which will most likely involve some refactoring as well.
2019-09-10 13:58:06 +00:00
Shayne Fletcher
d4d757f8bc
Update hlint; disable bracket rules for now (#2837) 2019-09-10 09:57:27 -04:00
Martin Huschenbett
0fdf85442f
Improve UX of generic templates over Ledger API (#2779)
* Improve UX of generic templates over Ledger API

Currently, if you write
```
template Template t => Proposal t with
    receiver: Party
    asset: t
  where ...
template Iou with ...
template instance ProposalIou = Proposal Iou
```
you'll get the following DAML-LF types:
```
record Proposal t = { receiver : Party, asset : t }
record Iou = ...
record ProposalIou = { unpack : Proposal Iou }
```
The definition of `ProposalIou` is not particularly user friendly when used
over the Ledger API.

This PR changes the definition of `ProposalIou` to
```
record ProposalIou = { receiver : Party, asset : Iou }
```
Basically, the definition of `Proposal` is copied and `t` is instantiated
with `Iou`. This should make a much nicer UX.

* Update documentation

* Add test

* Fix docs examples

* Fix release notes
2019-09-10 14:38:25 +02:00
Ganesh Sittampalam
bb90002e66 ghcide: support hs-boot files (#2827) 2019-09-10 11:35:52 +02:00
Ganesh Sittampalam
21022f411b ghcide: make tests fail on unexpected diagnostic messages (#2813) (#2823)
This has the downside of relying on a timeout, experimentally tuned
to be 0.5s, as we have no other way of knowing when the server has
finished sending us messages.
2019-09-09 20:24:50 +02:00
Moritz Kiefer
d2b68d45d4 Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
2019-09-09 13:55:16 +00:00
Neil Mitchell
a7002616a3 hie-core: Ignore packages that conflict with ghc in the hie.yaml (#2819) 2019-09-09 12:02:41 +02:00
jacg
cc452a626f hie-core: Remove code pretty printing from diagnostic output (#2810)
In moving from v. 0.15 to 0.16, haskell-lsp changed the type of the
value which ended up being passed to `pretty` from `Maybe Text` to
`Maybe LSP.NumberOrString`, thereby breaking the line of code which is
removed in this commit.

After discussion with @ndmitchell, it was observed that this code was
never useful, and fixing it was not worth the trouble.
2019-09-08 18:04:19 +02:00
Ganesh Sittampalam
a3111fadc1 A couple of improvements to the experience developing hie-core itself (#2812)
* Put information about the compiler pass in the _source field of Diagnostic

It's useful when looking at the hie-core command-line output to see where
a problem is coming from.

* include test code in hie-core's own cradle
2019-09-08 18:04:04 +02:00
Domen Kožar
0779776413 README: add notes for Nix installation (#2805) 2019-09-08 16:57:59 +02:00
Tobias Pflug
c09781bab2 Add languageclient-neovim info to README (#2806) 2019-09-08 16:36:38 +02:00
Moritz Kiefer
becb3ba8eb Fix hie-core cabal file metadata (#2804) 2019-09-07 15:06:25 +00:00
Neil Mitchell
bdcbf16462 #2326, GHC 8.4 compatibility (#2796)
* #2326, GHC 8.4 compatibility

* Fix up CI

* Add a Shake lower bound

* Upgrade to a hie-bios which is GHC 8.4 compatible

* Add a GHC 8.4 stack

* Fix HLint again
2019-09-07 16:23:14 +02:00
Robin Krom
aa1e95173a
language: check dflags for errors (#2748)
* language: check dflags for errors

We add a check when we build the dflags for cases that will lead to a
failed build and emmit a clearer error message. Currently this only
includes a check, to see whether the current installed unit id is also
imported as a package from the package database.

* exclude ghc-prim from check

* exclude code generation from dflag check

* add an internal option to turn dflags check off
2019-09-06 21:24:46 +02:00
Stefan Matting
43fc0a1c8b hie-core: Add instructions for Vim (#2793) 2019-09-06 15:30:48 +02:00
Neil Mitchell
6803310fb2 Constrain ghc so that people with 8.4 don't get install plans (#2790) 2019-09-06 14:42:19 +02:00
associahedron
3c78e6110f Move (/) to a Divisible class and drop the Fractional Int instance. (#2728)
* Move (/) into a separate typeclass.

* Update release notes.

* Wording change

* rst syntax!!!

* tweak release notes.

* Remove recip on Int test.

* deduplication of release notes.

* Fix release notes?
2019-09-06 11:51:51 +00:00
associahedron
a50e0c2e0e Move HasField to DA.Record in the stdlib docs. (#2764) 2019-09-06 10:28:24 +00:00
Andreas Herrmann
ed39800a9f Rename hazel_deps to hackage_deps (#2789)
* hazel_deps --> hackage_deps

Mechanical change:

```
sed -i 's/hazel_deps/hackage_deps/g' $(ag -l hazel_deps)
```

* Hazel dependencies --> Hackage dependencies
2019-09-06 09:01:09 +00:00
Neil Mitchell
fc159a2d41 Fix hie.yaml so you can still load hie-core in hie-core (#2786) 2019-09-06 06:43:31 +02:00
Anup Kalburgi
0a9e0a8911 Adding fields to template graphs (#2673)
* Adding more info to dor

* Adding fields to the graph

* Spelling mistakes and params

* Removing single line function

* Moving the duplicated code

* Revert "Moving the duplicated code"

This reverts commit 520b5d9b0d.

* Adding more structure to graph

* Working tests with graph which is more easy to understand and change.
have few more tests to migrate

* Adding edge details

* One more to go

* Adding more verbose field information

* All tests now tests the fields that are being added

* Removing unused Import

* defined not refined

* Unused imports

* Names need to be consitent

* Acutal and Expected, not expected and expected

* Removing unused export

* Lints
2019-09-05 15:57:58 +00:00
Bernhard Elsner
ad77aba246 Fix symbol in DA.Logic (#2765) 2019-09-05 12:17:28 +00:00
associahedron
ce52a0a24f
Escape all text in rst docs. (#2747)
* Escape text in rst.

* Fix the escaping

* Fix spacing and tests
2019-09-05 12:39:29 +01:00
Martin Huschenbett
b7bcba4ca7
Drop deprecated TextMap.filter from daml-stdlib (#2761)
It has been deprecated for a while now with a hint to use `filterWithKey`
instead. We should add
```haskell
filter : (v -> Bool) -> TextMap v -> TextMap v
```
after the next SDK release instead. This is tracked in #2760.
2019-09-05 13:34:49 +02:00
Martin Huschenbett
b95daba9ed Simplify conversion of top level bindings to DAML-LF (#2730)
At the top level we don't care if bindings are recursive or not. The logic
that takes care of this ignorance is currently mixed with the actual logic
for converting the bindings.

This PR separates these concerns properly. This is also in preparation for
another upcoming change which needs access to all top level bindings.
2019-09-02 19:51:03 +00:00
Martin Huschenbett
f787a0d715 Remove unused tracking of default methods from conversion to DAML-LF (#2729)
The removed code had a purpose in the past but has not been used anymore for
a while. Let's remove it.
2019-09-02 18:49:48 +00:00
Rohan Jacob-Rao
30fe23a4c1 Organise generic templates and instances into separate files (#2727)
* Organise generic templates and instances into separate files, add Fungibility

* Expect hlint warning in scenario
2019-09-02 18:39:45 +00:00
associahedron
ea9d9cb02e Convert Decimal type, literals, and primitives to Numeric when feature is available. (#2723)
* Add missing alpha-equivalence case.

* Type-level nat is not serializable.

* Convert decimal primitives as numeric primitives if feature is available.

* Convert decimal literals to numeric if available.

* Better approach to decimal primitves.

* Fixing BEDecimalFromText

* Add issue number

* Set Numeric feature at v1.7
2019-09-02 17:10:26 +00:00
Moritz Kiefer
336cad1016
Fix ghc-pkg runfiles (#2726)
This allows us to run "damlc build" in Bazel rules which is a
prerequisite for doing anything with DAML packages as they don’t work
with "damlc package".
2019-09-02 18:50:25 +02:00
Martin Huschenbett
222f8c6fc1
Revert type based computation of table headers in scenario view (#2704)
The type based computation doesn't work as intended. Let's go back to the
value based computation for now and fix it later.
2019-09-02 12:35:52 +02:00
Robin Krom
d5c6d93772
langauge: suppress warnings for unrecognised pragams in upgrades (#2711)
This make the build of upgrade modules a bit more quiet. The warnings
appear because in the generated generic instances there is an
unrecognised {-# NO_OVERLAPP #-} pragma annotation.
2019-08-30 12:21:01 +02:00
associahedron
0eed4afb3f Add Numeric literals in daml-lf-ast and daml-lf-proto. (#2706)
* Add Numeric literals.

* Decode numeric literals

* Add tests and fix Read for s=0

* lint

* Copyright header

* Use numericMaxScale in Serializability check

* Fix comment!
2019-08-30 08:45:03 +00:00
Remy
20649cf78e ledger-api: rename decimal field to numeric in value Proto (#2688)
* add Numeric.java

* ledger-api: rename `decimal` field to `numeric` in value protobuf

* Address Gerolf's comment

* ledger-api: add missing renammings

* ledger-api: relax syntax of numbers that can be sent as numerics

* extractor:  fix

* leger-api: change format of number though ledger api

* daml-lf: fix numeric regexp

* ledger: fix tests
2019-08-29 22:51:33 +00:00
Rohan Jacob-Rao
8dbc556655 Sketch of generic transfers and swaps (#2640)
* Templates and scenario for generic transfers

* Simplify transfer workflow by self-issuing cash

* Generic swap in the same style as Transferrable

* Use Template class constraints instead of *Instance constraints

* Shorter asset name for transferrable/swappable templates

* Shorten some stuff

* Simplify swap acceptance, remove dependency on transfers, add some checks in scenarios

* Remove FlexibleContexts extension which should be on by default

* Move Asset typeclass and Cash instance to separate module

* Rename Swap module to Swappable

* Revert change to VERSION file
2019-08-29 16:05:24 +00:00
Robin Krom
7fca591df0
replace main file with a pointer to the source root (#2687)
* language: compile everything in the source directory

This removes the need to specify a 'main'. Instead we 'source' in
daml.yaml should point to the source root directory.
2019-08-29 13:42:33 +02:00
Moritz Kiefer
3cda28935b Refactor DAR manifest reader (#2699)
* Refactor DAR manifest reader

This PR replaces the ad hoc string munging by a proper parser.

* Fix tests

* Fix more tests

* Factor out isHeaderChar
2019-08-29 10:26:53 +00:00
Moritz Kiefer
abfce20ce9
Fix damlc manifest writer (#2689)
Previously, we didn’t broke at 72 chars instead of 72 bytes and we did
not take the newline character into account.
2019-08-28 16:31:20 +02:00
Moritz Kiefer
664a633e20
Fix heap corruption in grpc-haskell-core (#2685)
The details are in the patch which I will also upstream.

fixes #2644
2019-08-28 16:21:37 +02:00
Martin Huschenbett
596058ac3f Allow boundedly polymorphic recursive functions without type annotation (#2684)
Currently, recursive top level functions whose type is boundedly polymorphic
require a type annotation to make it through the conversion to DAML-LF.

This PR changes the conversion slightly such that a type annotation is n o
longer required.

This fixes #2669.
2019-08-28 12:56:06 +00:00