Commit Graph

85 Commits

Author SHA1 Message Date
Moritz Kiefer
1fce415359
Only extract main dalf from a dependency (#4515)
This is a spin off from my fixes for making data-deps work with
typeclasses cross-SDK.

We only have the interface files for the main dalf so it doesn’t
really make sense to extract the other dalfs. The current behavior of
extracting all dalfs results in them being picked up by
`GeneratePackageMap` even if GHC doesn’t know about them which causes
issues in other placse.

I’ve adapted the collision check to check for transitive dependencies
when creating the project db.

changelog_begin
changelog_end
2020-02-14 13:33:48 +01:00
nickchapman-da
006aa9b608
Type checking DAML-LF type synonyms (#3959)
* CHANGELOG_BEGIN
Type-check type synonyms.
CHANGELOG_END

* placate HLint

* comments

* Add an example that requires the check in kindOf

* check types containing syn-apps are well formed even when there is no expression of that type

* show type mismatch error after synonyms are expanded

* typeOf calls expandTypeSynonyms; track vars bound by TForall during expansion

* test interaction of syn-expansion and free-vars; add one bigger testcase

* extend bigger example with pointed typeclass, having functor as a super class

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-01-10 17:51:51 +00:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
nickchapman-da
1369351f70
separate type-synonyms from type-constructors (#3829)
* separate type-synonyms from type-constructors in DAML-LF .proto and Haskell AST

* comments
2019-12-16 11:52:28 +00:00
associahedron
76531c93bf Expose generic equality in compiler (#3815) 2019-12-11 12:15:52 +00:00
Remy
e055b2bd9b DAML LF: expose generic equality in LF (#3752)
* daml-lf: expose generic equality

* drop unnecessary parentheses

* fix issue number

* address Fran's comments
2019-12-06 14:12:48 +00:00
associahedron
8127a415d9
Add unstable experimental text primitives in DA.Text and LF 1.dev (#3734)
* Add experimental text primitives

* Implement SBTextSlice

* Implemented SBTextSliceIndex

* Implement toUpper / toLower

* Implement SBTextContainsOnly

* Implement SBTextReplicate

* Implement SBTextReplicate

* Implement SBTextSplitOn

* Implement SBTextIntercalate

* Add unstable primitives in LFConversion

* Add unstable text primitives in DA.Text

* Remove all the ASCII infixes

* Fix typing mishap

* Change numbering for unstable primitives

* Deal with UTF8

* More careful slice

* Fix typo

* Missing decoder
2019-12-05 14:35:50 +00:00
nickchapman-da
d15b0c7538
Add support for type-synonyms in DAML-LF .proto and Haskell AST (#3703)
* Add support for type-synonyms in DAML-LF .proto and Haskell AST

* address review comments
2019-12-03 14:51:02 +00:00
nickchapman-da
d3d6891021
Rename daml lf tuples (#3658)
* Rename DAML-LF tuples as structs (structural records)
2019-11-28 07:58:30 +00:00
Remy
d152c7cbfd daml-lf: rename Map to TextMap in archive proto (#3589)
* daml-lf: rename Map to TextMap in archive proto
+ in Scala/haskell AST

* a bit more renamming

* Update compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Serializability.hs

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>

* fix test

* Apply suggestions from code review

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>

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

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>
2019-11-25 12:14:57 +00:00
associahedron
87de36a7fe Add GenMap support in the compiler. (#3437)
* Add GenMap support in the compiler.

* Add GenMap ticket number in Upgrade.hs
2019-11-13 13:05:53 +00:00
Remy
6f5c5fd3b1 daml-lf: add GenMap to archive proto (#3431)
* add GenMap to archive proto

* Address Martin's comments

* Address Gerolf's comments
2019-11-12 14:25:19 +00:00
Martin Huschenbett
6fe3df57cd Rewrite PRSelf when loading a dependency package (#3406)
When buidling simple project that has our favourite large project as a
dependency, this decreased
- total allocations from 63GB to 57GB
- run time from 34.0s to 31.5s
2019-11-11 08:52:07 +00:00
Moritz Kiefer
d7f5b3b436 Add support for on-disk incremental builds in damlc build (#3378)
* Add support for on-disk incremental builds in damlc build

* Normalise file paths of internal modules because Windows

* stop stealing my $s hlint

* Apparently jars are also called exe

* Address review comments

* Bump to proper ghcide revision
2019-11-07 16:56:42 +00:00
Remy
7d8a484ce9
daml-lf: prepare release of LF 1.7 (#3329)
* daml-lf: prepare release of LF 1.7

* add comment
2019-11-04 22:57:35 +01:00
Remy
7c427119e1 DAML-LF add Type Representation value (#3326)
* daml-lf: update spec with type-rep

* daml-lf: update proto with type-rep

* daml-lf: update scala side with TypeRep

* daml-lf: update compiler side with TypeRep

* Get triggers to compile

* Add featureTypeRep to allFeatures

* Apply suggestions from code review

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* daml-lf: add builtin for TypeRep equality

* Address Andrea's comments

* formatting

* Fix triggers

* Fix template typerep tests
2019-11-04 17:00:55 +00:00
Remy
d56a4aa715 Intern all strings: proto cleanup (#3296)
* daml-lf: cleanup strings/names interning for 1.dev

* change level of dottedName intening
* make interning mandatory
* rational name of proto field

* fix tests

* spec update

* fix test

* formatting

* Address Gerolf's comments

* Address Jussi's comments
2019-11-01 17:03:42 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
associahedron
dce578bbea damlc: Add Numeric primitives and type-level nats. (#2670)
* Add Numeric primitives and type-level nats

* Statically enforce Numeric scale in serializability check
2019-08-28 12:30:33 +00:00
Remy
6a96060af1 daml-lf: udpate LF protobuf for numerics (#2649)
* daml-lf: update proto for Numerics

* daml-lf: test decoder

* daml-lf: update spec

* daml-lf: polish proto doc

* damlc: address reviewers' comments

* daml-lf: minor fix
2019-08-26 11:55:48 +00:00
Moritz Kiefer
0e777d9fc8 Delete obsolete proto3-suite patch (#2601)
* Delete obsolete proto3-suite patch

My patch has been upstreamed so no need to keep it around in our repo.

* Upgrade proto3-wire

* Adapt to changes in proto3-suite
2019-08-20 10:17:26 +00:00
Remy
2abf27cd67 Revert DAML-LF proto change for Numeric (#2600)
* Revert DAML-LF proto change for Numeric

This partially reverts commit 0ffe5945b8.

* daml-lf: udpate release notes

* Apply suggestions from code review

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-08-20 08:13:15 +00:00
Bernhard Elsner
d9298c8744 Various improvements to make hs-bindings usable outside repo (#2583) 2019-08-19 16:44:45 +00:00
Gary Verhaegen
99ea93168d
update copyright notices (#2499) 2019-08-13 17:23:03 +01:00
Robin Krom
8fe537e292
Dar building cleanup (#2357)
* reorganizing dar building
2019-07-31 18:34:41 +02:00
Moritz Kiefer
72695ec310 Optimize mangleIdentifier (#2350)
* Optimize mangleIdentifier

I am slightly embarassed by importing Data.Text.Internal and
Data.Text.Array. However, this does make a very measurable difference:
On my testcase it brought down the time encoding modules from 22s to
17s, so it’s a 5s improvement.

I did quickcheck this against the old implementation, so I’m confident
it behaves correctly. I also ran some criterion benchmarks to see the
difference and on its own it’s even more of a difference.

https://gist.github.com/cocreature/822114257227473ecff1638a88f07788

* GHC is stupid :(
2019-07-31 14:07:36 +00:00
Robin Krom
3db5230a43
language: put hash in package directories (#2268)
* language: put hash in package directories

We put the package id of the main dalf of a package into the directory
names, where we store the files of that package in the package database.
This way we make sure that two equally named packages don't overwrite
their dependencies and files.
2019-07-31 14:31:45 +02:00
Stephen Compall
c483da3eb9 use MonoTraversable ModuleRef in place of Generic HasPackageRef (#2327)
* compiler: simpler packageRefs traversal

* compiler: include ModuleRefs in SourceLoc

* ignore the ModuleRef when traversing SourceLoc

- see https://github.com/digital-asset/daml/pull/2327#discussion_r308445649
2019-07-31 07:22:42 +00:00
Moritz Kiefer
50a04397e4
Supporting producing sdist tarballs for the HS ledger bindings (#2336)
* Supporting producing sdist tarballs for the HS ledger bindings

The README.md has an explanation for how you can use this.

This should hopefully allow others to experiment with the bindings.
2019-07-30 14:34:16 +02:00
Moritz Kiefer
e415527e3e
Speed up identifier mangling (#2320)
My benchmark is sadly extremely noisy which makes it hard to figure
out how much of an improvement this is but it does seem to at least be
a minor improvement.
2019-07-30 08:50:51 +02:00
Remy
0ffe5945b8 DAML-LF: Prepare archive proto for Numeric (#2298)
* daml-lf: prepare archive proto for Numeric

* replace DECIMAL by NUMERIC in messages and fields
* add nat kind and nat type
* add builtins CAST_NUMERIC and SHIFT_NUMERIC

* daml-lf: remove new builtins from archive proto

* daml-lf: some more doc about numeric

* daml-lf: fix spec
2019-07-29 18:33:52 +00:00