Commit Graph

193 Commits

Author SHA1 Message Date
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
Moritz Kiefer
6016633bb7
Construct ParsedModule directly in Daml Repl (#10701)
This is a relatively large change unfortunately which unfortunately
requires reimplementing parts of the logic of the typechecker & core
compilation. I don’t think it is too bad but we might want to think
over time if we can factor this better.

This fixes #10073 and fixes #10664 by referencing the exact types
instead of going via the renamer.

There are some minor changes around error messages for "module not
found" errors. This is because these are now caught in the
typechecker instead of in our own code. We could keep the errors but
it requires duplicating even more logic and I don’t really see what it
buys us so I think I prefer the approach here.

changelog_begin

- [Daml Repl] Fix a bug where bindings with out of scope types would result in error in following lines.

changelog_end
2021-08-30 17:28:16 +02:00
Moritz Kiefer
055be4b3cb
Disable deprecation warnings for data-dependencies (#10647)
Makes no sense to warn about this at this point since you cannot do
anything about this once that fails.

changelog_begin
changelog_end
2021-08-23 16:39:57 +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
d4150ac078
Refactor error reporting in Daml Repl (#10118)
* Refactor error reporting in Daml Repl

fixes #10098

As mentioned in that issue, the current behavior is a mess which
silently drops errors in certain cases. This PR switches things around
so that errors are reported to the client and we print them there
making sure that no error should ever get lost.

changelog_begin
changelog_end

* Bump timeout

changelog_begin
changelog_end
2021-06-25 14:08:44 +00:00
Sofia Faro
2f5186938e
Allow constraints in any position in data-deps. (#10049)
This fixes #8411. It turns out the issue was some missing parentheses.

changelog_begin
changelog_end
2021-06-17 15:45:10 +01:00
Sofia Faro
f355931a59
Fix typeclass detection in data-dependencies (#9830)
* Fix typeclass detection in data-dependencies

Fixes #9689 which was actually caused by misinterpreting a constraint
synonym as an empty typeclass.

This PR fixes and deduplicates the logic for detecting typeclass
definitions in data-dependencies. It also tries to avoid lifting
constraint tuples unnecessarily (since constraint synonym
definitions are already lifted). And for any constraint tuples
that are lifted, it picks a more unique name.

The PR adds a regression test, and a test for nested constraint tuples.

changelog_begin
changelog_end

* Preserve nice comment.
2021-05-28 12:25:46 +01:00
Sofia Faro
b19c8f2a7c
Drop sanitize, add MagicHash in data-dependencies. (#9698)
The only thing `sanitize` does is mangle the names of identifiers and
types that end in `#`. That can't be a good thing. This PR removes
sanitize and enables MagicHash in data-dependencies, meaning names can
end in `#` without causing issues. (MagicHash also enables unboxed
literals, but that doesn't matter here.)

In practice, sanitize was only affecting `GHC.Prim.Void#`, which we
define because GHC sometimes references it. AFAIK there's no other
use of `#` in the standard library that we don't rewrite away.

changelog_begin
changelog_end
2021-05-17 10:10:00 +00:00
Sofia Faro
6568336588
Lift constraint tuples up to a type synonym in data-dependencies. (#9687)
* Lift constraint tuples up to a type synonym in data-dependencies.

Fixes #9663 and adds a regression test.

GHC was crushing the constraint tuples into regular constraints, so the function caller no longer matched the original LF API. By lifting the constraint tuple into a type synonym, we eliminate this effect.

Part of the issue here is that we're losing the original constraint tuple type synonym during LFConversion. I'll open a separate issue for that, since I think it's also worth fixing that going forward.

(Preserving the type synonym would solve this issue for newly compiled packages. By contrast, the fix in this PR works for both new and old packages.)

changelog_begin

- [Daml Compiler] Fixed a data-dependencies bug where functions in a data-dependency that used a constraint tuple constraint (e.g. `Template t`) could not be directly invoked.

changelog_end

* use foldl'

* Fix exception test that spawned this mess
2021-05-14 14:22:47 +01: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
e84a94e8c1
Update issue number for BigNumeric Divisible instance. (#9334)
changelog_begin
changelog_end
2021-04-06 16:37:16 +00: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
Robin Krom
7669d8c88c
daml pkg: split installation of deps and package db inititialization (#9056)
* daml pkg: split installation of deps and package db inititialization

This is the next step for the daml package manager program #8976.
This splits the installation of dependencies from the initialization of
the (ghc) package database.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-12 22:55:11 +01:00
Sofia Faro
34fe42237d
data-deps: Dont let defaults leak constraints. (#8833)
* data-deps: Dont let defaults leak constraints.

Fixes #8802

changelog_begin
changelog_end

* use expandSynApp instead of expandTypeSynonyms

* revert isConstraint change

* fix indentation
2021-02-12 15:44:29 +00:00
Robin Krom
e79966b890
ghcide: cached goto definitions (#8751)
We update ghcide, which enables cached goto definitions that keep
working when the document doesn't compile anymore. This also adds a test
to lsp-tests for this feature.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-04 21:05:12 +01: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
Moritz Kiefer
5f1d5ad118
Fix prettyprinting in DAML REPL (#8214)
We used a weird mix of prettyprinting and string concatenation. This
breaks as soon as you have a line break somewhere because indentation
is messed up at that point. This PR fixes that by consistently (at
least more consistently than before) using the prettyprinting lib.

fixes #8213

changelog_begin

- [DAML REPL] Fix a bug where bindings with very long types sometimes
  resulted in parse errors on following lines. See #8213

changelog_end
2020-12-09 15:24:43 +01:00
Sofia Faro
6499ee9716
Add exceptions in DAML-LF AST (Haskell side) (#8112)
* Add exceptions in DAML-LF AST (Haskell side)

Updates the Haskell DAML-LF AST for exceptions, including
encode/decode, and updates all the functions that deal with the
AST directly.

changelog_begin
changelog_end

* Missed some TODOs in DecodeV1
2020-11-30 16:18:29 +00:00
Sofia Faro
e75d42ddc3
Represent overlap modes at the type level. (#7864)
On request by @hurryabit, this PR changes the representation of
overlap modes by moving it to the type-level. Since the value-level
encoding never made it into a stable release, this isn't a breaking
change. Also, the data-dependency and roundtrip tests are unchanged,
only the daml-test-files overlap mode test had to be updated.

changelog_begin
changelog_end
2020-11-03 12:40:36 +00:00
Sofia Faro
3f64a6ae8d
Add MINIMAL pragma support in data-deps. (#7815)
* Add MINIMAL pragma support in data-deps.

CHANGELOG_BEGIN

- [DAML Compiler] MINIMAL pragmas are now imported correctly
  in data-dependencies.

CHANGELOG_END

* fix test

* Review comments

* Update compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion.hs

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-10-28 10:37:23 +00:00
Sofia Faro
201a6e8c1b
Refactor fun dep and overlap mode implementations. (#7810)
* Refactor fun dep and overlap mode implementations.

This PR moves the functional dependency and overlap
mode encoding/decoding functions to a single module,
separate from the rest of LF conversion or
data-dependencies, in preparation of adding more
annotations of this sort (e.g. MINIMAL).

This involves a small amount of refactoring to get
the types to line up... It should be a little easer
to write some roundtrip tests for these now.

I'm not super satisfied with how much fun dep / overlap
mode logic is still left in LFConversion.hs and
DataDependencies.hs, but this is a step in the right
direction at least.

changelog_begin
changelog_end

* Rename Encoding to MetadatEncoding
2020-10-26 15:59:39 +00:00
Robin Krom
cf85751c3c
daml assistant: cleanup of daml ledger commands (#7777)
* daml assistant: cleanup of daml ledger commands

This is a cleanup of the Helper/Ledger.hs module in preparation for
further implementations of `daml ledger` commands against the JSON API.
In particular the module Compiler/Fetch.hs is removed from daml-compiler
and its contents moved over the Helper/Ledger.hs. Some renaming and
reorganization is done for clarity.

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-22 17:07:43 +02:00
Sofia Faro
b925c483d2
Add overlapping instances support in data-deps. (#7770)
Also adds a small test.

changelog_begin

- [DAML Compiler] Similar to functional dependencies, the
  compiler now adds overlapping instance pragmas into the
  DALF/DAR files. This way, overlapping instances pragmas
  will be preserved when importing typeclass instances
  via data-dependencies.

changelog_end
2020-10-21 15:07:10 +01:00
Sofia Faro
8e4e0f98c5
Functional dependency support in data-dependencies (#7719)
* Functional dependency support in data-dependencies

(WIP)

* Add test.

changelog_begin

- [DAML Compiler] Functional dependencies are now saved
  by the DAML compiler in the DALF file / DAR package. When
  importing a file with the functional dependency data via
  data-dependencies, these will be picked up automatically.

changelog_end
2020-10-19 16:50:45 +01:00
Sofia Faro
bda44fb084
Add default method support in data-dependencies. (#7645)
This PR adds default method support in data-dependencies,
including default method signatures (the DefaultSignatures
extension). This adds tests for simple default methods,
and for default methods with signatures.

changelog_begin

- [DAML Compiler] `data-dependencies` now support default
  methods in typeclasses, including default method
  type signatures.

changelog_end
2020-10-12 13:49:54 +01:00
Moritz Kiefer
1780f4cd93
Fix qualified name handling in DAML REPL (#7544)
* Fix qualified name handling in DAML REPL

This fixes the issue reported in
https://discuss.daml.com/t/how-to-use-qualified-template-names-in-repl-queries/1329/7

We need to print names qualified otherwise, the type signature for
following lines will be ambiguous even if users qualified the name in
their input. Figuring out the right name to use in qualification is
tricky but Luckily GHC provides this already so we just have to make
sure to plug it into the right places.

changelog_begin

- [DAML REPL] Fix a bug where you got an error about a name being
  ambiguous even if you used a qualified name.

changelog_end

* Update compiler/damlc/daml-compiler/src/DA/Daml/Compiler/Repl.hs

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

* Factor out typechecking of imports

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-10-02 12:16:17 +00:00
Sofia Faro
0382a62965
Fix data-deps dictionary function name mismatches. (#7539)
* Fix data-deps dictionary function name mismatches.

Fixes #7362. Incredibly, it's possible to fix this issue in
data-dependencies by sorting instance names in a funny way.
This is definitely a hack, but it should fix this issue,
which affects overlapping instances as well.

This PR adds a regression test.

changelog_begin
changelog_end

* Fix comments

* apply suggestion
2020-10-01 12:11:10 +00:00
Moritz Kiefer
293e5c55fa
Split DecodeDar into a separate module (#7530)
I originally implemented this for another change where I didn’t need it
in the end. However, it seems like a nice cleanup so spinning it out
into a standalone PR.

changelog_begin
changelog_end
2020-09-30 15:44:22 +02:00
Moritz Kiefer
0903b1a6be
Filter implicit parameter instances from data-dependencies (#7320)
* Filter implicit parameter instances from data-dependencies

Occasionally GHC likes to float implicit parameters to the top-level
making them look like any other typeclass instances. Implicit
parameters are by design not unique so if we try to reconstruct them
we get an error about a duplicate instance.

I haven’t figured out when exactly GHC floats things to the top-level
but I did verify that this testcase breaks without the fix.

changelog_begin
changelog_end

* Assert that there are 2 implicit instances

changelog_begin
changelog_end
2020-09-04 07:36:37 +00:00
Sofia Faro
a938fd7773
Preserve empty variant constructor in data-deps. (#7303)
* Preserve empty variant constructor in data-deps.

This fixes #7207 and adds a regression test. In a
separate PR I'll add a warning for variants with
single argument of unit type and add a changelog
entry.

changelog_begin
changelog_end

* Add special case for single constructor variants

* Add test for special case
2020-09-02 21:16:16 +01:00
Sofia Faro
4c7b07fec6
Add missing orphan superclass references when generating instances via data-dependencies. (#7267)
* Add test for issue 7256

* Fix the issue of missing references

changelog_begin
changelog_end
2020-08-31 11:57:56 +01:00
Andreas Herrmann
037cf11710
Add :json command to DAML REPL (#7202)
* REPL test `:json` command

changelog_begin
changelog_end

* Implement :json command in DAML REPL

changelog_begin
- [DAML REPL] You can now convert DAML expressions to JSON in the DAML
  REPL using the meta-command ``:json`` for example ``:json [1, 2, 3]``.
changelog_end

* Extend DAML REPL documentation

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-08-21 14:53:06 +00:00
Sofia Faro
944ccf9fc5
Expose type synonyms in data-dependencies. (#6894)
* Expose type synonyms in data-dependencies.

This PR converts (non-unit) type synonyms during LF conversion, and then
exposes them via data-dependencies. This is possible only when using an
LF version that supports type synonyms (LF version >= 1.7), the
type synonym isn't of unit type (because it clashes with empty
typeclasses, and the (fully applied) type synonym has kind *
(e.g. you can't define a * -> * synonym in LF).

This fixes issue #6306

changelog_begin

- [DAML Compiler] The DAML compiler will now compile type synonyms
  (``type X = Y``) into the DAR, whenever possible, and will expose
  these synonyms via data-dependencies.

changelog_end

* Add more tests

* Fix formatting
2020-07-28 15:11:17 +01:00
Andreas Herrmann
5481a080d7
DAML REPL :show imports (#6885)
* DAML REPL :show imports

changelog_begin
- [DAML REPL] You can now list the currently imported modules using
  the REPL command ``:show imports``.
changelog_end

* Accept \r\n on Windows.

* REPL functests use text mode file for stdin/out

So that `\r\n` will be mapped to `\n` automatically on Windows.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-28 10:51:48 +02:00
Andreas Herrmann
1076b165e6
Avoid redundant DAML REPL imports (#6872)
* Deduplicate REPL imports and store in map

changelog_begin
changelog_end

* DAML REPL subsumed imports functest

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-27 14:03:59 +00:00
Andreas Herrmann
e0b9a535b3
DAML REPL :module command (#6865)
* DAML REPL help and module commands

changelog_begin
- [DAML REPL] You can now type ``:help`` at the REPL prompt to see a
  list of possible REPL commands.
- [DAML REPL] You can now add and remove module imports using
  ``:module [+-] Some.Module``.
changelog_end

* REPL :module functests

* Improve module not imported error message

* DAML REPL document REPL commands

* Update docs/source/daml-repl/index.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-07-27 11:22:29 +00:00
Moritz Kiefer
15bf131fed
Enable assertions in Haskell builds (#6853)
GHC hates its users and defaults to optimizing out assertions. We
fixed that in Buck at some point but clearly that got lost when
migrating to Bazel.

Turns out enabling assertions catches bugs. This insight was brought to
you from the people that also brought you “Turns out writing tests
catches bugs”.

fixes #5624

changelog_begin
changelog_end
2020-07-24 14:29:25 +00:00
Moritz Kiefer
aac32983b7
Support let-bindings in DAML REPL (#6843)
This PR extends DAML REPL to also support `let` bindings which plays
well with the improved support for pure expressions. We support both
pattern bindings and function bindings.

changelog_begin

- [DAML REPL] DAML REPL can now run without a ledger. Take a look at
  the documentation for details.

- [DAML REPL] DAML REPL now supports ``let`` bindings to bind pure
  expressions. Take a look at the documentation for details.

changelog_end
2020-07-23 12:39:51 +00:00
Moritz Kiefer
6bf1eb19ae
Print results in DAML REPL and support pure expressions (#6799)
* Print results in DAML REPL and support pure expressions

This extends DAML REPL to behave similar to GHCi in that it prints
results if the result is an instance of `Show` and it also supports
pure, non-script expressions now. We copy the same hack from GHCi and
typecheck multiple times. This doesn’t seem to have any noticeable
performance impact (which makes sense, the expressions are tiny and
the overhead of grpc is much much bigger).

Docs and tests are updated.

fixes #6780

changelog_begin
changelog_end

* windows is garbage

* but I fixed it \o/

* Rename getReplLogger to newReplLogger

changelog_begin
changelog_end
2020-07-21 09:01:18 +00:00
Moritz Kiefer
b12a19181e
Add a --timeout option to daml ledger commands (#6774)
* Add a --timeout option to `daml ledger` commands

At least in the compatibility tests, we see timeouts fairly regularly
in the tests for fetch-dar. If we see those timeouts in the tests, I
see no reason why our users should never see that especially on
actually distributed ledgers and hardcoded timeouts are a bad idea
anyway so now they are configurable.

I’ve also changed the timeout for the fetch tests (those are the only
once I’ve seen timeout) to 120s.

changelog_begin

- [DAML Assistant] The `daml ledger` commands now accept a `--timeout`
  option which can be used to change the timeout for API requests from
  the default of 30s.

changelog_end

* Generate parties as uuids to avoid collisions

changelog_begin
changelog_end

* Match on Deadline Exceeded as well

changelog_begin
changelog_end

* Update compatibility/bazel_tools/test_utils/DA/Test/Util.hs

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>

* Update daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>

* Add some docs

changelog_begin
changelog_end

* Better version checks

changelog_begin
changelog_end

* fix imports

changelog_begin
changelog_end

* This is not how you exception

changelog_begin
changelog_end

* Update daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
2020-07-17 16:35:55 +02:00
Andreas Herrmann
4be01e4df6
Update ghcide 0.1.0 --> 0.2.0 (#6745)
* Update rules_haskell hie-bios support

* Decouple Haskell ghcide and DAML ghcide

Creates a separate `stack_snapshot` to pull in `ghcide` for the Haskell
IDE use case independent of the `ghcide` for DAML. This allows to update
these two `ghcide` instances independently. As DAML uses `ghcide` the
library updates can be involved if the API experienced breaking changes.
At the same time we may wish to update `ghcide` for Haskell earlier to
make use of new features and stay compatible with rules_haskell's ghcide
support.

* Fix Haddock warnings reported by ghcide

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-16 16:30:09 +00:00
Andreas Herrmann
ae65f93e01
DAML REPL - Explicit package imports (#6707)
* DAML REPL - Explicit package imports

changelog_begin
- [DAML REPL] The REPL no longer imports all modules from the main DALFs
  of all specified DARs automatically at start-up. Instead, the REPL
  will only import modules from packages specified on the command-line
  using the `--import` flag.
changelog_end

* Accept package-name or package-id

* REPL test case for --import flag

* DAML REPL use `UnitId` for import packages

Addressing review comment
https://github.com/digital-asset/daml/pull/6707#discussion_r453731353

* DAML REPL Parse package-name/id at CLI

* DAML REPL Simplify unversioned pkgs

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-14 11:38:23 +00:00
Andreas Herrmann
73c6fdffb8
Load multiple DARs into DAML REPL (#6656)
* REPL: Factor out Dar loading

* REPL accept multiple DARs

* REPL CLI take multiple packages

CHANGELOG_BEGIN
- [DAML REPL] The REPL now supports loading multiple DARs specified at
  the command line. The DARs are loaded as data-dependencies, and the
  modules of each DAR's main DALF will be imported into the REPL session
  at startup.
CHANGELOG_END

* REPL test loading multiple DARs

* REPL Load packages from current session

* REPL func-test test symbols from two DARs

* Update compiler/damlc/daml-compiler/src/DA/Daml/Compiler/Repl.hs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-07-09 10:47:21 +00:00
Moritz Kiefer
8390dff7f9
Only force the result of GeneratePackageMap to whnf (#6213)
This rule is repeated for every file. While we cache the computation,
we still forced it to NF which is super slow. On my (realworld)
testcase, this is a speedup of > 1.7x, cuts allocations to 1/3 and max
residency also goes down to 1/3.

changelog_begin
changelog_end
2020-06-03 16:12:39 +00:00
Andreas Herrmann
2666c73c73
Handle record dot syntax in DAML REPL (#6028)
* REPL record dot syntax regression test

* REPL: Apply record preprocessor to expressions

CHANGELOG_BEGIN
- [DAML REPL] Record dot syntax is now handled in expressions entered
  into the REPL.
CHANGELOG_END

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-05-19 13:59:35 +00:00
Sofia Faro
1bd117bcec
Inline typeclass projections. (#5759)
* Inline typeclasses and apply projections.

This draft PR:

* adds a Subst module for substitution within LF expressions.
  This implementation piggybacks on the existing type
  substition. But there are not enough tests yet.
* passes World data into the simplifier, in order to have
  have the ability to inline functions (selectively)
* inlines typeclass dictionaries and projection functions
* beta reduces type lambdas (which are just ignored by
  speedy afaik)
* beta reduces lambdas that are passed units or dictionaries
* runs the simplifier twice so it has a change to
  perform the inlining, reduction, AND projection
  -- this is probably avoidable by sequencing the
  simplifier steps in a specific order, but running
  the simplifier twice is simple enough for now.
* together, these fix #5748 (see result on a toy module)

TODO:

* add lots of tests for Subst
* run this on a benchmark to see how big of a difference it makes.
* reduce the jankiness of running the simplifier twice.

Results:

DAML input:

```
module Main where

hello : Int
hello = 10 + 30
```

Original DAML-LF output:

```
module Main where
    @location(7:0-7:5)
    def hello : Int64 =
      a284919a95c4a515cd1efac0d89be302d0e9d61e692a2176128c871ad8067e36:GHC.Num:+
        @Int64
        a284919a95c4a515cd1efac0d89be302d0e9d61e692a2176128c871ad8067e36:GHC.Num:$fAdditiveInt
        10
        30
```

Current DAML-LF output:

```
 module Main where
    @location(7:0-7:5)
    def hello : Int64 = ADD_INT64 10 30
```

changelog_begin
changelog_end

* Update copyright header

* Lint

* More direct typeclass simplification

* extendWorldSelf + getTypeClassDictionary

* Fix visual

* Fix visual comment

* Disable cross-module inlining for incremental builds

* Cleanup subst/freevars.

* copyright header

* Alpha equivalence for LF expressions.

* copyright header

* lots of tests

* fix comment

* Apply review suggestions
2020-05-11 16:48:27 +00:00
Moritz Kiefer
b8db6b23b6
Track main unit ids in createProjectPackageDb (#5598)
This is another refactoring PR for createProjectPackageDb. There are
no actual changes but the `DependencyInfo` now includes the list of
main unit ids. This is not used in this PR but the plan is to start
emitting a file here containing those and then we only have to parse
that file instead of reading all DARs again just to figure out the
--package flags. (The reason why it needs to be written to a file
instead of simply returned is that this needs to work even with
--init-package-db=no which is going to become more important for
incremental package db initialization).

changelog_begin
changelog_end
2020-04-17 14:47:06 +02:00
Moritz Kiefer
69ac459723
Add a suggestion when warning about unexposed modules (#5581)
This has come up today where someone didn’t realize that removing the
field is sufficient to fix the warning.

I’ve also taken this as an opportunity to move the code out to a
helper function.

changelog_begin
changelog_end
2020-04-16 15:29:13 +02:00