Commit Graph

158 Commits

Author SHA1 Message Date
Moritz Kiefer
82465e2e85
Drop Decimal completely from damlc (#12120)
no need to keep it if we can neither read nor write it.

changelog_begin
changelog_end
2021-12-13 12:30:53 +00:00
Sofia Faro
04dd386dcc
interfaces: Add up/downcast in haskell AST (#12048)
Adds EToRequiredInterface and EFromRequiredInterface in
the Haskell AST, and the typechecker.

Part of #11978

changelog_begin
changelog_end
2021-12-08 13:22:08 +00:00
Sofia Faro
43c8641215
interfaces: add up/downcast expressions in proto (#12030)
Part of https://github.com/digital-asset/daml/issues/11978

changelog_begin
changelog_end
2021-12-07 18:44:24 +00:00
Sofia Faro
1dd813170d
interfaces: Add "requires" field in Haskell AST. (#12016)
* interfaces: Add "requires" field in Haskell AST.

Part of #11978. Adds typechecking for this on the interface and
implementation side.

changelog_begin
changelog_end

* Fix all the errors
2021-12-07 17:01:45 +00:00
Sofia Faro
9430ee3131
interfaces: Add requires in DefInterface protobuf (#11986)
Part of #11978

changelog_begin
changelog_end
2021-12-07 00:38:59 +00:00
Moritz Kiefer
cf172619e5
Drop support for Daml-LF party literals-LF from the Haskell side (#11930)
This PR enforces that forbidPartyLiterals is always `true` and drops
the corresponding literals from the AST in our Haskell code. Scala
code will follow separately.

part of #11581

changelog_begin
changelog_end
2021-12-01 11:00:09 +01:00
Moritz Kiefer
16135e6f7c
Limit supported input versions in damlc to >= LF 1.8 (#11905)
* Limit supported input versions in damlc to >= LF 1.8

1.8 was the version that introduced type synonyms, we really don’t
gain much by dropping more since data-dependencies mainly depends on
that. and this provides for a very natural upgrade path for users
where pretty much everyone should be able to upgrade directly to SDK
2.0 without having to go through intermediate versions.

changelog_begin

- [Daml Compiler] The supported input LF versions for
  data-dependencies are now limited to LF 1.8 and newer.

changelog_end

* fix some tests

changelog_begin
changelog_end

* Drop export 1.6 tests

changelog_begin
changelog_end

* Drop daml2js support for LF < 1.8

changelog_begin

- [Daml2js] DARs with LF version < 1.8 are no longer supported.

changelog_end

* .

changelog_begin
changelog_end

* bash is bad, stop using it

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-30 17:24:08 +01:00
Sofia Faro
1d7bca801e
Add optional typerep argument in UExerciseInterface. (#11910)
* Add type rep argument for interface exercises.

(Still WIP.)

Part of #11703. Fixes the order in which errors are raised ("wrong type"
takes priority over "does not implement interface"). This PR also simplifies
ExerciseInterface by making the guard mandatory, otherwise there's too
many variations. We can revisit that later if we want.

changelog_begin
changelog_end

* haskell side

* dont throw exception in checkTemplateId

* scalafmt

* evidence security

* fix TypingSpec test
2021-11-30 15:10:33 +00:00
Moritz Kiefer
dbbb05fe2e
Split daml-lf encode/decode Haskell libraries (#11906)
* Split daml-lf encode/decode Haskell libraries

I was working on limiting the supported input versions in damlc. This
requires the list of stable package ids so we can allow those to be
decoded even if they are older.

However that leads to a cyclical dependency:
To get the package ids of the stable packages, I need to encode
them. The version check is in the decoder. If those live in the same
package, I now end up with a cyclical dependency and
Bazel (understandably) gets very sad.

This PR splits decoding/encoding into two libraries with the
generation of stable packages only depending on encoding.

changelog_begin
changelog_end

* Fix dependants

changelog_begin
changelog_end
2021-11-29 12:49:02 +00:00
Moritz Kiefer
3b5f8a73e1
Remove precondition field from TemplateImplements (#11763)
* Remove precondition field from TemplateImplements

fixes #11635

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-18 17:10:40 +01:00
Sofia Faro
87f282c7f3
interfaces: Preserve/provide by_interface data for create actions. (#11639)
* interfaces: Preserve by_interface data for create.

Part of #10915

This was a lot more involved than fetch or exercise. The first issue is
that we need to preserve the interface id into speedy, so it needs a
separate primitive ("experimental" won't cut it). Second, because
speedy's create requires the template definition, and now the interface
id as well, we basically need to compile a separate version of "create"
for each interface that a template implements, hence the separate
`CreateByInterfaceDefRef(templateId, ifaceId)`.

changelog_begin
changelog_end

* scalafmt and refactoring

* fixx merge conflict

* fix silly mistakes
2021-11-11 12:57:55 +00:00
Moisés Ackerman
7d68e05f7f
Remove virtual choices (#11482)
* Remove virtual choices

* Remove choices without a body in 'interface' definition
* Remove choices in 'template ... implements' section

part of #11372

changelog_begin
changelog_end

* Remove virtual choices cont.

Switch uses of virtual choices to fixed choice with method implementation

* update snapshot after pin on windows

* Disable failing interface tests with TODO #10810
2021-11-08 17:05:23 +01:00
Robin Krom
da76e2825b
iface: check for interface implementations precond (#11494)
* iface: check for interface implementations precond

We change speedy to also check all preconditions defined in interface
implementations upon a create.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

* format

* interfaces: lfconversion for iface preconditions

This adds interface preconditions to the interface implementations
during completion phase in the LF conversion.

CHANGELOG_BEGIN
CHANGELOG_END

* format

* rebase

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-02 17:27:49 +00:00
Sofia Faro
741a6e75a7
interfaces: Add list of fixed choices in TemplateImplements structure. (#11364)
* interfaces: Add fixed choices in TemplateImplements

To make template choice collision checks local.

changelog_begin
changelog_end

* LF completer

* lint

* scary non-shadowing

* improve comment

* change field name
2021-11-01 11:51:51 +00:00
Robin Krom
d3b9c84908
ifaces: preconditions, proto changes (#11448)
This adds a precondition expression to the protobuf and the
encoders/decoders on the haskell side.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-28 13:15:22 +00:00
Sofia Faro
ce64cb2a13
interfaces: Do some TODOs (#11231)
* interfaces: Do some TODOs

- Add uniqueness check between fixed choices and virtual choices in
  haskell decoder.
- Encode interface methods and fixed choices in scala encoder.
- ExprIterable for interfaces.

changelog_begin
changelog_end

* scalafmt
2021-10-13 13:36:53 +01:00
Sofia Faro
53c76d47c3
interface fixed choices: Haskell AST (#11160)
* interface fixed choices: Haskell AST

Part of #11137

changelog_begin
changelog_end

* Make intParam strict
2021-10-07 10:46:50 +00:00
Sofia Faro
7f6c8608bd
Interface fixed choices: protobuf (#11139)
Adds protobuf for fixed choices. ASTs left for later.

changelog_begin
changelog_end
2021-10-06 16:01:41 +01:00
Sofia Faro
4075624cfc
interface methods: Haskell AST (#11018)
* interface methods: Haskell AST for methods

Part of #11006. This leaves typechecker and LF conversion for later, on
the haskell side.

changelog_begin
changelog_end

* Forgot ECallInterface in DecodeV1

* fix a test
2021-09-27 10:10:21 +01:00
Sofia Faro
bf8b75dab5
interface methods: Add protobuf definitions. (#11005)
* interface methods: Add protobuf

Adds protobuf definitions for interface methods and calling them.
Encoders/decoders just ignore the extra stuff or error out.

Part of #10810 (maybe)

changelog_begin
changelog_end

* Update issue numbers where appropriate

* update stable protos
2021-09-23 14:55:19 +01:00
Sofia Faro
724e50d739
interfaces: Add to/from interface in Haskell AST (#10945)
Part of #10810

changelog_begin
changelog_end
2021-09-21 10:24:10 +01:00
Sofia Faro
409c0b4f60
interfaces: Add to/from_interface in proto (#10937)
* interfaces: Add to/from_interface in proto

Part of #10810

changelog_begin
changelog_end

* fix typo
2021-09-20 13:44:00 +00:00
Moritz Kiefer
9b0fa29aec
Separate exercise & fetch for interfaces from templates (#10908)
* Separate exercise & fetch for interfaces from templates

part of #10810

changelog_begin
changelog_end

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-16 12:05:11 +00:00
Robin Krom
8f5b4fa84c
interfaces: protobuf encoder haskell side (#10850)
* interfaces: protobuf encoder haskell side

This is the implementation of the protobuf encoder on the haskell side.

CHANGELOG_BEGIN
CHANGELOG_END

* missing decoder cases for added interface data constructor
2021-09-13 14:36:14 +00:00
Robin Krom
2aaf601912
interfaces: protobuf decoder haskell side (#10849)
CHANGELOG_BEGIN
CHANGELOG_END
2021-09-13 14:58:48 +02:00
Moritz Kiefer
6d347d4e88
Add daml interfaces to the Haskell LF AST (#10811)
* Add daml interfaces to the Haskell LF AST

Just copied from Sofia’s PR with no changes and stubbed all usages of
it that aren’t trivial.

changelog_begin
changelog_end
2021-09-08 15:48:02 +00:00
Robin Krom
b8bd5e6399
interface PoC: protobuf definitions (#10796)
* interface PoC: protobuf definitions

The protobuf changes for the Daml interface PoC.

CHANGELOG_BEGIN
CHANGELOG_END

* dummy interface decoder/encoder
2021-09-07 16:58:49 +02:00
Remy
f033bc2bbb
LF: Clean legacy from archive proto + TEXT_TO_CODE_POINTS typo (#10286)
Thanks to @tristan-da for pointing this out.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-15 16:01:08 +02:00
Jost Berthold
8a6e3ee95b
DEL-8657 update version info for Haskell LF libraries (#10160)
* DEL-8657 update version info for Haskell LF libraries

CHANGELOG_BEGIN
CHANGELOG_END

* DEL-8657 add a missing module
2021-07-02 09:46:53 +10:00
Remy
1f021b25c6
LF: Drop Builtin Exceptions completly (#9790)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-26 19:30:44 +02:00
Remy
5855a9941f
LF: Drop CONTRACT_ERROR (#9754)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-21 09:12:29 +00:00
Remy
40b23810d2
Compiler: clean convertion builtin name (#9724)
This follows up #9716

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 19:16:29 +02:00
Remy
fcbba1cd95
LF: rename convertion builtins to be more obvious (#9716)
The name of some builtins will be exposed as part of the Exception
message. This PR, try to make conversion builtins more consistent and
more obvious, before we could not rename those.

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 10:11:26 +00:00
Remy
55c36cc93e
Compiler: drop BEToTextBigNumeric in favor of BEToText (#9728)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 14:49:03 +00:00
Remy
d4fca0305b
LF: Change error exception for Arithmetic builtins (#9692)
This PR is a priliminary step toward making Arithmetic Builtin
throwing proper Daml Excetpions.

This is part of #8020.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 10:41:44 +02:00
Remy
fc745f2224
LF: clean shifting BigNumeric builtin (#9704)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 19:26:14 +02:00
Jost Berthold
6629aab009
DEL-8479 tag LF libs for SDK 1.13 release (#9680)
* DEL-8479 bump lib versions to 0.1.13

* HOTFIX use newer resolver lts-17.11 and protobuf from hackage


changelog_begin
changelog_end
2021-05-14 16:38:20 +10:00
Sofia Faro
22ba5fddd2
Remove builtin exception types from protobuf and ASTs. (#9595)
* Remove builtin exception types from protobuf/AST.

changelog_begin
changelog_end

* Remove builtin exxceptions from protobuf/ast.

* remove unecessary s"

* scalafmt

* syntax error

* Add TODOs

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Add AnyException builtins in typing spec.

* Update protobuf "Next id" comment.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-06 21:26:12 +00:00
Sofia Faro
1627b70427
Pattern matching for RoundingMode (#9381)
* Pattern matching for RoundingMode

- Fix the order of RoundingMode constructors in GHC.Types to match the LF built-in order. Try to match this order across all code and documentation, and added a test for this order.
- Implements pattern matching for RoundingMode. The added machinery could also be useful for solving #5753 in the future.
- Implements Show instance for RoundingMode. (Mainly so we can use them in tests.) Moved BigNumeric Show instance to GHC.Show.

changelog_begin
changelog_end

* mkScrutineeEquality typo

* fix roundingModeLiteralMap order

* Use custom type for building case body

* Factor GeneralisedCaseAlternative into GeneralisedCasePattern

* Fix finalize

* Remove unused bindings
2021-04-13 15:47:16 +00:00
Remy
6c1f404c7d
LF: Add TO_TEXT_BIGNUMERIC (#9276)
This is part of #8719.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-30 13:31:42 +02:00
Remy
181afe4607
Daml: Add basic support for BigNumeric in 1.dev (#9243)
CHANGELOG_BEGIN
CHANGELOG_END
2021-03-26 09:00:05 +01:00
Remy
1e0c67c306
LF: Add RoundingMode and BigNumeric in Haskell Ast (#9215)
This is part of #8719.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-23 16:50:17 +00:00
Remy
51c5eac66e
LF: Add BigNumeric to archive proto (#9210)
CHANGELOG_BEGIN
CHANGELOG_END
2021-03-23 13:58:22 +00:00
Remy
70379d4e85
LF: Experiment Hook for 1.dev (#9051)
This PR adds a hook in the compiler and the engine to allow easy prototyping of new features.

In particular by using this hook, one can add a new feature in 1.dev with modifying:

    compiler
    type checkers (both Haskell and Scala)
    archive Protobuf
    archive decoder

In addition of development speed, this also adds a bit of confidence, as the peaces enumerated above are not touched when adding the feature: The feature can be added by modifying only 1.dev Daml standard library and Speedy.

aa7991f8 shows a use case of this hook.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-11 21:36:49 +01:00
Jost Berthold
5d44ff9085
Upgrade the LF library build setup (resolver, dependencies, version) (#8865)
Upgrade Daml LF library extraction to latest versions and newer GHC

changelog_begin
changelog_end
2021-02-17 07:07:17 +01:00
Moritz Kiefer
773ddada04
Upgrade nixpkgs (#8190)
* Upgrade nixpkgs

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* No ibazel

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Switch agent pool

changelog_begin
changelog_end

* .

* .

changelog_begin
changelog_end
2021-02-08 11:12:07 +00:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00
Sofia Faro
33df124d84
Throw exceptions directly. (#8320)
* Update protobuf to throw exceptions directly.

Part of #8020. This PR changes the exception protobuf and AST (Haskell
side) to make exceptions be thrown directly via a primitive expression
(EThrow), instead of wrapping them up via AnyException.

changelog_begin
changelog_end

* Rename MakeAnyException to ToAnyException

* update EToAnyException field names

* Missing stuff

* missing scala case

* Make AnyException unserializable

* reindex protobuf builtins

* meaningless change

* refrobulate

* change pretty
2020-12-17 14:14:46 +00:00
Jost Berthold
04a6d4c86c
HOTFIX bump versions for Haskell LF libraries (#8287)
* HOTFIX update LF lib extraction to 0.1.8.0 + add new things

* HOTFIX add a dummy project file for testing

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-17 17:41:09 +11:00
nickchapman-da
2d511b449d
Make choice observers mandatory when available. (#8316)
* Make choice observers mandatory when available.

This is an invariant of the DAML-LF proto.

The haskell AST allows missing choice observers for any version, because the AST represents what was written in the syntax. However, if we are targeting a new DAML-LF version (>= `featureChoiceObservers`) then `Nothing` is converted to `Just (ENil TParty)` by the haskell encoder (`EncodeV1.hs`) to satisfy the proto invariant.

On the scala side, the decoder (`DecodeV1.scala`) now insists that choice observers are present when_ the version is new. (>= `LV.Features.choiceObservers`).

changelog_begin
changelog_end

* LF: LF encoder generate always choice observer if lf >= 1.dev (#8318)

This is a follow up of #8316.
This advances the state of #7709

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-12-16 14:38:25 +00:00