Commit Graph

872 Commits

Author SHA1 Message Date
Remy
c76e0bc1e0
DAML-LF add support for generic comparison in archive (#4983)
* DAML-LF: add generic comparison to archive
2020-03-13 20:13:13 +01:00
Andreas Herrmann
559c78003e
Update rules_haskell (#4751)
* Update rules_haskell

The workaround for linking against `Cffi` in the REPL has been
upstreamed in a more generalized form.

CHANGELOG_BEGIN
CHANGELOG_END

* ghcide: Use rules_haskell's hie-bios support

* Document `ghcide` Bazel integration

* Rename files to match module names

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-03-13 16:49:34 +01:00
Moritz Kiefer
a15bfd80f3
Fix lf versions in the tests for buliding against newer LF versions (#4933)
This makes sure that they won’t break once we switch defaults. For
consistency they are specified via `build-options` everywhere.

changelog_begin
changelog_end
2020-03-13 16:27:54 +01:00
Moritz Kiefer
4e99f18613
Introduce a DA.Test.Sandbox module for managing sandbox in tasty (#4986)
We previously had 3 slightly different but consistently shitty logic
for handling this in the tests for daml-helper daml repl and the
Haskell ledger bindings. This PR introduces a module that is flexible
enough to capture all their needs and hopefully is somewhat less
shitty.

changelog_begin
changelog_end
2020-03-13 15:35:03 +01:00
Remy
277883e4d5
DAML-LF: base GenMap on SortedMap (#4893)
Change underlying implementation of GenMap from insertion order Map to sorted Map

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-13 11:10:38 +01:00
Moritz Kiefer
58c101c3ab
Mark lsp tests as flaky on Windows (#4906)
:sadpanda:

changelog_begin
changelog_end
2020-03-09 16:53:36 +01:00
Moritz Kiefer
7b1f193012
Error out on dependencies on newer LF versions (#4901)
This doesn’t really make sense since the main point of targetting an older
LF version is because your server does not support the newer LF
version but including dependencies in newer LF versions makes that
completely useless. In the current state, this also produces a bunch
of errors that look very confusing and while we might be able to fix
them, I don’t think it’s worth doing.

changelog_begin
changelog_end

fixes #4596
2020-03-09 14:59:34 +00:00
associahedron
e67fef1d27
Add extra test on record constructor check. (#4898)
Based on @hurryabit's comments from last PR.

changelog_begin
changelog_end
2020-03-09 14:31:47 +00:00
associahedron
943832bc16
Add a warning for data X = Y {...}. (#4892)
* Add a warning for data X = Y {..}.

Part of #4718.

changelog_begin

- [DAML Compiler] The DAML compiler now emits a warning when you declare a single-constructor record type where the constructor name does not match the type name, such as ``data X = Y {...}``. This kind of type declaration can cause problems with cross-SDK upgrades because the record constructor name cannot be recorded in the DAML-LF representation. In the future, this warning will be upgraded to an error.

changelog_end

* s/Ctor/Constructor/g
2020-03-09 11:28:16 +00:00
associahedron
02ae2a29d9
data-dependencies: Call buildHiddenRefMap once per package. (#4881)
* Call buildHiddenRefMap once per pkg.

Instead of calling it once per module.

changelog_begin
changelog_end

* Remove special cases
2020-03-06 16:17:57 +00:00
Gary Verhaegen
2eedd291ec
bind repl to localhost (#4863)
Currently the repl server is bound to 0.0.0.0, which is not great for
security and makes running the tests a bit disruptive on macOS.

This binds it to 127.0.0.1 instead.

CHANGELOG_BEGIN
- [DAML Repl - Experimental] The REPL server will now bind to 127.0.0.1
  instead of 0.0.0.0.
CHANGELOG_END
2020-03-06 11:40:55 +01:00
mergify[bot]
1007fd58e6
Track erased types in data-dependencies. (#4833)
* Track erased types in data-dependencies.

This PR introduces a tracker for Erased types, DA.Generics, and any type, typeclass, or typeclass instance that dependens on them transitively. This is designed to detect and cut out any such definition that will cause problems.

Apologies for the large PR. Originally this was just a small extension to the tracking of old-style typeclasses, but each bugfix uncovered a new bug, and the only way to get it to completely work was to do it all at once. That's why the tracker is so extensive -- the only thing it doesn't track is regular functions, because they will never introduce a cyclic reference to an erased type that gets exposed in the type system (until we implement dependent DAML).

Right now the tracker runs once per data-dependency module, but in a future PR I will make it run once per data-dependency package to reduce the repetitive. This was all tested on a very large DAR, and it runs fine, but it should be much faster once it runs once per package.

changelog_begin
changelog_end

* lint

* Address comments

* Add a great test case
2020-03-05 17:54:55 +00:00
mergify[bot]
60013a1535
Remove DA.Upgrade module (#4839)
Given that Generic instances are not supported cross-SDK this module
only causes confusion and I’d rather remove it.

changelog_begin
changelog_end
2020-03-05 16:30:54 +00:00
Gary Verhaegen
75c7d48d5b
bind localhost for json-api and scenarios (#4576)
Both were previously binding 0.0.0.0, which is inherently insecure. More
importantly to me, that meant running `bazel test //...` essentially
rendered my computer unusable for however long it took (which is
_long_), as it kept popping up focus-stealing dialogs about whether or
not I wanted to trust "java" to open an incoming network connection.

The ScenarioService does not seem to have an existing setup for CLI args
and my Scala-fu is not good enough to add one, so I just changed the
hard-coded path.

The JSON API already had an option, just with the wrong default. This is
technically a breaking change, but I'm hoping to pass it under the
"experimental" flag we still have on the JSON API.

CHANGELOG_BEGIN
- [JSON API - Experimental] As a security improvement, the JSON API
server will now bind on ``127.0.0.1`` by default. Previous behaviour was
to bind on ``0.0.0.0``; you can get that behaviour back by passing in
the (existing) flag ``--address 0.0.0.0``.

- [DAML SDK] The Scenario Service will now bind on ``127.0.0.1``. Previous
behaviour was to bind on ``0.0.0.0``.

CHANGELOG_END
2020-03-05 17:10:49 +01:00
Moritz Kiefer
0a6be2b341
Overload submit so that it doesn’t collide with DAML script (#4831)
This introduces a `HasSubmit` typeclass (following the naming scheme
of `HasCreate`, …) and instances for `Scenario` and `Script`. This
avoids the need to hide `submit` in every single DAML script.

changelog_begin

- [DAML Standard Library] ``submit`` and ``submitMustFail`` are now
  overloaded so that they can be used in both scenarios and DAML script.

changelog_end
2020-03-05 15:43:35 +01:00
Moritz Kiefer
42dd6349e9
Cache unmangleIdentifier (#4822)
* Cache unmangleIdentifier

Previously we unmangled once per reference to an identifier rather
than doing the unmangling once per entry in the string interning
table. This PR fixes this which brings a pretty decent performance
improvement. On my testcase the time for converting for converting
from the low-level proto AST to the high-level Haskell AST goes down
from 13.5 to 7.5s on a certain DALF that we know very well. Max
residency also goes down from 2GB to 1.5GB (although that number is
somewhat unreliable ime) and allocations drop by 8%.

changelog_begin
changelog_end

* Move error message to unmangleIdentifier
2020-03-05 13:35:28 +01:00
mergify[bot]
cb1395e923
Remove damlc migrate (#4816)
* Remove damlc migrate

``damlc migrate`` hasn’t worked for quite a while and we emitted a
warning for months so given that we don’t have plans to make it work
again in the near future, I think it does more harm than good to keep
it around.

changelog_begin

- [DAML Compiler] After being deprecated for a while the ``damlc
  migrate`` command has now been removed. See
  https://docs.daml.com/upgrade/ for up to date documentation
  on model upgrades.

changelog_end

fixes #3704 (by removing the tests 😇)

* yeah the windows cache is once again broken \o/

* Revert "yeah the windows cache is once again broken \o/"

This reverts commit 38d7877aa4.
2020-03-04 20:36:48 +00:00
Moritz Kiefer
c866ac5132
Speed up unmangleIdentifier (#4810)
* Speed up unmangleIdentifier

On my (admittedly not super scientific) benchmark, this brings the
time used to convert from the low-level proto Haskell AST to the
high-level AST from 20s down to 16s on a certain DALF that we are all
too familiar with.

changelog_begin
changelog_end

* address review comments
2020-03-04 19:48:03 +01:00
Moritz Kiefer
c6e3bf5399
Only unmangle once in decodeValueName (#4813)
The `decodeValueName` code is rather confusing. It calls things
unmangled that are mangled and the other way around.

Furthermore, it unmangles twice, once in `decodeNameString` and once
directly in `decodeValueName`. The code claims that this is a
compatiblity hack but unless someone can explain to me what exactly is
failing here or CI fails, I would prefer to just kill this.

changelog_begin
changelog_end
2020-03-04 17:29:55 +00:00
Moritz Kiefer
a928402050
Make debug a bit more lazy (#4807)
* Make `debug` a bit more lazy

Previously `debug x >>= f` would print the debug statement when it got
evaluated rather than when the monadic execution got executed. This is
rather confusing. Now we explicitly make it lazy by wrapping the trace
statement in a lambda passed to >>=.

changelog_begin

- [DAML Standard Library] Fix a bug where ``debug`` printed the trace
  statement before the action got executed. Note that this means that
  ``debug`` now has a slightly more restrictive type. You can use
  ``trace`` directly if this causes problems.

changelog_end

* Update compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-03-04 17:12:24 +00:00
Moritz Kiefer
3c30073b31
Merge cross-LF tests (#4785)
Given that these two group of tests run for the same combination of LF
versions, I don’t see any reason why we should keep them
separate. Merging them, speeds up the packaging tests by > 50s on my
local machine.

changelog_begin
changelog_end
2020-03-03 09:53:06 +00:00
Moritz Kiefer
cc7f3e7ad0
Avoid decoding package twice in validate-dar (#4780)
Rather than decoding everything twice, we can only rewrite references
which is measurably faster (> 5s out of 60s on the packaging tests).

changelog_begin
changelog_end
2020-03-03 10:28:11 +01:00
Moritz Kiefer
ebbe135583
Add singleton to DA.List (#4777)
changelog_begin

- [DAML Standard Library] Add ``singleton`` to ``DA.List``.

changelog_end
2020-03-02 20:49:21 +00:00
Moritz Kiefer
d68d3eb74a
Freeze DAML-LF 1.8 (#4770)
* Freeze DAML-LF 1.8

Two minor points that I did not mention in the previous PR:

We also include the renaming of structural records to `struct` and the
renaming of `Map` to `TextMap`.

There are some minor changes around the LF encoder tests which need to
be able to emit package metadata properly so I’ve added it to the
parser. Sorry for not splitting that out.

Following the process used for the DAML-LF 1.7 release, this does not
yet include the frozen proto file.

changelog_begin

- [DAML-LF] Release DAML-LF 1.8:

  * Rename structural records to ``Struct``. Note that
    structural records are not exposed in DAML.
  * Rename ``Map`` to ``TextMap``.
  * Add type synonyms. Note that type synonyms are not serializable.
  * Add package metadata, i.e., package names and versions.

  Note that the default output of ``damlc`` is stil DAML-LF 1.7. You
  can produce DAML-LF 1.8 by passing ``--target=1.8``.

changelog_end

* Update encoder

* Update java codegen tests

* Update comment in scala codegen

* Handle TSynApp in interface reader

* Bump lf_stable_version to 1.7

* Fix kvutils tests
2020-03-02 18:29:26 +01:00
Moritz Kiefer
501aa9e89e
Prepare DAML-LF 1.8 release (#4769)
We will only include type synonyms and package metadata (which are
used for Cross-SDK model upgrades). Everything else stays in 1.dev for
now.

changelog_begin
changelog_end
2020-03-02 14:23:07 +00:00
Moritz Kiefer
7a9b9a3ace
Fix data-dependencies for impredicative types (#4744)
I’m not really happy with this “fix” but after having spend way too
much time on this, this was the best I came up with. (The details are
in an inline comment). If anyone has better ideas, I’m all ears.

changelog_begin
changelog_end
2020-03-02 09:37:46 +01:00
nickchapman-da
8af3857c09
Use damlc validate-dar in packaging tests. (#4760)
Replace `daml-lf-repl validate` in packaging tests with `damlc validate-dar`.
Simplify test setup a little by passing tools (damlc,validate, etc) in a record.

changelog_begin
changelog_end
2020-02-28 16:28:04 +00:00
nickchapman-da
b8124a993f
damlc validate-dar (#4654)
changelog_begin
changelog_end
2020-02-27 14:26:14 +00:00
Moritz Kiefer
597c3a30f6
Fix unstableDrop (#4740)
We want to start at n not at length - n

changelog_begin
changelog_end
2020-02-27 11:11:57 +01:00
Moritz Kiefer
d455267e58
Reduce the number of GHCs in our nix closure (#4729)
This reduces the number of GHCs to 2 on Linux (regular and DWARF) and
1 on macOS. Given that each derivation is > 1 GB this should hopefully
help a bit.

changelog_begin
changelog_end
2020-02-26 20:00:07 +01:00
Shayne Fletcher
66dd112960
Remove pragma 'daml 1.2' (#4702)
changelog_begin
- The pragma 'daml 1.2' is now optional.
changelog_end
2020-02-26 13:17:45 -05:00
Moritz Kiefer
c9b9293d69
Import all dependencies via Pkg_$pkgid (#4696)
Previously, we mapped `dependencies` under
Pkg_$pkgId.originalmodule name and imported them this way. However, we
did not map `dependencies` the same way. This PR unifies the two and
cleans up the import handling logic a bit.

This also fixes imports if we have two packages with the same name but
a different version since the package name (which is the only thing
usable in package-qualified imports) is not sufficient to
disambiguate. I’ve added a test for this.

changelog_begin
changelog_end
2020-02-26 17:08:41 +01:00
Moritz Kiefer
48acfc3073
Remove daml version headers from packaging tests (#4719)
changelog_begin
changelog_end
2020-02-26 13:04:26 +00:00
Moritz Kiefer
c11a0ebd43
Delete damlc generate-src and damlc generate-gen-src (#4714)
These commands were intended for debugging but neither @associahedron
nor I actually use them since running `daml build` and looking at the
generated files in `.daml` is a much more robust solution.

I’ve also deleted some leftover code from the old-style
data-dependencise where we generated actual template instances (not
just dummy instances). We’ve already deleted everything else around
this, this was just leftover by accident.

The only usage was a testcase which I’ve just switched over to using
`daml build`.

changelog_begin
changelog_end
2020-02-26 11:15:21 +00:00
associahedron
860477bb1f
Handle generic variant records in data-deps. (#4710)
* Handle generic variant records in data-deps.

Fixes issue #4707.

changelog_begin
changelog_end

* Add usage test of problem constructor
2020-02-26 10:52:44 +00: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
Gary Verhaegen
5a117dc358
introduce new release process (#4513)
Context
=======

After multiple discussions about our current release schedule and
process, we've come to the conclusion that we need to be able to make a
distinction between technical snapshots and marketing releases. In other
words, we need to be able to create a bundle for early adopters to test
without making it an officially-supported version, and without
necessarily implying everyone should go through the trouble of
upgrading. The underlying goal is to have less frequent but more stable
"official" releases.

This PR is a proposal for a new release process designed under the
following constraints:

- Reuse as much as possible of the existing infrastructure, to minimize
  effort but also chances of disruptions.
- Have the ability to create "snapshot"/"nightly"/... releases that are
  not meant for general public consumption, but can still be used by savvy
  users without jumping through too many extra hoops (ideally just
  swapping in a slightly-weirder version string).
- Have the ability to promote an existing snapshot release to "official"
  release status, with as few changes as possible in-between, so we can be
  confident that the official release is what we tested as a prerelease.
- Have as much of the release pipeline shared between the two types of
  releases, to avoid discovering non-transient problems while trying to
  promote a snapshot to an official release.
- Triggerring a release should still be done through a PR, so we can
  keep the same approval process for SOC2 auditability.

The gist of this proposal is to replace the current `VERSION` file with
a `LATEST` file, which would have the following format:

```
ef5d32b7438e481de0235c5538aedab419682388 0.13.53-alpha.20200214.3025.ef5d32b7
```

This file would be maintained with a script to reduce manual labor in
producing the version string. Other than that, the process will be
largely the same, with releases triggered by changes to this `LATEST`
and the release notes files.

Version numbers
===============

Because one of the goals is to reduce the velocity of our published
version numbers, we need a different version scheme for our snapshot
releases. Fortunately, most version schemes have some support for that;
unfortunately, the SDK sits at the intersection of three different
version schemes that have made incompatible choices. Without going into
too much detail:

- Semantic versioning (which we chose as the version format for the SDK
  version number) allows for "prerelease" version numbers as well as
  "metadata"; an example of a complete version string would be
  `1.2.3-nightly.201+server12.43`. The "main" part of the version string
  always has to have 3 numbers separated by dots; the "prerelease"
  (after the `-` but before the `+`) and the "metadata" (after the `+`)
  parts are optional and, if present, must consist of one or more segments
  separated by dots, where a segment can be either a number or an
  alphanumeric string. In terms of ordering, metadata is irrelevant and
  any version with a prerelease string is before the corresponding "main"
  version string alone. Amongst prereleases, segments are compared in
  order with purely numeric ones compared as numbers and mixed ones
  compared lexicographically. So 1.2.3 is more recent than 1.2.3-1,
  which is itself less recent than 1.2.3-2.
- Maven version strings are any number of segments separated by a `.`, a
  `-`, or a transition between a number and a letter. Version strings
  are compared element-wise, with numeric segments being compared as
  numbers. Alphabetic segments are treated specially if they happen to be
  one of a handful of magic words (such as "alpha", "beta" or "snapshot"
  for example) which count as "qualifiers"; a version string with a
  qualifier is "before" its prefix (`1.2.3` is before `1.2.3-alpha.3`,
  which is the same as `1.2.3-alpha3` or `1.2.3-alpha-3`), and there is a
  special ordering amongst qualifiers. Other alphabetic segments are
  compared alphabetically and count as being "after" their prefix
  (`1.2.3-really-final-this-time` counts as being released after `1.2.3`).
- GHC package numbers are comprised of any number of numeric segments
  separated by `.`, plus an optional (though deprecated) alphanumeric
  "version tag" separated by a `-`. I could not find any official
  documentation on ordering for the version tag; numeric segments are
  compared as numbers.
- npm uses semantic versioning so that is covered already.

After much more investigation than I'd care to admit, I have come up
with the following compromise as the least-bad solution. First,
obviously, the version string for stable/marketing versions is going to
be "standard" semver, i.e. major.minor.patch, all numbers, which works,
and sorts as expected, for all three schemes. For snapshot releases, we
shall use the following (semver) format:

```
0.13.53-alpha.20200214.3025.ef5d32b7
```

where the components are, respectively:

- `0.13.53`: the expected version string of the next "stable" release.
- `alpha`: a marker that hopefully scares people enough.
- `20200214`: the date of the release commit, which _MUST_ be on
  master.
- `3025`: the number of commits in master up to the release commit
  (included). Because we have a linear, append-only master branch, this
  uniquely identifies the commit.
- `ef5d32b7ù : the first 8 characters of the release commit sha. This is
  not strictly speaking necessary, but makes it a lot more convenient to
  identify the commit.

The main downsides of this format are:

1. It is not a valid format for GHC packages. We do not publish GHC
  packages from the SDK (so far we have instead opted to release our
  Haskell code as separate packages entirely), so this should not be an
  issue. However, our SDK version currently leaks to `ghc-pkg` as the
  version string for the stdlib (and prim) packages. This PR addresses
  that by tweaking the compiler to remove the offending bits, so `ghc-pkg`
  would see the above version number as `0.13.53.20200214.3025`, which
  should be enough to uniquely identify it. Note that, as far as I could
  find out, this number would never be exposed to users.
2. It is rather long, which I think is good from a human perspective as
  it makes it more scary. However, I have been told that this may be
  long enough to cause issues on Windows by pushing us past the max path
  size limitation of that "OS". I suggest we try it and see what
  happens.

The upsides are:

- It clearly indicates it is an unstable release (`alpha`).
- It clearly indicates how old it is, by including the date.
- To humans, it is immediately obvious which version is "later" even if
  they have the same date, allowing us to release same-day patches if
  needed. (Note: that is, commits that were made on the same day; the
  release date itself is irrelevant here.)
- It contains the git sha so the commit built for that release is
  immediately obvious.
- It sorts correctly under all schemes (modulo the modification for
  GHC).

Alternatives I considered:

- Pander to GHC: 0.13.53-alpha-20200214-3025-ef5d32b7. This format would
  be accepted by all schemes, but will not sort as expected under semantic
  versioning (though Maven will be fine). I have no idea how it will sort
  under GHC.
- Not having any non-numeric component, e.g. `0.13.53.20200214.3025`.
  This is not valid semantic versioning and is therefore rejected by
  npm.
- Not having detailed info: just go with `0.13.53-snapshot`. This is
  what is generally done in the Java world, but we then lose track of what
  version is actually in use and I'm concerned about bug reports. This
  would also not let us publish to the main Maven repo (at least not more
  than once), as artifacts there are supposed to be immutable.
- No having a qualifier: `0.13.53-3025` would be acceptable to all three
  version formats. However, it would not clearly indicate to humans that
  it is not meant as a stable version, and would sort differently under
  semantic versioning (which counts it as a prerelease, i.e. before
  `0.13.53`) than under maven (which counts it as a patch, so after
  `0.13.53`).
- Just counting releases: `0.13.53-alpha.1`, where we just count the
  number of prereleases in-between `0.13.52` and the next. This is
  currently the fallback plan if Windows path length causes issues. It
  would be less convenient to map releases to commits, but it could still
  be done via querying the history of the `LATEST` file.

Release notes
=============

> Note: We have decided not to have release notes for snapshot releases.

Release notes are a bit tricky. Because we want the ability to make
snapshot releases, then later on promote them to stable releases, it
follows that we want to build commits from the past. However, if we
decide post-hoc that a commit is actually a good candidate for a
release, there is no way that commit can have the appropriate release
notes: it cannot know what version number it's getting, and, moreover,
we now track changes in commit messages. And I do not think anyone wants
to go back to the release notes file being a merge bottleneck.

But release notes need to be published to the releases blog upon
releasing a stable version, and the docs website needs to be updated and
include them.

The only sensible solution here is to pick up the release notes as of
the commit that triggers the release. As the docs cron runs
asynchronously, this means walking down the git history to find the
relevant commit.

> Note: We could probably do away with the asynchronicity at this point.
> It was originally included to cover for the possibility of a release
> failing. If we are releasing commits from the past after they have been
> tested, this should not be an issue anymore. If the docs generation were
> part of the synchronous release step, it would have direct access to the
> correct release notes without having to walk down the git history.
>
> However, I think it is more prudent to keep this change as a future step,
> after we're confident the new release scheme does indeed produce much more
> reliable "stable" releases.

New release process
===================

Just like releases are currently controlled mostly by detecting
changes to the `VERSION` file, the new process will be controlled by
detecting changes to the `LATEST` file. The format of that file will
include both the version string and the corresponding SHA.

Upon detecting a change to the `LATEST` file, CI will run the entire
release process, just like it does now with the VERSION file. The main
differences are:

1. Before running the release step, CI will checkout the commit
  specified in the LATEST file. This requires separating the release
  step from the build step, which in my opinion is cleaner anyway.
2. The `//:VERSION` Bazel target is replaced by a repository rule
  that gets the version to build from an environment variable, with a
  default of `0.0.0` to remain consistent with the current `daml-head`
  behaviour.

Some of the manual steps will need to be skipped for a snapshot release.
See amended `release/RELEASE.md` in this commit for details.

The main caveat of this approach is that the official release will be a
different binary from the corresponding snapshot. It will have been
built from the same source, but with a different version string. This is
somewhat mitigated by Bazel caching, meaning any build step that does
not depend on the version string should use the cache and produce
identical results. I do not think this can be avoided when our artifact
includes its own version number.

I must note, though, that while going through the changes required after
removing the `VERSION` file, I have been quite surprised at the sheer number of
things that actually depend on the SDK version number. I believe we should
look into reducing that over time.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-25 17:01:23 +01:00
Moritz Kiefer
38b7e65197
Add documentation for DAML repl and advertise it (#4678)
* Add documentation for DAML repl and advertise it

This PR adds some simple docs for ``daml repl`` and adds it to the
release notes.

changelog_begin

- [DAML Repl - Experimental] A new ``daml repl`` command that allows
  you to use the ``DAML Script`` API interactively. Take a look at the
  `documentation <https://docs.daml.com/daml-repl/>`_ for more
  information.

changelog_end

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

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

* s/Repl/REPL/

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-02-25 11:16:31 +00:00
Moritz Kiefer
76ae5d15a4
Use package metadata instead of file names to infer unit ids (#4667)
* Use package metadata instead of file names to infer unit ids

This PR adds a function that abstracts over whether we get metadata
from a filename (< 1.dev) or directly from the LF metadata.

There is more work to be done here, in particular, I want to clean up
the hacks around daml-prim/daml-stdlib but I’ll leave that for a
separate PR.

changelog_begin
changelog_end

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

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

* Refactor getUnitId

Co-authored-by: associahedron <231829+associahedron@users.noreply.github.com>
2020-02-24 18:12:29 +00:00
Moritz Kiefer
2a05611b63
Graceful error handling in daml repl (#4673)
* Graceful error handling in `daml repl`

This PR changes `daml repl` to handle errors (parse errors, type
errors, unsupported statement errors, script errors) gracefully
and just emit an error message instead of tearing down the whole
process.

This gets the repl into a state where I think it’s sufficiently
user-friendly to be released (obviously there are tons of potential
improvements). The only thing missing before I’m comfortable
mentioning this in release notes and uninternalizing it are docs.
If you think there is something crucial that needs to be addressed
before, let me know.

changelog_begin
changelog_end

* why is windows
2020-02-24 18:15:32 +01:00
Moritz Kiefer
500fb9a171
Support shadowing in daml repl (#4668)
changelog_begin
changelog_end
2020-02-24 15:47:00 +01:00
Moritz Kiefer
8d81399c0f
Add an experimental DAML script REPL (#4660)
As mentioned in the title, this is still very experimental and needs
more work before we want to advertise it. However, the code is in a
somewhat reasonable shape, there are tests and I think even in the
current state it is already useful. Also this PR is already getting
very large so I don’t want to hold off much longer before merging this.

It is included in the SDK but hidden from `damlc --help` and `daml
--help` until the most pressing issues are addressed (primarily around
making sure that it doesn’t just shut down if you have a type error
and better error messages in general).

changelog_begin
changelog_end
2020-02-24 11:06:27 +01:00
Martin Huschenbett
b38ec15e3a
Add hlint rule to use whenJust instead of maybe (pure ()) (#4659)
This has come up a few times lately.

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-24 10:08:44 +01:00
Remy
0321a1bb32
[Engine] push absolute contract ids inside the evaluation (#4652)
* [Engine] push absolute contract inside the evaluation
* Remove discriminator fom relative contract id

CHANGELOG_BEGIN
CHANGELOG_END
2020-02-21 20:21:35 +01:00
Moritz Kiefer
c68dd19ade
Decode and validate package metadata in Scala (#4653)
This adds the code for decoding and validating package metadata
that is now emitted by damlc.

changelog_begin
changelog_end
2020-02-21 18:20:42 +00:00
Moritz Kiefer
c03ded317b
Produce package metadata in damlc (#4647)
This PR adds the necessary infrastructure to produce package metadata
in `damlc`.

For `damlc build` this works exactly as expected. There are a few edge
cases where we don’t have names and/or versions (namely scenarios,
damlc compile and damlc package). We don’t really care about the
metadata for those anyway, so I’ve just set it some default value.

changelog_begin
changelog_end
2020-02-21 13:47:28 +01:00
Moritz Kiefer
fb30690787
Clarify optionality of pVersion field in PackageConfig (#4648)
changelog_begin
changelog_end
2020-02-21 11:58:32 +00:00
Martin Huschenbett
19e1973b29
Improve documentation of DA.Text.sha256 (#4649)
This was suggested on the public slack. Easy enough to fix it quickly.

changelog_begin
changelog_end
2020-02-21 11:48:52 +00:00
Moritz Kiefer
fe6b710329
Typify splitUnitId (#4643)
Strings are confusing so let’s throw in some more types.

changelog_begin
changelog_end
2020-02-21 10:26:16 +01:00
Moritz Kiefer
a252605d91
Refactor handling of package names and versions (#4633)
* Refactor handling of package names and versions

This is a preparatory refactoring PR in preparation for propagating
package metadata into DAML-LF. There are no actual changes in here.

Primarily the changes consist of 3 things:

1. In options, we split the `optMbPackageName` field which previously
contained the unit id into `optMbPackageName` and
`optMbPackageVersion`.
2. We use newtypes for names and versions and try to keep them pretty
much everywhere (the only place missing is `splitUnitId`, I’ll do that
separately).
3. We use `UnitId` where we want `name-version`.

As was probably to be expected, this surfaced some minor issues. They
are pretty much exclusively in debugging or “internal” commands so
I’ve mostly just added notes/todos.

changelog_begin
changelog_end

* cry about applicativedo
2020-02-20 17:57:35 +00:00