* Adding more info to dor
* Adding fields to the graph
* Spelling mistakes and params
* Removing single line function
* Moving the duplicated code
* Revert "Moving the duplicated code"
This reverts commit 520b5d9b0d.
* Adding more structure to graph
* Working tests with graph which is more easy to understand and change.
have few more tests to migrate
* Adding edge details
* One more to go
* Adding more verbose field information
* All tests now tests the fields that are being added
* Removing unused Import
* defined not refined
* Unused imports
* Names need to be consitent
* Acutal and Expected, not expected and expected
* Removing unused export
* Lints
It has been deprecated for a while now with a hint to use `filterWithKey`
instead. We should add
```haskell
filter : (v -> Bool) -> TextMap v -> TextMap v
```
after the next SDK release instead. This is tracked in #2760.
At the top level we don't care if bindings are recursive or not. The logic
that takes care of this ignorance is currently mixed with the actual logic
for converting the bindings.
This PR separates these concerns properly. This is also in preparation for
another upcoming change which needs access to all top level bindings.
* Add missing alpha-equivalence case.
* Type-level nat is not serializable.
* Convert decimal primitives as numeric primitives if feature is available.
* Convert decimal literals to numeric if available.
* Better approach to decimal primitves.
* Fixing BEDecimalFromText
* Add issue number
* Set Numeric feature at v1.7
This allows us to run "damlc build" in Bazel rules which is a
prerequisite for doing anything with DAML packages as they don’t work
with "damlc package".
This make the build of upgrade modules a bit more quiet. The warnings
appear because in the generated generic instances there is an
unrecognised {-# NO_OVERLAPP #-} pragma annotation.
* add Numeric.java
* ledger-api: rename `decimal` field to `numeric` in value protobuf
* Address Gerolf's comment
* ledger-api: add missing renammings
* ledger-api: relax syntax of numbers that can be sent as numerics
* extractor: fix
* leger-api: change format of number though ledger api
* daml-lf: fix numeric regexp
* ledger: fix tests
* Templates and scenario for generic transfers
* Simplify transfer workflow by self-issuing cash
* Generic swap in the same style as Transferrable
* Use Template class constraints instead of *Instance constraints
* Shorter asset name for transferrable/swappable templates
* Shorten some stuff
* Simplify swap acceptance, remove dependency on transfers, add some checks in scenarios
* Remove FlexibleContexts extension which should be on by default
* Move Asset typeclass and Cash instance to separate module
* Rename Swap module to Swappable
* Revert change to VERSION file
* language: compile everything in the source directory
This removes the need to specify a 'main'. Instead we 'source' in
daml.yaml should point to the source root directory.
Currently, recursive top level functions whose type is boundedly polymorphic
require a type annotation to make it through the conversion to DAML-LF.
This PR changes the conversion slightly such that a type annotation is n o
longer required.
This fixes#2669.
Currently, we use `Safe 1` as the safety of the `BEMapEmpty` primitive. This
is clearly wrong since `BEMapEmtpy` is not supposed to be applied to a value
(but only to a type). Thus, it must be `Safe 0`. This has not caused any
problems in the past because the type checker would have caught any
application of `BEMapEmpty` to a value.
Noticed this while trying to debug the segfaults.
I don’t have a concrete case where this causes issues (usually we only
call this once on startup so leaks are not an issue) but we might as
well do it properly.
Both language extension are needed to improve the UX of generic templates.
Without them templates a la
```
template Template (A t) => B t with
```
would produce an error that we need `FlexibleContexts` for the
`Template (A t)` context and a warning suggesting to simplify it to
`AInstance t`. The latter would expose an implementation detail we prefer
to hide.
* Add test case for default method signature
* Fix default method docs
* lint
* Refactor ty calculation in getMethodDocs
* Add test for multiple names in one method type sig
* daml visualize with lsp
* Working command execution with ide
* Have to call visual now
* Split function
* Wrong constuctions of world or the module
* Working almost
* Have to gather all modules
* Now works end to end. Considers all the daml files in workspace
* removing unused code
* removing unused dependency
* Removing unused JS code and better error message
* Function re-arrange
* Removing us of heaad, instead handling error
* Format and rearranging
* Removing unused assignment
* Formating everything
* missed dependency
* Generating visual only for the file that is open
* Using modules from generated pkg, error messages
* Bringing back the commands
* Names and formating
* consitent error message
* Removing Just pattern match using _use now
* package
* Moving visual to a different module
* Function simple
* Removing Rule as it increases memeory consumption
* TODO LSP error
* White space
* Fmt things
* Handling if command was executed for a non daml files
* Better error message
* debugging
* Fix executeCommand
* Adding tests to execute command. Thanks moritz
* Unwanted lines
* Spaces and comment
* 3rd time ?
* Spaces are white
* assert equal instead of assert bool
* language: use generic templates for upgrades
Instead of generating templates we now have generic upgrade/rollback
templates in the standart library and we just create instances of in the
migration project. I will update the documentation in a follow up PR.
* Delete obsolete proto3-suite patch
My patch has been upstreamed so no need to keep it around in our repo.
* Upgrade proto3-wire
* Adapt to changes in proto3-suite
* language: smoothing out the migration experience
Some improvements to make the migration process simpler when migrating
between packages with the same name, e.g. foo-1.0.0 -> foo-2.0.0. This
is the main use case.
This switches the creation of the archive in `daml build` from
`zip-archive` to `zip`. This has a few advantages:
1. It gets rid of lazy IO for reading all the interface and source
files. This avoids the high usage of file handles in `daml build`.
2. It seems to be a slight improvement in max memory usage and runtime
and a giant improvement in allocations (but I think the latter
probably comes primarily from the fact that the locations are moved to
the bzip C library). The improvement in max memory usage is less than
I expected so probably there is still something off somewhere.
For now, I only switched over `createArchive`. Archive reading is
still done using `zip-archive`. We might want to switch that over in a
separate PR.
* language: Check for different SDK versions when building pkg db
This fixes#2510. We check whether packages were compiled with differen
SDK versions and emmit an understandable error if so.
* addressing moritz comments
* Bump stackage
This PR switches us over to the latest Stackage LTS 0.14.1 (we were on
0.13.x before, so this includes major bumps) and gets rid of some
obsolete overwrites.
* Make stack traces work with cached top level values
For stack traces to work properly in the presence of cached top level values,
we need to cache the stack trace together with the value and restore the
stack trace when we get the value from the cache.
We also need to push location information under the monadic. Otherwise, the
location information will be removed from the continuation stack before the
monadic action is _executed_.
We also change one test case to use `fail` instead of `error` since `fail` is
more tricky than `error` (due to the lazy expression embedding in DAML-LF).
Unfortunately, the test did not work woth `fail` in the past because of the
issues fixed in this PR.
* Explain special cases when pushing location information
* language: append the version to the output dar name by default.
We now by default output foo-1.0.0.dar instead just foo.dar. Also the
maven coordinate default naming got removed.
* fixing integration tests and quickstart.dar occurences
The hie-core tests are flaky in stack. They can fail with the following
error message
```
hie-core: panic! (the 'impossible' happened)\n (GHC version 8.6.5 for x86_64-unknown-linux):
Dynamic linker not initialised
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Explicitly initializing the dynamic linker at session startup should
avoid this issue.
This fixes all flakiness in `damlc test` that I was able to
reproduce. Previously, I got it to fail in about 10% of the cases
whereas now I have successfully run tests 200 times under load without
issues.
There were two issues at play here:
1. We run scenarios in separate threads to be able to kill the running
Shake session quickly even if a scenario has an infinite loop or
something like that (there is a timeout but it’s quite long). This
could result in one of those left-over threads trying to issue a
request while we are already trying to shut down.
To fix that, we wait for the concurrency semaphore to be empty before
shutting down.
2. Just waiting for scenario executions is not quite sufficient as
`runAction` does not wait for all rules to finish (we could just use
runActionSync in `damlc test` but I’d rather make this work
properly). While we do wait for all scenario executions to finish
there is one gRPC request in offInterest that we do not wait for:
gcCtxs.
To fix this, I’ve now routed all gRPC requests through the semaphore
which means that we will also wait for these requests to finish (or
prevent them from spawning).
This makes more sense anyway as scenario executions are mostly fairly
cheap requests while things like setting up the context are expensive
so we want to limit their concurrency.
We should make the concurrency limit configurable but I’ll leave that
for a separate PR.
* Extract template instance doc from newtype constructor doc
* Use new ghc-libs
* Remove type application which is not needed anymore
* Update daml-doc output with template instances
* Update hlint version
Apparently, we never had any tests for this, so this PR adds at least
a rudamentary test. The logic for this is rather stupid and easy to
break and might change soon so I’ll hold off on adding more extensive
tests until this works a bit better.
SS.scenarioServiceClient does not just read the actual client from
some IORef, it registers the available gRPC methods. Apparently we
never knew about this or at least I didn’t.
By only doing this once, we should speed things up a bit and this
fixes once of the assertion failures that we have been seing on
shutdown (pthread_mutex_lock(&mu->mutex) == 0 in sync_posix.cc) which
was caused by trying to register a method from another thread after
destroying the channel.
Add a command line option to `damlc inspect` which allows for configuring the
details level of the pretty printed DAML-LF. Right now the only difference is
that levels bigger than 0 print all location information. Level 0, which is
the default, also prints location information top level declarations.
This feature is useful for debugging location information.
* Show function names in stack trace on failing scenario
So far, we've only shown the location of the function but not its name.
Now, we add the name of the function as well.
* Only report progress when client supports it
This fixes an issue that some people encountered when running hie-core
in Emacs with a version of haskell-lsp that does not understand
progress events.
* Fix tests
* More test fixes
* language: fix: compute correct source root when building dar
Previously we just took the base directory of the main file, which is
wrong when the main is deeper down in the module structure.
* hlinting
* reuse moduleImportPaths
I assume the plan was to implement stack traces. I intend to do that as well
but the message type does not fit my approach. Thus, let's remove it first.
* Print stack traces in the scenario on failure
Currently, we only print the last source location, which is not
particularly helpful for debugging. Now, we put all source locations we
encounter during execution on the continuation stack and print them when
a scenario fails. This PR does not print the names of entered functions
or choices. We leave this for a future PR.
* Address Moritz' comments
Otherwise, we can end up retaining references to the old map which
prevent it from being garbage collected.
On a simple testcase that repeatedly opens and closes a module, this
seems to make memory usage constant whereas it was increasing
each time before.
* Add md_instances field to ModuleDoc
* Extract instances
* Add instance fields to class and type docs.
* Implement distributeInstanceDocs
* Use Maybe list instead of list.
* Render instance docs.
* Add instance data in tests and add a golden test.
* Rename to orphan typeclass instances.
* Upgrade ghc-libs supporting generic templates
* Update Proposal and ComposedKey tests to generic template syntax
* Temporarily patch daml-doc test output (will need to fix for template instances)
* Add exports to doc ctx
* Filter out unexported things.
* Added a golden test
* Fix missing constructors.
* Hide unexported class members
* Add rst golden test as well
* Remove unnecessary HIDEs from stdlib.
* lint
* Upgrade haskell-lsp and lsp-test
There have been some fixes upstream that should hopefully mean that we
no longer need to mark the lsp-tests as flaky on Windows. I am having
trouble reproducing the flakiness locally, so let’s see what happens
on CI.
* Also bump stack.yaml
Currently, we pass the flavour of the type constructor around although that
is cheaply computable from the data constructor itself. Thus, don't pass the
flavour around.
For every enum constructor `Foo` we produce a function `$ctor:Foo` whose
value is simply `Foo`. When we convert `Foo` to DAML-LF, we convert to
a call of `$ctor:Foo`. Since enum constructors are always fully applied,
this indirection is useless. Thus, we remove it in this PR.
GHC produces a function `$WFoo` for every record data constructor `Foo`.
The conversion to DAML-LF produces a function `$ctor:Foo` which does exactly
the same. We stop doing this and use the `$WFoo` function instead. Since GHC
does not produce `$WFoo` for newtypes, we need to produce these nevertheless.
I'll leave solving the corresponding issue for variant types to another PR.
Right now, the set of internal functions seems to depend on the DAML-LF
version although it actually doesn't. Since GHC is smart enough this doesn't
bite us but doesn't feel particularly clean either. If the internal functions
ever start to depend on the DAML-LF version again, we should probably put
them into the environment of the conversion to DAML-LF.
The code removed was responsible for injecting DAML-LF primitives for
`create`, `exercise`, etc. for the old template desugaring. These code
paths are not hit anymore with the new template desugaring.
* Only change project root once
As described in #2449, calling withProjectRoot' twice breaks with
relative paths and is also just silly so this PR fixes this by
factoring out the actual logic from init from execInit which does the
project root thingy.
* Add a regression test
* Avoid one indirection for dictionary construction
For every constructor `Foo` we generate a function `$ctor:Foo` which calls
the DAML-LF constructor for `Foo`. This function is useless since GHC already
creates a function `$WFoo` for us which does the same. This PR remove the
`$ctor:...` functions for type class dictionaries.
This makes a bit of a mess in the `Ctors` data type. This will be cleaned up
when all `$ctor:...` functions are finally gone.
* Fix construction of XInstance templates
This is a small step to solve the package name ambiguity problem.
Putting the package version into the package name allows to import a
package two times with different versions.
For example, we print two spaces if there's no annotation between `def` and
the function. This PR fixes this by using the `empty` document instead of the
document containing the empty string. (Please don't ask me why they are
different.)
Comparing FilePaths is really slow so by mapping them to Ints, we can
speed up dependency chasing significantly.
We might want to switch to doing some kind of global hash consing of
file paths at the Shake level but for now, this seems like a nice
improvement while not being too invasive.
This is roughly an ~8s speedup on my testcase.
Until now the test used the manually desugared syntax for the `Iou`
template. Now, we use the proper `template` syntax. The test is also
renamed from `IouDSL` to `ProposalIou` since the DSL would be confusing
after this change. In fact, we're mostly testing that the
instantiation of `Proposal a` with `a = Iou` actually works.
* Remove tests that are obsolete with new template desugaring
The tests were only relevant during the transition phase to the new
template desugaring. Since that desugaring has landed the test don't
provide value anymore and can be deleted.
* Fix super class dictionary detection
* Use tasty-golden for daml-doc's golden tests
With our hand rolled version of golden tests it is pretty painful to update
the golden files when they must change. After this PR it is as simple as
```
> bazel run //compiler/damlc/tests:daml-doc -- --accept
```
* Address indentation issues
* Use diff command line tool for diffing
* Removed new unused dependecy on Diff package
* Ignore carriage returns in diff
This allows us to GC the unsimplified DALF which decreases memory
usage and GC pressure. This does make GenerateRawDalf slightly slower
which could in theory have an effect on IDE performance since we use
the raw DALF for the scenario service. However, I haven’t been able to
measure any regressions (if it does become an issue, we could disable
optimizations completely in the IDE). In fact, things seem to be
slightly faster.
On my testcase max memory usage does seem to go down a bit but not a
lot (3.0GB to 2.7GB but it fluctuates somewhat between runs).
* Rename HaddockParse -> Extract
* Add --qualify-types option.
* More qualified type options
* Update help text
* Update compiler/damlc/lib/DA/Cli/Damlc/Command/Damldoc.hs
Co-Authored-By: Jost Berthold <jost.berthold@digitalasset.com>
* Accidentally left in a testing change.
* Documenting DocCtx fields
* Mark new options internal
* Fix daml build for usernames with spaces
This PR fixes two issues caused by having spaces in your username:
1. On Windows, we need to quote the path to the daml binary in the
batch wrapper (quotes are not valid in usernames, so no need to worry
about escaping them).
2. Invoking ghc-pkg via callCommand broke since shells are
terrible. Luckily, we can easily get away with just using callProcess
here.
* Update compiler/damlc/lib/DA/Cli/Damlc.hs
Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>
This PR moves as much work as possible to GetLocatedImports which
contracry to GetDependencyInformation is shared between rules.
It’s still slower than it should be and somewhat messy but at least
it’s slightly faster and imho cleaner than before.
* Make --shake-profiling use the directory based profiling
The single-file based profiling is rather useless in the IDE and I
always found myself having to modify the source to set `profileDir` so
this PR switches the CLI option to control that instead.
* Add --shake-profiling to damlc ide
* Unify rst and md output in damldocs.
* Fix errors
* Define RenderUnwords / RenderIntercalate in terms of RenderConcat
* Delete the old
* Small output format changes and update golden tests
* Fix table rendering and tests.
* Fix golden test.
* Delete more old
* Implement reviewer suggestions
* Optimize mangleIdentifier
I am slightly embarassed by importing Data.Text.Internal and
Data.Text.Array. However, this does make a very measurable difference:
On my testcase it brought down the time encoding modules from 22s to
17s, so it’s a 5s improvement.
I did quickcheck this against the old implementation, so I’m confident
it behaves correctly. I also ran some criterion benchmarks to see the
difference and on its own it’s even more of a difference.
https://gist.github.com/cocreature/822114257227473ecff1638a88f07788
* GHC is stupid :(
* language: put hash in package directories
We put the package id of the main dalf of a package into the directory
names, where we store the files of that package in the package database.
This way we make sure that two equally named packages don't overwrite
their dependencies and files.
This is in preparation for #2326 as well as for splitting hie-core
into a separate repo. Given that, it explicitely avoids using our
dev-env.
We do need to install a few system packages, so for now this uses the
hosted builder so we can do this. Another option would be to just add
those to our builders. I don’t really have a preference either
way. The builds are < 5 minutes so I don’t expect issues from using
the hosted builders.
* Update ghc-libs to use new template desugaring
* Replace old template typeclasses with generic-friendly ones
* New template desugaring doc
* Fix tests
* Fix damldoc tests regarding Archive choice
* Update visualisation code to not traverse master dictionary
* Additional class method stubs to template instance declaration for upgrades
* Increase stack limit for bond trading compilation test
* Update hlint version
* Supporting producing sdist tarballs for the HS ledger bindings
The README.md has an explanation for how you can use this.
This should hopefully allow others to experiment with the bindings.
My benchmark is sadly extremely noisy which makes it hard to figure
out how much of an improvement this is but it does seem to at least be
a minor improvement.
* daml-lf: prepare archive proto for Numeric
* replace DECIMAL by NUMERIC in messages and fields
* add nat kind and nat type
* add builtins CAST_NUMERIC and SHIFT_NUMERIC
* daml-lf: remove new builtins from archive proto
* daml-lf: some more doc about numeric
* daml-lf: fix spec
Speed up file modification checks
Summary: `getModificationTime` from the `directory` package is really
slow. The `unix` package is faster but still slow. This PR brings the
time spent checking file modifications (which is required on every
change) from ~0.5s to ~0.15s.
* Add anchor self-links in Rst docs
* Refactor a little with unwords
* Fix silly type error
* Refactoring and better type rendering
* Rename rst renderer functions.
* Update tests
* lint
* language: a shake rule to get interface/hie files
This adds a shake rule to get module interfaces and hie files. This
gives more control on when to build them and also an opportunity to
change the package name after typechecking. This is used in the next
PR to add package hashes to the package name in the interface files.
* generate hie files only on demand
Currently, we call `force` on every result of a rule. This was
problematic for the rules that produce LF packages:
Even if only the top-level module changes, the package for that module
contains all its dependencies. This means that we end up RNFing every
module that the current module depends on. On a project with ~900
dependencies this added up to over 1s for both GeneratePackageDeps and
GeneratePackage which corresponded to more than half of the overall
runtime.
This PR introduces a newtype for packages that does not evaluate the
modules in a package to NF. With this PR both rules are below 0.02s so
his is quite a significant improvement. We do not introduce any
potential space leaks here since the modules are produced by rules
that already force them to NF.
* Improve debugging output
Displaying the exception makes it easier to figure out what is going
wrong.
I’ve also added a HasCallStack constraint to `locateRunfiles` since it
looked like that was failing. Turned out to be a call to `create` that
didn’t go via `locateRunfiles` but I think it’s useful either way.
Should be more useful with https://github.com/tweag/rules_haskell/pull/1007
* Update compiler/hie-core/src/Development/IDE/Core/Shake.hs
Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
* Upgrade ghc-lib
* Patch bazel_tools : hazel-include-paths patch, no-isystem patch.
* Provide "haskell_c2hs" for package name to cabal_haskell_package
* Package name haskell_c2hs => c2hs.
* Switch to less hacky patch for include dirs
* damlc visual: detect ledger actions at surface level
Instead of detecting the DAML-LF primitives for `create` and `exercise`,
we detect the corresponding surface DAML functions and ignore the
dictionaries for the `Template` and `Choice` classes. This will be
necessary for swiching to the new template desugaring.
This is the quickest way to get this working but might turn into a brittle
maintenance nightmare one day. If that happens, we should switch to doing
proper symbolic evaluation, which will we be a bit more code though.
* Fix explanation
Co-Authored-By: Rohan Jacob-Rao <rohanjr@gmail.com>
* Add explanation for special casing archive
* Support depending on potentially stale values in damlc
For now, this is opt-in and only enabled for the scenario service.
Locations should be properly mapped so if lines are inserted above a
scenario, the scenario link will move down.
* Erase key lookup methods implemented using magic as well
We're already erasing `create`, `fetch` and `exercise` methods. I've
missed the ones related to key lookups when I did that. This PR fixes
my mishap.
* Fix typo in docs.
Co-Authored-By: Rohan Jacob-Rao <rohanjr@gmail.com>
We want to discourage users to pin down a target DAML-LF version but rather
want them to always use the default version, which is typically the newest
version. Thus, we turn this into an expert flag that is mostly used for
testing by us.
The module was only used to format decimal numbers. The only impact the
formatting could have had was to add/strip trailing zeros from the
presentation of the number. However, manual testing shows this did not
happen. Thus, the whole module is now useless.
`template X` generates type class `XInstance` which contains a few methods
which are implemented in terms of `magic` and then rewritten during the
conversion to DAML-LF. The default implementations of these methods need to
be erase during the conversion to DAML-LF since `magic` is erased as well.
* language: added a merge command to damlc
This adds a 'merge-dars' command to damlc to merge two dars into one.
This is useful when you created an upgrade dar and want to ship it as
part of the latest version of a package.
* added a comment on nubSort for clarity
* hie-core/test: Dedicated test suite for hie-core
* Apply hlint suggestion
Use System.Environment.Blank's setEnv which has a non-overwrite mode
that implements precisely what we were doing with more code before.
* buildifier fixes
* hie-core-exe works on Windows now - ghc-paths was fixed
This is a refactoring-only PR in preparation for supporting stale
values in damlc so we can still produce some results if a rule fails
to produce a value but has a stale value stored.
While experimenting with the pure Haskell gRPC implementation I
noticed that there is a fair amount of duplication in PrettyScenario
so this PR cleans up some of that.
The gRPC library does not handle asynchronous exceptions properly and
ends up leaking things which causes various issues (segfaults,
assertion failures, weird backup poller timer messages, …) when
shutting down gRPC.
The switch to grpcShutdownBlocking is somewhat unrelated (the issues
happen with and without that and the fix seems to work both times) but
that function seems to be the right way to shut down gRPC in newer
versions and is what all the official language bindings switched to,
so I also made the switch.
I haven’t yet looked into the issues in the HS ledger bindings so not
sure if this helps with those as well.
* language: upgrades independent of stdlib
This fixes several issues in the code generation from dalfs. As a result
we can now generate upgrades independent of the stdlib source.
Some `Development.IDE.*` modules were imported qualified as either `Compile`
or `CompilerService`. These names are at least odd and maybe also
misleading. Since there's no actual need to import them qualified, let's
just import them not qualified.
* handling dalfs flowing to next line
* space not blank
* Lints and space
* fixing the test names
* filter using not.null
* Using fold instead. makes reading easy
* Format everything
* Removing use of partial function
* More stdlib tweaks
* Another commit to kick off build again
* Fix incorrect docs syntax
* Apply suggestions from code review
Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
* Apply suggestions from code review
Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
* More suggestions applied
* Support reading of DAML-LF 1.5 in damlc again
We dropped support for this for no good reason when we dropped support for
writing DAML-LF 1.5. Being able to _read_ older versions of DAML-LF is
important for the upgrading story.
We don't support reading older versions of DAML-LF since there seems to
be no need for this.
* Fix integration test