Commit Graph

60 Commits

Author SHA1 Message Date
Moisés Ackerman
d23d113667
Restructure interface desugaring (#11555)
* Update ghc patch

* Replace Implements proxy datatype with a class

* Expose 'Implements' class in Prelude

* Add DA.Internal.Desugar.HasMethod class

This allows us to get the type of a method of an interface through the functional dependency

* Convert interfaces from new desugaring

* Update Interface daml-test-file to use Interface class functions

* Update InterfaceDesugared daml-test-file

* Replace remaining uses of Is<Interface> methods with Implements

* Document HasMethod, Method and mkMethod

* Ignore _method_ bindings in convertBind

* Ignore interface desugaring types/classes/instances/functions in LF conversion

* update snapshot after pin on windows

changelog_begin
changelog_end
2021-11-19 10:06:49 +01:00
Moisés Ackerman
cfd521ff86
Fix GHC build errors on macOS (#11560)
changelog_begin
changelog_end
2021-11-09 14:42:52 +01:00
Robin Krom
af1bee7b82
precondition lf conversion (#11538)
* interfaces: lf conversion of preconditions

This adds the LF conversion of preconditions from the desugared GHC code
to Daml LF for preconditions. This depends on the corresponding patch of
the GHC fork.

CHANGELOG_BEGIN
CHANGELOG_END

* pin linux stackage snapshot

* added a test

CHANGELOG_BEGIN
CHANGELOG_END

* pinned linux stackage snapshot

CHANGELOG_BEGIN
CHANGELOG_END

* additional InterfacePrecondition test

this checks that that conjunction of all preconditions of intererfaces
and templates is checked.

CHANGELOG_BEGIN
CHANGELOG_END

* pin stackage snapshot

* pin windows stackage snapshot

* update compile.yml (again)

* pin linux stack snapshot

* fix InterfacePrecondition test

* pin windows stackage
2021-11-09 11:43:46 +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
12e782b1ea
ifaces: update ghc-parser (#11383)
* ifaces: update ghc-parser

This updates the ghc-parser, including the `ifaceTypeRep` method
generation for interfaces.

CHANGELOG_BEGIN
CHANGELOG_END

* pin stack snapshot on unix

* add tests

* update ghc-lib hash

* pin stackage dependencies on unix

* pinned stackage windows
2021-10-27 11:29:22 +00:00
Sofia Faro
76eb1657d2
Interface fixed choices: ghc parser (#11275)
* Interface fixed choices: ghc parser

(WIP)

changelog_begin
changelog_end

* .

* ..

* ...

* stackage unpin unix

* ...

* fold create/observer/signatory into fake lfconversion primitives

* stackage unpin

* .....

* ......

* ........

* .........

* . . . . .

* unpin stackage on unix

* ...... ......

* ...

* . . . . .

* unpin stackage on unix

* . . . . . . . . .

* unpin stackage on unix

* Loosen restriction on ETo/FromAnyChoice fake primitives

* uncomment exercise in Interface.daml

* remove comments

* !!!

* the final re-pinning, part 1

* the final re-pinning: part 2
2021-10-20 17:45:13 +00:00
Robin Krom
3115d104aa
daml script interfaces (#11124)
* interfaces: introduce TemplateOrInterface class in stdlib

The template typeclass is to strong for many applications. The new
constraint `TemplateOrInterface` only contains the methods to convert
contract IDs and choices.

CHANGELOG_BEGIN
CHANGELOG_END

* ghc-lib update, interface script tests

* pinned stackage on unix

* added missing implementation in preprocessor

* added test

* fixing tests

* remove Iface type

* pinned stackage windows

* make sure createAndExercise is not called on interfaces
2021-10-11 18:22:40 +02:00
Robin Krom
9fd6326ae7
interfaces: consuming/non-consuming iface choices (#11009)
* interfaces: consuming/non-consuming iface choices

We add the consumption behaviour to the interface choice definition and
typecheck accordingly.

CHANGELOG_BEGIN
CHANGELOG_END

update to new ghc-lib, conversion implementation

* update ghc-lib

* pinning stackage on unix

* pin stackage on windows
2021-09-30 15:56:28 +00:00
Moritz Kiefer
4acf34b5fc
Add conversions from/to interfaces in Daml parser (#10954)
* Add conversions from/to interfaces in Daml parser

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-09-21 18:24:12 +00:00
Moritz Kiefer
cac8391d4c
Bump ghc-lib to include daml interfaces parser (#10747)
changelog_begin
changelog_end
2021-09-16 17:52:16 +00:00
Moritz Kiefer
e9c8af5024
Bump ghc-lib to include dropped parsing code for generic templates (#10735)
* Bump ghc-lib to include dropped parsing code for generic templates

changelog_begin
changelog_end

* bump snapshot

changelog_begin
changelog_end

* drop old generics file

changelog_begin
changelog_end

* drop other broken file

changelog_begin
changelog_end

* Bump again

changelog_begin
changelog_end

* bump to merged commit

changelog_begin
changelog_end

* and bump snapshots

changelog_begin
changelog_end
2021-09-01 15:35:40 +02:00
Robin Krom
36f3ba8a6a
lsp-types patch for platform independence (#10288)
* fix shake rebuild tests

* patch pretty printing in ghc

* pin linux deps

* pin windows deps

* cosmetics

* address review

* update ghc commit hash

* pin linux stackage deps

* update stack snapshot

* pin windows deps
2021-08-04 21:33:52 +02:00
Moritz Kiefer
fa80f1b615
Bump ghcide and upgrade to lsp/lsp-types (#10139)
* Bump ghcide and upgrade to lsp/lsp-types

changelog_begin
changelog_end

* Bump rev

changelog_begin
changelog_end
2021-06-30 12:16:12 +00:00
Moritz Kiefer
7855ea50c2
Switch to Ubuntu 20.04 nodes for ghc lib (#9838)
changelog_begin
changelog_end
2021-05-31 13:32:39 +02:00
Robin Krom
a336363020
ghc-lib: update (#9742)
* ghc-lib: update

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-25 15:52:39 +02:00
Robin Krom
84359ffa73
nested record updates (#9505)
* record dot updates: update to new ghc-lib-parser

This updates the ghc-lib-parser library featuring record dot updates and
adds tests for the new feature.

CHANGELOG_BEGIN
CHANGELOG_END

* update snapshot after pin on windows

* added a test for error locations

* nested record puns test

* update ghc commit

* update of stack dependencies (linux)

* update stack snapshot(windows)
2021-05-03 16:27:01 +02:00
Sofia Faro
f670daec6f
Add try-catch syntax. (#9203)
* Add try-catch syntax.

changelog_begin
changelog_end

* ++

* +++

* ++[>++<-]>

* ++[>++<-]>+

* ++[>+++<-]>

* ++[>+++<-]>+

* ++[>++++<-]>

* Use try-catch in ExceptionSyntax test

* add a syntax test for try catch

* +++[>+++<-]>

* +++[>+++<-]>+

* enable test4

* typo

* add a test with multiple patterns and guards

* final patch sha

* update stack snapshot (unix)

* update stack snapshot (win)
2021-03-25 13:36:09 +00:00
Sofia Faro
c26c349c8b
Generate exception instances from syntax. (#9140)
* Generate exception instances from syntax.

changelog_begin
changelog_end

* II

* III

* VII

* update ghc patch and add test

* VIII

* IX

* Remove DatatypeContexts

* X

* update stack snapshot

* don't need datatypecontexts warning anymore

* X-2

* XII

* XIII
2021-03-17 12:19:22 +00:00
Sofia Faro
e6ea8fa9b3
Start adding exception syntax support. (#8960)
* Start adding exception syntax support.

changelog_begin
changelog_end

* .

* ..

* . .

* ....

* .___.

* ..__..

* ._._._.

* update stack snapshot

* recompile ghc-lib

* update stackage

* add CmmParse patch

* incorporate CmmParse.y patch into ghc branch

* Add a first test for exception syntax desugaring.

* Add a test for multiple message declarations

* update ghc patch

* Update duplicate message test with location

* add brackets test

* Add final patch SHA

* update stack-snapshot and unpin for unix

* Update stackage pin on windows
2021-03-10 12:07:53 +00:00
Moritz Kiefer
f15a2a36b0
Bump DLint to include fix for disable comments (#8820)
changelog_begin

- [DLint] You can now disable dlint hints for a specific functions in
  the form `{- DLINT ignore functionName "hintName" -}`, e.g.,

```
{- DLINT ignore noHint "Use concatMap" -}
noHint f xs = concat (map f xs)
```

Note: The undocumented {- HLINT -} pragmas are no longer supported.

changelog_end
2021-02-12 11:13:44 +01:00
Moritz Kiefer
c89e00342d
Clean broken entries from the Bazel cache (#8668)
* Clean broken entries from the Bazel cache

This is hopefully a somewhat reasonable workaround for the "output not
created" errors that keep annoying us.

For now, this is just part of the hourly cronjob but we could move it
somewhere else if desired.

changelog_begin
changelog_end

* Fix GCS credentials

changelog_begin
changelog_end
2021-01-28 17:57:09 +00:00
Moritz Kiefer
e0c5abd647
Switch to GHC 8.10.3 (#8394)
* Switch to GHC 8.10.3

changelog_begin
changelog_end

* Update bazel-haskell-deps.bzl

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

* Comment on rules_haskell patch

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-01-25 11:53:53 +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
nickchapman-da
a7891a32b5
Avoid duplicating template let bindings (#8259)
* update ghc-lib patch hash

* update stack-snapshot.yaml

* update ghc-lib patch again

changelog_begin
changelog_end

* update stack-snapshot.yaml

* bazel run @stackage-unpinned//:pin (on linux)

* update ghc patch -- no singleton tuples!

* update stack-snapshot.yaml

* update stackage_snapshot.json

* expect error just once, not repeated 5 times

* remove 4x: --ghc-option -Werror

* ghc-lib patch

* stackage_snapshot.json

* stackage_snapshot.json (really, last commit was the yaml)

* Revert "remove 4x: --ghc-option -Werror"

This reverts commit 34b65fc7b1.

* ci/da-ghc-lib/compile.yml

* stack-snapshot.yaml

* stackage_snapshot.json

* stack pin on windows
2020-12-18 14:33:28 +00:00
nickchapman-da
0867605e1a
Don't loose signatures in template let binding (#8136)
* update ghc-lib patch

* update stack-snapshot.yaml

changelog_begin
changelog_end

* bazel run @stackage-unpinned//:pin (on linux) and update stackage_snapshot.json

* testcase to check type signatures in template-lets are not ignored

* update to ghc-lib commit hash following merge

* update snapshot

* update snapshot after pin on windows

* update stack pin on linux

Co-authored-by: Nick Chapman <nchapman@digitalasset.com>
2020-12-03 15:08:02 +00:00
nickchapman-da
6a745ed1fa
Support choice observers in 1.dev (#7922)
* Adapt to new desugaring for choice observers.

update hash of ghc patch.

changelog_begin
changelog_end

update ghc patch to final version

update stack-snapshot hashes for ghc-lib(-parser)

update stackage_snapshot.json, following `bazel run @stackage-unpinned//:pin`

expose Optional constructors for desugared code to use

adapt LFConversion to expect a 4-tuple for a desugared choice def/sig

update LFConversion for choice-observers

first example using new choice observer syntax.

fix scala type checker to have correct scoping rules for choice-observers

remove comment from example which says it is broken

improve variable names

improve tests for choice-observer clause

only test choice-observers SINCE 1.dev

add jq queries for choice observeres

make positive statement in jq test which checks choice obserers are present

test behaviour of choice observers

squash me

typo

* test more choice-observer divulgence

* Update documention for choice observers.

changelog_begin
Support choice observers in 1.dev
changelog_end

* fix docs build

* fix daml docs choice-observers example

* address comments: rewording text

* annotate choices observers as early-access in documention

* split out documentation code-snippets which require --target=1.dev

* final tweaks to documentation text
2020-11-18 19:51:15 +00:00
Sofia Faro
c5d145358d
Patch ghc to add a daml version header marker. (#7489)
* Update ghc to add a daml version header marker.

(WIP)

changelog_begin
changelog_end

* update stack snapshot

* See what happens with daml-doc

* update patch

* update stack snapshot

* unpin stackage

* Update daml docs tests

* Remove version header ann when parsing module doc

* Update the test

* Set final patch commit SHA.

* update stack snapshot

* unpin stackage (mac/linux)

* lint

* unpin stackage (win)
2020-09-28 17:01:20 +00:00
Moritz Kiefer
edd84a09d5
Fix reference to return produced by ApplicativeDo (#6821)
* Fix reference to return produced by ApplicativeDo

see https://github.com/digital-asset/ghc/pull/53 for details.

fixes #6820

changelog_begin
changelog_end

* bump to merged commit

changelog_begin
changelog_end

* switch to new ghc-lib

changelog_begin
changelog_end
2020-07-22 10:09:23 +00:00
Shayne Fletcher
4d896bc3bd
Update ghc-lib, da-ghc-master-8.8.1 (#6460)
changelog_begin
changelog_end
2020-06-23 08:29:16 -04:00
Shayne Fletcher
cec2693dc7
enable -Wunused-matches (#6423)
changelog_begin
changelog_end
2020-06-19 19:35:10 +00:00
Moritz Kiefer
a178f62613
Fix packaging performance (#6350)
fixes #3150

This PR introduces a patch to GHC to fix the performance of the
pattern match checker in the presence of multiple packages which
is currently significantly (orders of magnitude) slower than having
everything in a single package. I also added a test case that hits
this. Here’s what you need to hit this issue:

1. A typeclass with a functional dependency. `HasField` is the obvious
   candidate for this.

2. A lot of instances of this typeclass in a separate package (this is
   the only part where the separate package matters).

3. A reasonably large ADT with a bunch of strict fields.

4. A pattern match in the context of some constraints of the
   typeclass. The constraints can be completely unused.

In that case, you will get a significant slowdown in the number of
instances, number of constructors and number of constraints (didn’t
verify if it’s linear but it is significant which is all that
matters).

Here’s why this happens:

1. The pattern match checker checks for strict fields if the type is
   inhabited.

2. This calls `pmTopNormaliseType_maybe` to normalize a type (the details don’t
   matter) which in turn calls into the typechecker. This function is
   called very often (presumably linear in the number of constructors
   but didn’t verify.)

3. The typechecker has some logic in `improveFromInstEnv` for
   generating additional equations by unifying functional
   dependencies `a -> b` with constraints in scope
   and thereby deducing information about `b`.

4. In the pattern match checker the list of instances of the home
   package is empty since the pattern match checker (apparently)
   doesn’t actually care about those extra equations. However, the
   list of instances in the EPS is not empty. This is the issue here:
   By moving it to an external package we suddenly end up with
   thousands of instances that we try to unify with the functional
   dependencies every time we normalize which happens very often.

Proposed fix:

The solution is rather simple: Since the pattern match checker
apparently does not care about the instances of the home package, it
almost certainly doesn’t care about instances in general so we just
empty the instances of external packages explicitly.

Is the fix correct?

1. I verified that the GHC test suite passes with this patch which
   gives me a reasonable level of confidence.

2. I verified that our own test suite passes.

3. The most dodgy part is actually emptying the instance since the
   whole EPS stuff is a mutable mess. What could in theory happen is that
   the PM ends up loading an interface file that mutates this
   again. However, afaiu it is impossible for the PM to need an
   interface that the typechecker didnt already need. I did do a bunch
   of debugging and this is exactly what I observed in my experiments.

Alternative ideas and upstreaming:

The other option would be to not try and mess with the EPS but somehow
have a conditional flag somewhere in the typechecker env to disable
this logic in the pattern match checker. However, that sounds
significantly more complex so I don’t think it’s worth the effort.

GHC 8.10 has a new pattern match checker that has different
performance characteristics and seems to do much better here so there
is little reason to try and upstream this. I strongly want to avoid
upgrading DAML to 8.10 at this point (too much risk, let’s wait until
things calm down)

changelog_begin

- [DAML Compiler] Fix an issue where compilation slowed down
  significantly when code was split up into several packages. See
  https://github.com/digital-asset/daml/issues/3150

changelog_end
2020-06-16 15:12:34 +02:00
Gary Verhaegen
2fe320fe48
automated ghc-lib build (#6188)
automated ghc-lib build

This PR aims at automating the build of ghc-lib. The current process
still has a few manual steps; it needs to be updated because Bintray is
going away, so this seemed like a good opportunity to fully automate it.

This works like the "patch bazel on Windows" jobs: the filename will
contain a hash of the `ci/da-ghc-lib` folder, and the job will run only
if the corresponding filename does not yet exist on the GCS bucket. PRs
aiming at changing the ghc-lib version will need to run twice: once to
create the artifacts, and once to change the `stack-snapshot.yaml` file
to match.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-04 12:05:03 +02:00
Gert-Jan Bottu
2af134ca69
WIP: Draft version constraint generation (#5472)
First version of static verification tool.

The current state of the tool: 
- Reads DAR files.
- Partially evaluates the code.
- Generates constraints for the field and choice to be verified.
- Passes the constraints to an SMT solver.
- Some basic tests.
2020-05-20 08:08:18 +02:00
Moritz Kiefer
db37e4c497
Patch zip library to not use temp files (#5621)
This should hopefully fix the issues we have been seeing on CI. While
I’m not super keen on including non-upstreamable patches it seems
better than having CI be flaky.

changelog_begin
changelog_end
2020-04-20 08:35:11 +00:00
Gary Verhaegen
1872c668a5
replace DAML Authors with DA in copyright headers (#5228)
Change requested by Manoj.

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 01:26:10 +01:00
Moritz Kiefer
aa48f3026e
Bump ghcide (#5128)
This PR bumps ghcide, haskell-lsp and haskell-lsp-types. There aren’t
really any important changes in ghcide itself but the haskell-lsp
update includes my fix for crashing completions.

One change in ghcide itself is that NormalizedFilePath got moved to
haskell-lsp. ghcide needs special treatment for empty file paths so we
use `toNormalizedFilePath'` from ghcide instead of
`toNormalizedFilePath` from `haskell-lsp`. I’ve added an hlint rule to
enforce this.

changelog_begin
changelog_end
2020-03-23 12:09:36 +00:00
Shayne Fletcher
2525a4610a
Update hlint (#5123)
changelog_begin
changelog_end
2020-03-22 16:30:11 +00:00
Moritz Kiefer
d36bb65df2
Bump zip library (#4768)
This should hopefully fix the failure to delete the temporary zip file
on Windows. See https://github.com/mrkkrp/zip/pull/61

changelog_begin
changelog_end
2020-03-02 12:26:28 +01:00
Shayne Fletcher
8c36b68a3d
Upgrade to ghc-lib-8.8.1.20200225 (#4692)
- Prelude `daml 1.2` is now optional;
- `HsDumpAst` now comes from `ghc-lib-parser`.

changelog_begin
changelog_end
2020-02-25 14:57:17 -05:00
Shayne Fletcher
a49bc83502
Update hlint (#4577)
changelog_begin
changelog_end
2020-02-18 16:54:16 +00:00
Gary Verhaegen
47bd131f15
add copyright headers to yml files (#4407)
We seem to have forgotten about them in the copyright scripts.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-06 12:54:07 +01:00
Moritz Kiefer
959da4cdbb
Upgrade to haskell-lsp 0.20 (#4397)
* Upgrade to haskell-lsp 0.20

This includes another ghcide bump but the only change there is the
haskell-lsp ugprade. haskell-lsp 0.20 includes some performance
improvements.

changelog_begin
changelog_end

* Bump parser-combinators
2020-02-05 11:27:44 +01:00
Moritz Kiefer
52d4f60aec
Switch to ghcide 0.1.0 (#4381)
* Switch to ghcide 0.1.0

changelog_begin
changelog_end

* Bump hie-bios
2020-02-04 18:40:43 +01:00
Shayne Fletcher
5c1f032c71
Update hlint (#4350)
changelog_begin
changelog_end
2020-02-03 10:34:56 -05:00
Shayne Fletcher
a48b7b039f
Update hlint (#4276)
* Update hlint

changelog_begin
changelog_end

* Update hlint

changelog_begin
changelog_end
2020-01-30 00:06:18 +00:00
Shayne Fletcher
e9d67ba9f6
Disambiguate consuming vs pre-consuming choices (#4164)
changelog_begin
- [DAML Compiler] Choices marked explicitly as `preconsuming` are now equivalent to a non-consuming choice that calles `archive self` at the beginning.
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-22 14:24:00 -05:00
Shayne Fletcher
674eaffc70
Depend on ghc-lib-parser-ex (for hlint) (#4109)
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-22 06:25:51 -05:00
Shayne Fletcher
1359d97702 Update hlint (#4080)
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-16 22:01:30 +00:00
Shayne Fletcher
29d88bb39b Update hlint (#4054)
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-15 19:45:04 +00:00
associahedron
5d3040835a LF conversion of templates under new rules (WIP). (#4030)
* Patterns and test for new desugaring

* working on new template conversion

* Update ghc-lib

changelog_begin
changelog_end

* shut up hlint

* Update desugar stdlib

* update test

* remove unuseful templatebinds

* Add implicit qualified GHC.Types import

* Add missing primitives

* Remove chaff

* update comments

* Remove patterns that dont seem useful anymore

* Capture key data in template binds

* Dont make TypeRep/ToAny/FromAny classes conditional

* Remove some unnecessary TODOs

* Generate the template definition

* Remove new template desugaring test

* Fix jq query

* Rename makeDesugarDFunProjection to useSingleMethodDict

* Let TTypeRep and TAny be TUnit in primitives.

* Fix damlc visual wrt the new desugaring

* Fix visualization tests in shake test suite

* Fix damldocs

* Drop envTemplateKeyData

* Use the new ghc-lib release

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-01-15 18:03:15 +01:00