Commit Graph

765 Commits

Author SHA1 Message Date
Remy
23c3c33fe1
scenario-service: run no validation, when called from ide (#3003) 2019-09-25 11:06:47 +02:00
Martin Huschenbett
2ac81ce4b8
Change Haskell implementation of DAML-LF encoder to monadic style (#3007)
This is in preparation for interning all strings during encoding, which
will replace the current reader monad by a state monad.

This PR does not change or add any functionality. It is purely a
refactoring.
2019-09-25 09:14:11 +02:00
Shayne Fletcher
f6173c0037 Update hlint (#2999)
* Sync to f65e69951032a4c2ab308fd3c3471cd833925abf

* In the DAML parse tree, ListComps are coming through as MonadComps

* Linting smoke tests for lists

* Punctuate test header for readability
2019-09-25 03:17:13 +00:00
Rohan Jacob-Rao
4d641dbb66 Fix a bug in template resugaring (#2942)
Under very specific circumstances, as presented in `TemplateSuperClassD`, the
template resugaring would fail and the compiler crash. This PR fixes the
problem.

It also adds test case `TemplateSuperClassF` for similar very specific
circumstances under which template resugaring would fail.
2019-09-24 21:38:13 +00:00
Shayne Fletcher
044560ad70
Update hlint (cabal changes) (#3011)
* Update hlint (cabal changes)

* Fix the now failing test
2019-09-24 17:21:20 -04:00
Moritz Kiefer
1d593f2a16 Deduce pkgname in damlc migrate from dalf not dar (#3000)
The filename of the dar is not something that you should rely on as
evidenced by the fact that we have a -o option to change it to
something completely different.
2019-09-24 15:13:57 +00:00
Moritz Kiefer
78e51090df Fix Windows CPP issues (#2991)
The issue was actually not really related to CPP but to the lack of
sandboxing on Windows. That resulted in us overwriting Prelude.hi from
the 1.dev rule with the Prelude.hi from the 1.6 rule in some cases
which caused the error we were seeing.

fixes #2983
2019-09-24 13:42:48 +00:00
Moritz Kiefer
2644c98508
Update comments for getSrcRoot to new semantics (#2990) 2019-09-24 10:12:38 +02:00
Moritz Kiefer
9decc6b25f Fix getSrcRoot for A/B.daml (#2989)
Previuosly we would return A for module A.B in A/B.daml which resulted
in us including /B.daml in the DAR instead of /A/B.daml.
2019-09-24 00:31:52 +00:00
Moritz Kiefer
2e9f300563 Address comments on AnyTemplate PRs (#2986)
* Address comments on AnyTemplate PRs

* Remove unnecessary HIDE
2019-09-23 17:58:02 +00:00
associahedron
db04b57f3e Name collision checking within a module. (#2981)
* Implement name collision check

* Better error messages

* Update copyright header

* Make the map strict

* Update collision test
2019-09-23 17:17:38 +00:00
Moritz Kiefer
bf3f0063d2
Get rid of ./build.sh scripts for damlc migrate (#2984)
Now that we have the build-options fields that makes for a much nicer
interface.
2019-09-23 19:08:30 +02:00
Martin Huschenbett
2eb538e1d1 Remove outdated comment regarding feature flags in compiler (#2985) 2019-09-23 16:34:53 +00:00
Moritz Kiefer
2ab06da199 Use a consistant include dir for cwd (#2978)
* Use a consistant include dir for cwd

See https://github.com/digital-asset/ghcide/pull/114 for the actual
fix.
This PR just bumps ghcide and adds a regression test. I’ll change the
revision before merging, I just want to test CI for now.

fixes #2929

* Switch to proper ghcide revision

* writeIfacesAndHie no longer exists

* Add changelog entry

* Maybe I should try to compile code before committing but I don’t want to

* Fix ghcide exe
2019-09-23 14:33:06 +00:00
Moritz Kiefer
7a2e12d6d2
[daml-triggers] Expose template data in CreateEvents (#2973)
Now that we have AnyTemplate, we can actually make the template data accessible.
2019-09-23 12:49:01 +02:00
Moritz Kiefer
2de32b7419
Include all daml files in dar if source points to a file (#2970)
Previously, we only included the source file itself but not its
dependencies which didn’t make much sense.

This fixes #2960
2019-09-23 11:14:35 +02:00
Moritz Kiefer
20b182fcf2 Workaround Windows CPP issues (#2966)
Not sure why this is failing but given that I won’t have the time to
investigate this today, feel free to merge this as a workaround for
now.

My current suspicion is that caching is broken somehow so maybe if the
nodes get recycled it will fix itself.
2019-09-20 11:14:38 +01:00
Shayne Fletcher
f7c52d4228 Disable redundant $ rule by default (#2962) 2019-09-19 19:12:21 +00:00
Moritz Kiefer
69da1d6379 Implement AnyTemplate in DAML (#2947)
* Implement AnyTemplate in DAML

* Fix doctest path

* Shuffle around CPP

* Do not hide anything

* Hide it again

* Clean build

* Enable caching again

* debug windows crap

* more tests

* reinstantiate full tests
2019-09-19 08:42:55 +00:00
Shayne Fletcher
11f29469fe Move the dump parse tree logic slightly (#2949) 2019-09-18 15:00:36 +00:00
Moritz Kiefer
b2b94ac835
Remove redundant dropWhile isTypeArg (#2943)
(_, args) is already the result of calling "span isTypeArg" so isTypeArg
can never return true here.
2019-09-18 13:37:08 +02:00
Moritz Kiefer
afde28f1da
Bump ghc-ghcide (#2936) 2019-09-18 10:29:02 +02:00
Remy
220a03c9e8 Daml-LF: make MUL_NUMERIC and DIV_NUMERIC multi-scale (#2921)
* daml-lf: Make MUL_NUMERIC and DIV_NUMERIC multi-scale

* update release notes

* compiler: fix with type change
2019-09-17 14:32:49 +00:00
Moritz Kiefer
36e95f6cf3
Add Any type and to_any/from_any primitives to protobuf (#2930)
* Add Any type and to_any/from_any primitives to protobuf

Following a suggestion by Rémy, the protobuf representation is more
general and is associated with an arbitrary type instead of a
typecon. This allows us to easily extend this later to a full Any
type.

I’ve still called the type in the protobuf Any instead of Haskell’s
Dynamic since I find AnyTemplate more clear than DynamicTemplate and
having AnyTemplate and Dynamic seems confusing.

Right now, the decoder enforces that the type is a TypeCon.

* Fix some mistakes in the spec

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>

* Add evaluation rule for to_any_template

* Update daml-lf/spec/daml-lf-1.rst

Co-Authored-By: Remy <remy.haemmerle@daml.com>
2019-09-17 15:02:59 +02:00
Jost Berthold
277bfcbb70 HOTFIX damldoc: suppress instance docs when --data-only (#2927) 2019-09-17 11:55:51 +00:00
Remy
dc9429be1d Daml-LF: Add CAST_NUMERIC and SHIFT_NUMERIC (#2919)
* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC internally

* daml-lf: add CAST_NUMERIC and SHIFT_NUMERIC to archive proto

* daml-lf: update spec with CAST_NUMERIC and SHIFT_NUMERIC

* update release notes

* fix spec

* Address comments from Fran and Gerolf

* fix unrel
2019-09-17 08:52:54 +00:00
Martin Huschenbett
9a4735a9b3 Allow qualified import of generic templates (#2892)
* Allow for importig generic templates qualified

Currently, there's a bug which breaks `template instance` declarations when
the module containing the generic template definition is imported qualified.

This PR fixes this problem.

* Update ghc-lib, allowing qualified import of generic templates
2019-09-16 17:00:21 +00:00
Shayne Fletcher
4140b9e028
Don't disable $ rules (#2909) 2019-09-16 10:17:00 -04:00
Robin Krom
0f015e965f
language: support for automatic embeddings/projections in migation (#2893)
* language: support for automatic embeddings/projections in migation

This adds support to automatically generate embeddings/projections if an
optional field to a contract template is added. This allows generation
of migration contracts for these kind of updates.

* only project None entries

* added a test for optional field embedding/projection.
2019-09-16 14:31:38 +02:00
associahedron
dc32abb220
Add a CPP flag for each available DAML-LF feature. (#2896)
* Expose Daml LF features as a CPP flags.

* Add missing text dependency
2019-09-16 11:34:02 +01:00
Shayne Fletcher
c4c658dcb3
Add syntax tree dump support to damlc compile command (#2895) 2019-09-13 10:14:48 -04:00
Rohan Jacob-Rao
e1ff195cee
Update ghc-lib, adding locations to errors with generic templates (#2894)
* Update ghc-lib, adding some locations to errors with generic templates

* Test for template instance location
2019-09-13 10:11:00 -04:00
Jussi Mäki
868cb785ad
Preload packages to engine during upload (#2860)
* Preload packages to engine during upload

* Improve logging in KeyValueCommitting and add timing information

* Fix scenario service tests now that logging is done in interpreter
2019-09-13 14:31:52 +02:00
associahedron
183d28995f Make CPP work in damldocs. (#2891)
* Make CPP work in damldocs.

* buildifier

* Use getTemporaryDirectory

* lint
2019-09-13 11:09:39 +00:00
Shayne Fletcher
546a52e745
Remove two redundant parenthesizations (#2873)
* Remove two redundant parenthesizations

* Add test and improve comments

* Improve comments, start on some more tests (more to come)

* Bind to the newest hlint; more tests.
2019-09-11 12:41:33 -04:00
associahedron
2027d39206 Enable {-# LANGUAGE CPP #-} for daml. (#2878)
* Passing the preprocessor

* Add ghcversion.h

* Remove {-# LANGUAGE CPP #-} for now.

* Remove spurious #line

* Always add platform info, and pass -P flag

* buildifier

* Generate blank ghcversion.h to get around copyright headers check.

* Reviewer suggestions
2019-09-11 15:28:34 +00:00
Shayne Fletcher
388af4c29a
Default disable "Use camelCase" (#2885) 2019-09-11 10:30:45 -04:00
Robin Krom
41aa03c711
language: fix: missing template instances in package (#2884)
The package compiled via daml migrate was missing the actual
Upgrade/Rollback templates. This is because we used `type` instead of
`template instance` to define those templates. Also, apparently we need
to export UpgradeInstance/RollbackInstance from DA.Upgrade in the
standard library.
2019-09-11 16:05:46 +02:00
Moritz Kiefer
e2c3474f1c Upgrade ghcide to incorporate the latest changes (#2879) 2019-09-11 13:19:11 +00:00
Martin Huschenbett
2411fdb0e0 Allow exercising choices on generic templates in a generic context (#2871)
* Allow exercising choices on generic templates in a generic context

Every `template T a_1 a_n` gets desugared into a `class TInstance a_1 ... a_n`,
an instance
```
(*)    instance TInstance a_1 ... a_n => Template (T a_1 ... a_n)
```
and instances `instance TInstance a_1 ... a_n => Choice (T a_1 ... a_n) C R`
for each choice `C`.

Thus, a _generic_ exercise of a choice on `T t_1 ... t_n` needs to have the
`TInstance t_1 ... t_n` constraint in scope. However, we want to keep the
existence of the `TInstance` class an implementation detail and not expose
it to our users. Instead we want our users to add a `Template (T t_1 ... t_n)`
constraint when they want to perform the generic exercise.

Due to the (*) instance above, the constraint `Template (T t_1 ... t_n)`
is satisfied if and only if the constraint `TInstance t_1 ... t_n` is
satisfied. For the intent described above it would be necessary that GHC
conlcudes the latter from the former. Unfortunately, GHC's type system only
allows for concluding the former from the latter.

Thus, we add a preprocessing step which rewrites all constraints of
the form `Template (T t_1 ... t_n)` into `TInstance t_1 ... t_n`.

* Add test for fetchByKey
2019-09-11 09:41:21 +00:00
Moritz Kiefer
f7befca723
Get ghcide from the new upstream repo (#2867)
* Get ghcide from the new upstream repo

* Update azure-pipelines.yml

Co-Authored-By: Gary Verhaegen <gary.verhaegen@digitalasset.com>
2019-09-11 08:57:48 +02:00
Robin Krom
29b8aed5f1
language: fix: forgot to archive contract id in Update template. (#2869)
This makes sure the in-contract of the update gets archived before the
new updated contract is created.
2019-09-10 20:38:23 +02:00
Shayne Fletcher
5b6a809433
Remove (one) redundant parenthesization (#2865) 2019-09-10 12:19:49 -04:00
Gary Verhaegen
5234236639
add build-options to daml.yaml (#2772) 2019-09-10 18:16:33 +02:00
Martin Huschenbett
cb60a6d26e Avoid duplicate variant constructors (#2840)
GHC produces a function `$WFoo` for every variant 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.

The resulting code looks quite messy. I'll clean it up in a separate PR,
which will most likely involve some refactoring as well.
2019-09-10 13:58:06 +00:00
Shayne Fletcher
d4d757f8bc
Update hlint; disable bracket rules for now (#2837) 2019-09-10 09:57:27 -04:00
Martin Huschenbett
0fdf85442f
Improve UX of generic templates over Ledger API (#2779)
* Improve UX of generic templates over Ledger API

Currently, if you write
```
template Template t => Proposal t with
    receiver: Party
    asset: t
  where ...
template Iou with ...
template instance ProposalIou = Proposal Iou
```
you'll get the following DAML-LF types:
```
record Proposal t = { receiver : Party, asset : t }
record Iou = ...
record ProposalIou = { unpack : Proposal Iou }
```
The definition of `ProposalIou` is not particularly user friendly when used
over the Ledger API.

This PR changes the definition of `ProposalIou` to
```
record ProposalIou = { receiver : Party, asset : Iou }
```
Basically, the definition of `Proposal` is copied and `t` is instantiated
with `Iou`. This should make a much nicer UX.

* Update documentation

* Add test

* Fix docs examples

* Fix release notes
2019-09-10 14:38:25 +02:00
Ganesh Sittampalam
bb90002e66 ghcide: support hs-boot files (#2827) 2019-09-10 11:35:52 +02:00
Ganesh Sittampalam
21022f411b ghcide: make tests fail on unexpected diagnostic messages (#2813) (#2823)
This has the downside of relying on a timeout, experimentally tuned
to be 0.5s, as we have no other way of knowing when the server has
finished sending us messages.
2019-09-09 20:24:50 +02:00
Moritz Kiefer
d2b68d45d4 Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
2019-09-09 13:55:16 +00:00
Neil Mitchell
a7002616a3 hie-core: Ignore packages that conflict with ghc in the hie.yaml (#2819) 2019-09-09 12:02:41 +02:00
jacg
cc452a626f hie-core: Remove code pretty printing from diagnostic output (#2810)
In moving from v. 0.15 to 0.16, haskell-lsp changed the type of the
value which ended up being passed to `pretty` from `Maybe Text` to
`Maybe LSP.NumberOrString`, thereby breaking the line of code which is
removed in this commit.

After discussion with @ndmitchell, it was observed that this code was
never useful, and fixing it was not worth the trouble.
2019-09-08 18:04:19 +02:00
Ganesh Sittampalam
a3111fadc1 A couple of improvements to the experience developing hie-core itself (#2812)
* Put information about the compiler pass in the _source field of Diagnostic

It's useful when looking at the hie-core command-line output to see where
a problem is coming from.

* include test code in hie-core's own cradle
2019-09-08 18:04:04 +02:00
Domen Kožar
0779776413 README: add notes for Nix installation (#2805) 2019-09-08 16:57:59 +02:00
Tobias Pflug
c09781bab2 Add languageclient-neovim info to README (#2806) 2019-09-08 16:36:38 +02:00
Moritz Kiefer
becb3ba8eb Fix hie-core cabal file metadata (#2804) 2019-09-07 15:06:25 +00:00
Neil Mitchell
bdcbf16462 #2326, GHC 8.4 compatibility (#2796)
* #2326, GHC 8.4 compatibility

* Fix up CI

* Add a Shake lower bound

* Upgrade to a hie-bios which is GHC 8.4 compatible

* Add a GHC 8.4 stack

* Fix HLint again
2019-09-07 16:23:14 +02:00
Robin Krom
aa1e95173a
language: check dflags for errors (#2748)
* language: check dflags for errors

We add a check when we build the dflags for cases that will lead to a
failed build and emmit a clearer error message. Currently this only
includes a check, to see whether the current installed unit id is also
imported as a package from the package database.

* exclude ghc-prim from check

* exclude code generation from dflag check

* add an internal option to turn dflags check off
2019-09-06 21:24:46 +02:00
Stefan Matting
43fc0a1c8b hie-core: Add instructions for Vim (#2793) 2019-09-06 15:30:48 +02:00
Neil Mitchell
6803310fb2 Constrain ghc so that people with 8.4 don't get install plans (#2790) 2019-09-06 14:42:19 +02:00
associahedron
3c78e6110f Move (/) to a Divisible class and drop the Fractional Int instance. (#2728)
* Move (/) into a separate typeclass.

* Update release notes.

* Wording change

* rst syntax!!!

* tweak release notes.

* Remove recip on Int test.

* deduplication of release notes.

* Fix release notes?
2019-09-06 11:51:51 +00:00
associahedron
a50e0c2e0e Move HasField to DA.Record in the stdlib docs. (#2764) 2019-09-06 10:28:24 +00:00
Andreas Herrmann
ed39800a9f Rename hazel_deps to hackage_deps (#2789)
* hazel_deps --> hackage_deps

Mechanical change:

```
sed -i 's/hazel_deps/hackage_deps/g' $(ag -l hazel_deps)
```

* Hazel dependencies --> Hackage dependencies
2019-09-06 09:01:09 +00:00
Neil Mitchell
fc159a2d41 Fix hie.yaml so you can still load hie-core in hie-core (#2786) 2019-09-06 06:43:31 +02:00
Anup Kalburgi
0a9e0a8911 Adding fields to template graphs (#2673)
* 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
2019-09-05 15:57:58 +00:00
Bernhard Elsner
ad77aba246 Fix symbol in DA.Logic (#2765) 2019-09-05 12:17:28 +00:00
associahedron
ce52a0a24f
Escape all text in rst docs. (#2747)
* Escape text in rst.

* Fix the escaping

* Fix spacing and tests
2019-09-05 12:39:29 +01:00
Martin Huschenbett
b7bcba4ca7
Drop deprecated TextMap.filter from daml-stdlib (#2761)
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.
2019-09-05 13:34:49 +02:00
Martin Huschenbett
b95daba9ed Simplify conversion of top level bindings to DAML-LF (#2730)
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.
2019-09-02 19:51:03 +00:00
Martin Huschenbett
f787a0d715 Remove unused tracking of default methods from conversion to DAML-LF (#2729)
The removed code had a purpose in the past but has not been used anymore for
a while. Let's remove it.
2019-09-02 18:49:48 +00:00
Rohan Jacob-Rao
30fe23a4c1 Organise generic templates and instances into separate files (#2727)
* Organise generic templates and instances into separate files, add Fungibility

* Expect hlint warning in scenario
2019-09-02 18:39:45 +00:00
associahedron
ea9d9cb02e Convert Decimal type, literals, and primitives to Numeric when feature is available. (#2723)
* 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
2019-09-02 17:10:26 +00:00
Moritz Kiefer
336cad1016
Fix ghc-pkg runfiles (#2726)
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".
2019-09-02 18:50:25 +02:00
Martin Huschenbett
222f8c6fc1
Revert type based computation of table headers in scenario view (#2704)
The type based computation doesn't work as intended. Let's go back to the
value based computation for now and fix it later.
2019-09-02 12:35:52 +02:00
Robin Krom
d5c6d93772
langauge: suppress warnings for unrecognised pragams in upgrades (#2711)
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.
2019-08-30 12:21:01 +02:00
associahedron
0eed4afb3f Add Numeric literals in daml-lf-ast and daml-lf-proto. (#2706)
* Add Numeric literals.

* Decode numeric literals

* Add tests and fix Read for s=0

* lint

* Copyright header

* Use numericMaxScale in Serializability check

* Fix comment!
2019-08-30 08:45:03 +00:00
Remy
20649cf78e ledger-api: rename decimal field to numeric in value Proto (#2688)
* 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
2019-08-29 22:51:33 +00:00
Rohan Jacob-Rao
8dbc556655 Sketch of generic transfers and swaps (#2640)
* 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
2019-08-29 16:05:24 +00:00
Robin Krom
7fca591df0
replace main file with a pointer to the source root (#2687)
* 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.
2019-08-29 13:42:33 +02:00
Moritz Kiefer
3cda28935b Refactor DAR manifest reader (#2699)
* Refactor DAR manifest reader

This PR replaces the ad hoc string munging by a proper parser.

* Fix tests

* Fix more tests

* Factor out isHeaderChar
2019-08-29 10:26:53 +00:00
Moritz Kiefer
abfce20ce9
Fix damlc manifest writer (#2689)
Previously, we didn’t broke at 72 chars instead of 72 bytes and we did
not take the newline character into account.
2019-08-28 16:31:20 +02:00
Moritz Kiefer
664a633e20
Fix heap corruption in grpc-haskell-core (#2685)
The details are in the patch which I will also upstream.

fixes #2644
2019-08-28 16:21:37 +02:00
Martin Huschenbett
596058ac3f Allow boundedly polymorphic recursive functions without type annotation (#2684)
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.
2019-08-28 12:56:06 +00:00
associahedron
dce578bbea damlc: Add Numeric primitives and type-level nats. (#2670)
* Add Numeric primitives and type-level nats

* Statically enforce Numeric scale in serializability check
2019-08-28 12:30:33 +00:00
Martin Huschenbett
25d1e2ce63
Fix the safety of the empty map in the DAML-LF simplifier (#2679)
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.
2019-08-28 13:20:31 +02:00
Moritz Kiefer
52101479d4
Shutdown IdeState in withDamlIdeState (#2680)
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.
2019-08-28 13:02:39 +02:00
Martin Huschenbett
016b73b3de Enable MonoLocalBinds and FlexibleContexts by default in DAML (#2678)
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.
2019-08-28 10:21:54 +00:00
Shayne Fletcher
8bcf6bf568
Smoke tests for newly added dlint hints (#2672) 2019-08-27 15:09:52 -04:00
Anup Kalburgi
ff77b2e285 Correcting spelling mistakes (#2671) 2019-08-27 18:35:08 +00:00
associahedron
bd686aa6a0 damldocs: Rewrite class method extraction and fix handling of default methods. (#2667)
* 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
2019-08-27 12:50:14 +00:00
Anup Kalburgi
09b766c502 Visual integration with LSP (#2597)
* 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
2019-08-26 15:47:29 +00:00
Robin Krom
c1e7f0ad61
language: use generic templates for upgrades (#2605)
* 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.
2019-08-26 15:30:47 +02:00
Remy
6a96060af1 daml-lf: udpate LF protobuf for numerics (#2649)
* daml-lf: update proto for Numerics

* daml-lf: test decoder

* daml-lf: update spec

* daml-lf: polish proto doc

* damlc: address reviewers' comments

* daml-lf: minor fix
2019-08-26 11:55:48 +00:00
Moritz Kiefer
67c2e2a9ef
Switch to upstream gRPC-haskell (#2642)
* Switch to upstream gRPC-haskell
2019-08-23 15:10:15 +02:00
Moritz Kiefer
0419e31f0c Mark doctest integration tests as flaky (#2645)
They fail a bit too often to not mark them flaky. I’ve opened
https://github.com/digital-asset/daml/issues/2644 to track this.
2019-08-23 07:57:10 +00:00
Remy
997212c8f4
daml-lf: decommission internal Decimal type in favor of Numeric. (#2594)
* daml-lf: ValueDecimal -> ValueNumeric
* Apply suggestions from Stephen's code review
   Co-Authored-By: Stephen Compall <stephen.compall@daml.com>
* extractor: add comment about Numeric SQL format
2019-08-22 18:07:47 +02:00
associahedron
271795a6d0 damldocs: Only strip implied typeclass member constraint, not all constraints. (#2632)
* Add test case for canstrained class method.

* Fix constrained class methods bug.

* dubious lint
2019-08-22 14:44:17 +00:00
Moritz Kiefer
9654af6a26
Output more information on failure in the doctest integration tests (#2634) 2019-08-22 16:38:54 +02:00
Moritz Kiefer
88c2a1fd15 Add stripInfix to daml stdlib (#2629)
fixes #2617
2019-08-22 13:21:03 +00:00
Moritz Kiefer
03468a72ea Fix VSCode extension if extraArguments is empty (#2625)
Apparently somebody thought that splitting an empty string should
return a singleton array …
2019-08-22 08:16:59 +00:00
Moritz Kiefer
2a9eee8fae Add an extraArguments config in the VSCode extension (#2620)
This allows passing extra arguments like `--ghc-option -W`.
2019-08-21 18:50:27 +00:00
Moritz Kiefer
82ad89e770 Support --ghc-option in damlc ide (#2619)
fixes #2612
2019-08-21 13:56:15 +00:00
associahedron
e367f000a7 Hide GHC.Base.(++) (#2616) 2019-08-21 11:29:38 +00:00
associahedron
f14a925a91 damldocs: External docs links. (#2589)
* Allow for external anchor locations.

* Extracting package names in types.

* Create external references to stdlib.

* Update golden tests.

* Refactor DA.Daml.Doc.Render.Monoid
2019-08-21 10:15:42 +00:00
Rohan Jacob-Rao
4c53841eeb
Upgrade ghc-lib, improving parsing of template headers (#2609)
* Update ghc-libs
* Test for parsing template headers
2019-08-20 13:24:15 -04:00
Moritz Kiefer
0e777d9fc8 Delete obsolete proto3-suite patch (#2601)
* 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
2019-08-20 10:17:26 +00:00
Robin Krom
2374b8c231
Migrate same package name (#2564)
* 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.
2019-08-20 11:02:41 +02:00
Remy
2abf27cd67 Revert DAML-LF proto change for Numeric (#2600)
* Revert DAML-LF proto change for Numeric

This partially reverts commit 0ffe5945b8.

* daml-lf: udpate release notes

* Apply suggestions from code review

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-08-20 08:13:15 +00:00
Martin Huschenbett
f11e09f60f Stop highlighting signature as a keyword in the IDE (#2599)
This fixes #2598.
2019-08-20 07:23:39 +00:00
Moritz Kiefer
3e2ccc0842
Switch to a streaming zip encoding (#2595)
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.
2019-08-19 20:15:13 +02:00
Bernhard Elsner
d9298c8744 Various improvements to make hs-bindings usable outside repo (#2583) 2019-08-19 16:44:45 +00:00
Robin Krom
4634d35df2
language: Check for different SDK versions when building pkg db (#2591)
* 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
2019-08-19 18:43:18 +02:00
Moritz Kiefer
b4dc886fa8
Bump stackage (#2588)
* 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.
2019-08-19 13:31:10 +02:00
Moritz Kiefer
02a148fbb6
Bump hie-bios (#2586)
This includes my patches to fix the Stack cradle in hie-bios so
hie-core should now work properly on Stack projects.
2019-08-19 11:13:13 +02:00
Shayne Fletcher
4b8ac32651
Update hie-core README emacs instructions (#2567)
* Update hie-core README emacs instructions

* Send the reader to MELPA
2019-08-16 13:43:49 -04:00
Martin Huschenbett
4ae8cfd940 Write template locations when converting to DAML-LF (#2575)
Until now we've omitted them for no good reason. Choice locations
will follow in a separate PR.
2019-08-16 14:16:45 +00:00
Martin Huschenbett
0a82d9fd18 Make stack traces work with cached top level values (#2560)
* 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
2019-08-15 17:28:26 +00:00
Andreas Herrmann
76b9a477b3 hie-bios: Don't hard-code import-dirs (#2562)
* hie-bios: Don't hard-code import-dirs

* Formatting
2019-08-15 16:08:35 +00:00
Robin Krom
f209950f0b
language: append the version to the output dar name by default. (#2559)
* 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
2019-08-15 18:07:52 +02:00
Robin Krom
27d798d68a
language: use versioned name for conf files. (#2558)
Otherwise importing two different versions of the same package overrides
one conf file.
2019-08-15 16:12:42 +02:00
Andreas Herrmann
a7fac2fbee
hie-core exe: initDynLinker (#2555)
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.
2019-08-15 15:27:26 +02:00
Moritz Kiefer
3554596f9a Wait for all gRPC requests to finish before shutting down gRPC (#2551)
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.
2019-08-15 09:39:30 +00:00
Robin Krom
bf8d84216d
langauge: fix: broken package imports in ide (#2545)
We need to initialize the package database before we run
`defaultOptionsIO`, because the later filters package database path that
don't exist.
2019-08-15 11:39:15 +02:00
Andreas Herrmann
ad8c2e8426 Add more hie-core diagnostics tests (#2535)
* hie-core test: missing modules

* hie-core test: variable not in scope

* hie-core test: cyclic module dependency

* hie-core test: redundant import

* hie-core test: type error

* hie-core test: reorganise test

* hie-core test: factor out diagnostic tests

* Display unexpected diagnostics
2019-08-15 09:35:52 +00:00
Rohan Jacob-Rao
9ab3609772 Remove outdated todo (#2548) 2019-08-14 21:29:51 +00:00
Rohan Jacob-Rao
5bf86db2a1
Update generic templates (#2547)
* 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
2019-08-14 16:28:35 -04:00
Shayne Fletcher
6defc5fdf8
More dlint smoke tests (#2546)
* More dlint smoke tests

* Fix test case name
2019-08-14 15:20:11 -04:00
Shayne Fletcher
f85e2430d1
Change default lexer mode to Opt_KeepRawTokenStream (#2542)
* Change default lexer mode to Opt_KeepRawTokenStream

* Set lexer to Opt_Haddock in daml-doc tests

* Set Opt_Haddock in another daml-doc test
2019-08-14 14:13:42 -04:00
Moritz Kiefer
c27e126267
Add a test that haddock comments are shown on hover (#2539)
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.
2019-08-14 16:44:51 +02:00
Robin Krom
b85623d4d3
language: make sure conf files are uniform accross OS's. (#2538)
If a package is build on Windows, it puts '\' into the conf files, which
will not work on a Linux system. Now we always use '/' as path
separator.
2019-08-14 16:40:11 +02:00
Moritz Kiefer
126ad13326
Only register gRPC methods once (#2537)
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.
2019-08-14 16:21:17 +02:00
Martin Huschenbett
3e5115edc7 Make damlc inspect work with DARs (#2534)
So far is can only pretty print DALFs. Now, you can give it a DAR and it
will pretty print the main DALF.
2019-08-14 12:39:36 +00:00
Martin Huschenbett
4f178a3a63 Simplify the pretty printing of location info in DAML-LF (#2530) 2019-08-14 10:05:50 +00:00
Moritz Kiefer
502b09e5e7 Mark the "damlc test" tests as flaky (#2527) 2019-08-14 09:04:09 +00:00
Martin Huschenbett
4a952d59ea Make the detail level of damlc inspect configurable (#2498)
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.
2019-08-14 07:54:20 +00:00
Martin Huschenbett
803fee057f Show function names in stack trace on failing scenario (#2516)
* 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.
2019-08-14 09:16:07 +02:00
Moritz Kiefer
3eb112e4ca
Only report progress when client supports it (#2517)
* 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
2019-08-13 20:00:21 +02:00
Gary Verhaegen
99ea93168d
update copyright notices (#2499) 2019-08-13 17:23:03 +01:00
Andreas Herrmann
a1c21d9829
Update rules haskell (#2509)
* update rules_haskell

* adapt rules_haskell patches

* io_tweag_rules_haskell --> rules_haskell

* io_tweag_rules_haskell --> rules_haskell

* haskell:haskell.bzl --> haskell:defs.bzl

* rules_haskell_dependencies
2019-08-13 16:46:31 +02:00
Moritz Kiefer
da3f295507
Add commands for inserting and deleting lines to ide-debug-driver (#2511) 2019-08-13 15:25:26 +02:00
Robin Krom
8400e33cb7
language: fix: compute correct source root when building dar (#2500)
* 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
2019-08-13 13:45:22 +02:00
Moritz Kiefer
052cbe0fd4
Fix more leaks in Development.IDE.Core.Shake (#2507)
We accumulated some thunks in those variables that leak over long
sessions.
2019-08-13 13:36:03 +02:00
Martin Huschenbett
c2940705ff Remove unused message from scenario service protobuf (#2503)
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.
2019-08-13 07:07:38 +00:00
Martin Huschenbett
0ca2601cd9 Print stack traces in the scenario on failure (#2497)
* 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
2019-08-12 19:05:19 +00:00
Moritz Kiefer
b87215e111 Remove the --dump-pom flag from damlc package (#2496)
It doesn’t serve any purpose at this point so we might as well get rid
of it.
2019-08-12 17:49:43 +00:00
Anup Kalburgi
c96dae3a52
Visual ide (#2467)
Generate visualization from IDE
2019-08-12 12:42:45 -04:00
Moritz Kiefer
9ce0d414c4
Force values in setValues and getValues (#2494)
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.
2019-08-12 17:40:12 +02:00
associahedron
ed0d5667c2 damldocs: Small type rendering improvements. (#2492)
* Add parentheses around type operators in expressions.

* Remove levity arguments from (->) in stdlib docs

* Avoid parenthesizing type-level literals
2019-08-12 15:28:57 +00:00
Robin Krom
829cb4cef5
Daml stdlib with versions (#2479)
* language: build daml_stdlib with a version in the package name.

* versioned daml-stdlib in damlc

* reformat bazel files

* fix daml_doc_test
2019-08-12 16:05:28 +02:00
associahedron
b16f937d7e damldocs: Show relevant instances for types and classes. (#2487)
* 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.
2019-08-12 13:48:46 +00:00
Martin Huschenbett
bbfa0a1318 Simplify test for issue with GHC.Tuple.Unit (#2475)
* Simplify test for issue with GHC.Tuple.Unit

* Make sure tests actually produces GHC.Tuple.Unit somewhere
2019-08-12 09:20:40 +00:00
Rohan Jacob-Rao
c2f315d2ba
Support generic templates (#2465)
* 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)
2019-08-09 17:15:51 -04:00
Moritz Kiefer
2b690fd420 Increase timeout on lsp-tests (#2478)
Now that they are no longer marked as flaky on Windows, we seem to be
hitting the actual Bazel timeout sometimes.
2019-08-09 15:32:32 +00:00
associahedron
2262c5add0
damldocs: Show only exported things. (#2477)
* 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
2019-08-09 16:12:47 +01:00
Moritz Kiefer
d388c5692b
Upgrade haskell-lsp and lsp-test (#2474)
* 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
2019-08-09 15:09:59 +02:00
Martin Huschenbett
3c03d8c33b Simplify how we compute the label of a data constructor (#2473)
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.
2019-08-09 11:39:58 +00:00
Moritz Kiefer
491d13a276
Add an ide-debug-driver to make it easier to find leaks (#2472) 2019-08-09 12:48:05 +02:00
Martin Huschenbett
e9e96be3da Avoid one indirection when constructing enum values (#2469)
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.
2019-08-09 09:01:36 +00:00
Martin Huschenbett
9b1d5c8c32 Avoid duplicate record constructors (#2466)
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.
2019-08-09 07:24:20 +00:00
Martin Huschenbett
53de4511ce Make DAML internal functions version independent (#2464)
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.
2019-08-08 18:32:10 +00:00
Martin Huschenbett
f357b2f0b7 Remove compiler code to inject DAML-LF primitives for old desugaring (#2462)
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.
2019-08-08 18:04:15 +00:00
Moritz Kiefer
bdd665fcf8
Only change project root once (#2459)
* 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
2019-08-08 19:56:04 +02:00
Martin Huschenbett
8fc5b62bd8
Avoid one indirection for dictionary construction (#2456)
* 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
2019-08-08 19:12:44 +02:00
Robin Krom
6ccb18be08
language: put pkg version into pkgname (#2454)
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.
2019-08-08 16:31:09 +02:00
Martin Huschenbett
4d0a62801c Fix pretty printing of empty annotations in DAML-LF AST (#2453)
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.)
2019-08-08 12:11:56 +00:00
Moritz Kiefer
c5664fe5b5
Speed up dependency information chasing (#2444)
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.
2019-08-07 16:51:38 +02:00
Martin Huschenbett
966dfbd400 Add test for manually desugared form of the generic proposal workflow (#2442)
Having a test that demonstrates how the desugared form of the template syntax
looks like seems to be a good idea.
2019-08-07 11:53:52 +00:00
Moritz Kiefer
b3e1833e71
Use FastString where possible and speed up conversions to Text (#2436)
This cuts allocations on my testcase by about 2% and provides a
similar speedup.
2019-08-07 11:03:40 +02:00
Martin Huschenbett
c0a07e7e07
Use template syntax in IOU proposal test (#2435)
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.
2019-08-07 10:04:45 +02:00
Martin Huschenbett
c63782791e Remove tests that are obsolete with new template desugaring (#2434)
* 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
2019-08-06 18:22:49 +00:00
Moritz Kiefer
d95d25fd2f Speed up convertModuleName (#2432)
On my testcase, this cuts allocations by about 6%.
2019-08-06 18:14:34 +00:00
Martin Huschenbett
15f94783d8
Use tasty-golden for daml-doc's golden tests (#2429)
* 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
2019-08-06 19:47:52 +02:00
Shayne Fletcher
1308c8232b
hlint => dlint everywhere (#2409) 2019-08-06 13:42:36 -04:00
Moritz Kiefer
180313b404
Unrecursionschemify freeVars calculation (#2427)
This cuts allocations and speeds things up (admittedly not by a whole
lot) but it also lets us delete a bunch of code which is always nice.
2019-08-06 19:33:11 +02:00
Anup Kalburgi
629266a445
Addressing comments on a previous PR #2371 (#2408) 2019-08-06 12:48:54 -04:00
Moritz Kiefer
859ac379de
Move simplification to GenerateRawDalf (#2424)
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).
2019-08-06 16:40:29 +02:00
Martin Huschenbett
d723db8fca Simplify test for different choice syntaxes (#2405)
* Simplify test for different choice syntaxes

* Test for scoping rules of flexible controllers as well
2019-08-06 14:19:47 +00:00
Moritz Kiefer
a1ac927add
Avoid converting DARs to a strict bytestring (#2423)
Converting it to a strict bytestring only to then write it to disk
doesn’t make much sense.
2019-08-06 16:16:14 +02:00
Moritz Kiefer
d630b7134d
Activate VSCode extension on daml.resetTelemetryConsent (#2421)
Otherwise, you will get an error if you run the resetTelemetryConsent
command without having opened a .daml file.
2019-08-06 14:43:35 +02:00
Shayne Fletcher
c8783d08bb Upgrade hlint (#2406)
* Upgrade hlint

* Reduce duplication
2019-08-05 18:45:31 +00:00
Martin Huschenbett
3a02b56117 Merge the Iou12 and Iou_template test into one test (#2407)
They differ only marginally and I don't see any reason why they should be
two different tests.
2019-08-05 17:14:59 +00:00
Martin Huschenbett
ecc66604b5 Simplify test for unserializability check (#2404) 2019-08-05 17:05:12 +00:00
Martin Huschenbett
f669d7e572 Remove the old template resugaring from the GHC Core -> DAML-LF conversion (#2400)
Since we changed how the parser desugares templates, this code path won't be
hit anymore.
2019-08-05 16:38:11 +00:00
Moritz Kiefer
a967b872e2 Use a single map for RawDependencyInformation (#2399)
This cuts allocations a bit and makes things slightly faster (sadly
not a lot).
2019-08-05 16:21:36 +00:00
Rohan Jacob-Rao
4fc121db60 Use template-let-bound function in signatory decl (#2401) 2019-08-05 16:10:15 +00:00
associahedron
9042d14cb1 Damldocs qualified flag (#2394)
* 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
2019-08-05 13:23:58 +00:00
Moritz Kiefer
4a265e5399 Enable TypeApplications in daml-lf-ast.cabal (#2395)
We started using this recently which broke the cabal build.
2019-08-05 12:55:44 +00:00
Moritz Kiefer
705f014a88 Fix daml build for usernames with spaces (#2392)
* 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>
2019-08-05 08:49:40 +00:00
Moritz Kiefer
482a01dacf
Speed up dependency chasing (#2383)
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.
2019-08-05 09:31:14 +02:00
Rohan Jacob-Rao
9527fd044d Test template level let with keys (#2387) 2019-08-02 21:17:56 +00:00
associahedron
7d165a7511 damldocs: Switch to mustache templates. (#2373)
* damldocs: Switch to mustache templates.

* Update cli help and release notes.

* Move to stache
2019-08-02 13:52:38 +00:00
Moritz Kiefer
393aa14e11
Make --shake-profiling use the directory based profiling (#2378)
* 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
2019-08-02 15:21:40 +02:00
Anup Kalburgi
6f8edb86b1
Visual Checking actual actions instead of number of actions
Visual Checking actual actions instead of the number of actions
2019-08-01 18:25:04 -04:00
Martin Huschenbett
7cebdb7c17 Shrink stack size on Windows in bond memory test (#2358)
We increased it by too much in order to get tests to pass earlier. Now we shrink it to something closer to what we had before.
2019-08-01 13:45:27 -04:00
Anup Kalburgi
e5a0206a62
Visual tests - Avoid using golden file tests (#2325) 2019-07-31 15:49:53 -04:00
Neil Mitchell
6dd5e04576 Fix up the .ghci file for hie-core to track recent changes (#2322) 2019-07-31 21:15:40 +02:00
associahedron
35ee96a613 damldocs: Unify output across formats. (#2351)
* 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
2019-07-31 17:34:52 +00:00
Robin Krom
8fe537e292
Dar building cleanup (#2357)
* reorganizing dar building
2019-07-31 18:34:41 +02:00
Gary Verhaegen
0c154b7948 add set -e to vsix production (#2359) 2019-07-31 15:10:30 +00:00
Moritz Kiefer
72695ec310 Optimize mangleIdentifier (#2350)
* 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 :(
2019-07-31 14:07:36 +00:00
Robin Krom
3db5230a43
language: put hash in package directories (#2268)
* 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.
2019-07-31 14:31:45 +02:00
Moritz Kiefer
4cd35cccca
Add a Stack based pipeline for testing hie-core (#2348)
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.
2019-07-31 11:24:37 +02:00
Shayne Fletcher
f220100ab8
Enable linting in 'defaultOptionsIO' (#2343) 2019-07-31 05:08:36 -04:00
Stephen Compall
c483da3eb9 use MonoTraversable ModuleRef in place of Generic HasPackageRef (#2327)
* compiler: simpler packageRefs traversal

* compiler: include ModuleRefs in SourceLoc

* ignore the ModuleRef when traversing SourceLoc

- see https://github.com/digital-asset/daml/pull/2327#discussion_r308445649
2019-07-31 07:22:42 +00:00
Rohan Jacob-Rao
e6a4d8b251
New template desugaring (#2178)
* 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
2019-07-30 19:49:33 -04:00
Shayne Fletcher
b3dac78e66
hlint.yaml => dlint.yaml; globally disable "use newtype" hint (#2341) 2019-07-30 14:39:46 -04:00
Shayne Fletcher
8532316c3a
Enable linting in the IDE! (#2339) 2019-07-30 11:57:52 -04:00
Moritz Kiefer
50a04397e4
Supporting producing sdist tarballs for the HS ledger bindings (#2336)
* 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.
2019-07-30 14:34:16 +02:00
Shayne Fletcher
18ecf0ee8c
Support per-project hlint customization (.dlint.yaml files) (#2328)
* Support per-project hlint customization (.dlint.yaml files)

* Simplify logic with 'foldMapM'
2019-07-30 07:41:11 -04:00
associahedron
29fa387910 Move GHC.Classes docs to Prelude, hide IP. (#2333) 2019-07-30 11:15:05 +00:00
Moritz Kiefer
e415527e3e
Speed up identifier mangling (#2320)
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.
2019-07-30 08:50:51 +02:00
Remy
0ffe5945b8 DAML-LF: Prepare archive proto for Numeric (#2298)
* 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
2019-07-29 18:33:52 +00:00
nickchapman-da
b90862ebec
improve haskell module hierarchy to be more consistent (#2319) 2019-07-29 15:55:55 +01:00
Moritz Kiefer
ce5fe424fc
Speed up file modification checks (#2317)
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.
2019-07-29 16:19:32 +02:00
associahedron
462a852a03
Anchor links in Rst docs, fixing type rendering, and refactoring. (#2315)
* 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
2019-07-29 12:28:37 +01:00
associahedron
2a17b3d191 damldocs: Drop --json flag, update release notes. (#2309)
* Drop --json flag, update release notes.

* Clean up import list
2019-07-29 07:19:01 +00:00
Robin Krom
5bdc0d1b37
language: a shake rule to get interface/hie files (#2291)
* 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
2019-07-26 15:06:20 +02:00
associahedron
3d6f740964
damldocs: Hook up multiple file rendering to cli options. (#2295)
* Hook up multiple file rendering to cli options

* Fix --output help

* Fix bazel rules, boo

* Fix rule again

* Address reviewer comments
2019-07-26 13:45:06 +01:00
Moritz Kiefer
a7bb901052
Avoid evaluating modules unnecessarily to NF (#2296)
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.
2019-07-26 14:11:43 +02:00
Andreas Herrmann
5f550e852e Fix hanging hie-core tests with stack (#2293) 2019-07-26 12:08:51 +00:00
Andreas Herrmann
fc388b038f stack/cabal for hie-core-tests (#2287)
* stack/cabal for hie-core-tests

* ./fmt.sh
2019-07-25 12:50:07 +00:00
Moritz Kiefer
da9fb464db Improve debugging output (#2281)
* 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>
2019-07-25 10:33:57 +00:00
Shayne Fletcher
ee5079d9d3 Ghc lib 8.8.0.20190723 (#2279)
* 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
2019-07-25 08:59:34 +00:00
Martin Huschenbett
8d8b09c45f damlc visual: detect ledger actions at surface level (#2278)
* 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
2019-07-24 21:42:28 +00:00
Fran
16259ab00f
damldocs: Make function types mandatory. (#2274) 2019-07-24 11:22:17 +01:00
Fran
000ccfc86e
damldocs: Use blockquotes for layout in markdown rendering. (#2273)
* Use blockquote for layout

* Update tests
2019-07-24 10:30:52 +01:00
Fran
1bf9adf44e
damldocs: Reinstate contexts in markdown function docs. (#2269)
* Reinstate contexts in markdown function docs.

* Simplify missing types logic

* Fix rst rendering for sphinx
2019-07-24 09:03:33 +01:00
nickchapman-da
b30228ab95
{-# LANGUAGE OverloadedStrings #-} is now on by default (#2270) 2019-07-24 08:09:26 +01:00
Fran
d0dd201380
damldocs: Backend for rendering docs to multiple pages. (#2259)
* Begin multi-page rendering

* Fixed multi-file output rendering for HTML

* Remove renderSimpleHtml

* Remove unnecessary imports

* Remove unused lang extensions

* Address reviewer comments
2019-07-23 19:04:10 +01:00
Moritz Kiefer
5f3e4b4b35 Add property tests for PositionMapping (#2265) 2019-07-23 15:05:44 +00:00
Moritz Kiefer
80360af18b
Support depending on potentially stale values in damlc (#2257)
* 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.
2019-07-23 15:00:21 +02:00
Martin Huschenbett
35dc1848a2 Erase key lookup methods implemented using magic as well (#2252)
* 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>
2019-07-22 19:18:14 +00:00
Martin Huschenbett
a35af9697f
Hide the --target flag of damlc (#2253)
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.
2019-07-22 20:43:22 +02:00
Martin Huschenbett
3076aeb239 Remove DA.Daml.LF.Decimal module (#2251)
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.
2019-07-22 17:55:30 +00:00
Martin Huschenbett
82ef3e47cf Generic templates: erase default implementations of magic methods (#2249)
`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.
2019-07-22 16:57:01 +00:00
Martin Huschenbett
4acaa0abdd Prefix method names in generic template classes with underscore (#2248)
We will do this as part of desugaring the surface syntax to occupy less
precious namespace.
2019-07-22 15:07:53 +00:00
Robin Krom
20fde9fd98 language: added a merge command to damlc (#2232)
* 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
2019-07-22 14:04:28 +00:00
Fran
a324102a19
damldocs: Document template instances. (#2240)
* Add md_templateInstances field and TemplateInstance docs.

* Extract template instance docs from adt docs

* Turn template instance map into a set.

* Output template instances

* Refactor rst sections

* Remove extra line

* Use doc marker to detect template instances

* Remove lint

* Implement review suggestions
2019-07-22 14:48:12 +01:00
Andreas Herrmann
e2a424e5fc hie-core/test: Dedicated test suite for hie-core (#2243)
* 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
2019-07-22 13:42:04 +00:00
Moritz Kiefer
46a8737d82 Ignore optional notification and request methods (#2244)
* Ignore optional notification and request methods

* Update compiler/damlc/daml-ide/src/DA/Daml/LanguageServer.hs

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-07-22 13:12:36 +00:00
Robin Krom
c8e0f51e90
Address martin comments (#2242)
addressing martin's comments
2019-07-22 13:48:29 +02:00
Michał Majcherski
148d2a57d3
VSCode scenario codelenses improvements (#2141) 2019-07-22 10:50:30 +02:00
Moritz Kiefer
cb83a32ccd
Use a custom Value type instead of Maybe for storing rule results (#2237)
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.
2019-07-22 10:46:37 +02:00
Moritz Kiefer
4cd5766ab4 Remove duplication from PrettyScenario (#2236)
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.
2019-07-22 08:26:48 +00:00
Moritz Kiefer
f9fbfaeed2
Fix gRPC issues in damlc (#2230)
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.
2019-07-19 16:38:48 +02:00
Robin Krom
fd82ec73ab
language: generate upgrades independent of daml-prim (#2228)
This finally allows upgrades to be generated independent of the
daml-prim package.
2019-07-19 16:29:47 +02:00
Robin Krom
2b110f88e6
Upgrades independent of stdlib (#2222)
* 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.
2019-07-19 13:36:01 +02:00
Martin Huschenbett
37b7820942 Import the IDE modules unqualified instead of as Compile(rService) (#2227)
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.
2019-07-19 10:05:49 +00:00
Anup Kalburgi
bdddad4d76 Handling Dalfs list in Manifest file (#2207)
* 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
2019-07-18 15:31:52 +00:00
Martin Huschenbett
c113378482 Drop two useless occurences of 'import ... as Base' (#2216)
They don't serve any purpose and are just noise.
2019-07-18 13:53:57 +00:00
Fran
9f93362d44 Fix MOVE in GHC.Enum (#2215) 2019-07-18 13:40:09 +00:00
Martin Huschenbett
fab77c8092
Enable GHC Core linter in damlc integration tests (#2206) 2019-07-18 10:26:03 +02:00
Beth Aitman
d9e079df39 More stdlib tweaks (#2203)
* 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
2019-07-17 17:05:10 +00:00
Fran
c3f798610f
Fix Rst typeclass headers, simplify/fix typename anchors, make type declaration docs more robust. (#2202) 2019-07-17 15:13:17 +01:00
Martin Huschenbett
885aed9e0a In damlc session setup, pass options record around (#2193)
... rather than individual option fields. This prepares a change where I want
to add another option which needs to find its way into `adjustDynFlags`.
2019-07-17 13:29:30 +00:00
Martin Huschenbett
f38d717433 Support reading of DAML-LF 1.5 in damlc again (#2180)
* 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
2019-07-17 11:34:53 +00:00
Fran
f9bb9dc149
damldocs: Show generic template args and context. (#2181)
* Collect generic template args and context

* Revert template anchor change (keep it separate)

* Output generic template args and context in Rst docs

* Add template args and context in Md output
2019-07-17 11:58:55 +01:00
Shayne Fletcher
e735b16c40 Rephrase lint exit actions (#2182) 2019-07-17 10:57:59 +00:00
Beth Aitman
cd514eb024 Stdlib doc edits (#2163)
* Stdlib doc edits

* Apply suggestions from code review

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update based on Moritz's suggestion

* Fix ledger-api-integration-tests
2019-07-17 07:54:13 +00:00
Andreas Herrmann
63b46304eb
Base DA.Bazel.Runfiles on bazel-runfiles (#2147)
* DA.Bazel.Runfiles based on bazel-runfiles

* locateRunfilesMb -> locateRunfiles

* .exe extension on Windows

* Add docstring to locateRunfiles

* bazel-runfiles: Normalize on Windows
2019-07-17 09:48:44 +02:00
Fran
4a125ef963
damldocs: Recognize generic templates, choices, and template instances. (#2179)
* Add test for recognition of generic template.

* Recognise a generic template

* Recognize choices

* Recognize template instances

* Update getTemplateData haddock
2019-07-17 08:46:54 +01:00
Shayne Fletcher
2799c1c7cc Add damlc command 'lint' (#2177)
* Add damlc command 'lint'

* Tidy up

* Say "No hints" (like hlint.exe) when there's nothing to suggest
2019-07-16 21:37:29 +00:00
Robin Krom
bde8af18c9
language: correct translation of sums of products in daml code gen (#2169)
* language: correct translation of sums of products in daml code gen

We fix the translation of data type constructors with several name
components for sums of products in the translation from daml-lf back to
source.
2019-07-16 22:40:22 +02:00
Gary Verhaegen
b8d356d8e3 enable old extension test (#2103) 2019-07-16 18:12:48 +00:00
Martin Huschenbett
d5d08707c2 Drop support for DAML-LF 1.5 from damlc (#2161) 2019-07-16 13:52:29 +00:00
Moritz Kiefer
5aa3cba949
Add a damlc doctest command and test the standard library (#2157)
There is lots of room for improvements here but I think this is a good
first step. The 3 main things that could be improved imho are:

- Rewrite source locations to point to the original file rather than
  the generated module

- Provide some way to declare things like imports or more general,
  setup code that is added to the generated module.

- Prettier/more helpful output during a run, e.g., print the list of
  successful tests.
2019-07-16 15:51:01 +02:00
Fran
0fc0ca6574
damldocs: Anchors and type signature links for markdown output. (#2156)
* Move renderer monoid to its own module.

* Markdown rendering

* Add md stdlib bazel rules

* Update damldoc tests
2019-07-16 13:53:15 +01:00
Fran
7324a5d8a7 Prune DA.Generics and fix up some docs. (#2153)
* Prune DA.Generics and fix up some docs.

* Add more --

* :flame-emoji:
2019-07-16 12:12:44 +00:00
Robin Krom
aff7f1bc67
Generate interface files from dalf (#2151)
* language: upgrading: generating interface files
2019-07-16 13:46:43 +02:00
Anup Kalburgi
ddd96a05ce Same chouce name visual (#2152)
* internal name

* Adding internal choice name

* correct but ugly

* no more awkard underscore for create and archive

* not more underscores

* creating archive is not necessary

* simplify

* Removing duplicate

* simplified code

* Using cons intead of ++

* not needed parans

* Formatting
2019-07-15 19:57:20 +00:00
Shayne Fletcher
1bdf212f47
Eliminate the maybe in the hlint option (#2145)
* Eliminate the maybe in the hlint option

* Allow multiple `--with-hlint ...`, `--without-hlint` flags

* Use 'lastMay'
2019-07-15 11:11:37 -04:00
Shayne Fletcher
4f3c4f828f
Improve diagnostics of hlint ideas (#2139)
* Improve diagnostics of hlint ideas

* Zero based
2019-07-15 07:21:57 -04:00
Fran
e30955963b damldoc: Derive missing type signatures and add links in type signatures. (#2132)
* Use type information in function docs

* idpToText -> packRdrName

* Use tycon to get superclasses

* Make anchors from tycons

* Generate all type anchors with tyConAnchor

* Type information is everywhere

* Render links.

* s/missing/available/

* Update golden tests

* Hlint / refactor

* Clean up import list

* Banish evil

* Catch lint

* Use mapMaybe

* Use list comprehensions instead

* packModule -> getModulename, dc_mod -> dc_modname

* Deal with tuple constructors properly

* Update the test case

* Better docs in Rst renderer

* Add test that uses type sig links

* Update release notes
2019-07-15 11:06:01 +00:00
Shayne Fletcher
a85fee85b3
Improve hlint options handling (#2138) 2019-07-15 05:41:06 -04:00
Gary Verhaegen
e2d9541c8c bundle vsix in sdk tarball (#2113) 2019-07-12 21:35:05 +00:00
Remy
e7bbf87692 Freeze DAML-LF version 1.6 (#1937)
* daml-lf: cosmetic

* daml-lf: release V1.6

* daml-lf: update spec

* update unreleased.rst

* Address Martin's comments

* damlc: active daml-lf-target 1.6

* lf-encoder: fix testing dar generation

* daml-lf spec: simplify 1.dev description

* daml-lf: fix engine test

* daml-lf: fix version timeline

* extractor: fix test

* Address Stephen's comments

* Add more meat to the release notes

* java-codegen: update docs

* damlc: set 1.6 as default output version

* java-codegen update integration tests

* undo replicating typo

* release notes

* scala-codegen: update test

* java-codegen: fix doc

* extractor: fix  test

* address Gerolf's comments

* realse-notes: cleanup unreleased.rst

* Address last comment from Stephen

+ cosmetic cleanup

* formatting
2019-07-12 19:06:44 +00:00
Shayne Fletcher
dd77ea99e1 remove filegroup now there's only hlint.yaml (#2133) 2019-07-12 16:57:37 +00:00
Shayne Fletcher
dcd20ace8a Daml hlint integration (#2115)
* Get draft rule in

* Hlint is now firing

* First hlint unit test

* This gets hlint working in the ide

* Select hlint.yaml contextually. Wip

* Fix prod path

* Switch between prod and test versions of hlint.yaml

* Format

* Ignore hlint hints in the language tests

* Add some debugging stuff. LSP stress test is broken

* Update compiler/damlc/daml-ide-core/src/Development/IDE/Core/Rules/Daml.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Tidy up some details

* Simplify settings (remove unused parseFlags)

* Fix LSP stress tests

* ./fmt.sh

* Collapse to one hlint.yaml, provide options

* Fix location of hlint runfiles

* Disable hlint by default; enable for shake-ide tests

* lint (ironic)

* Remove filtering of lints from integration test

* ./fmt.sh

* Respect the flag

* Silence opininated lint

* Update compiler/damlc/daml-opts/daml-opts-types/DA/Daml/Options/Types.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update compiler/damlc/lib/DA/Cli/Damlc.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* I really did mean optHlintEnable here

* Move hlint enabled check to ofInterest like shouldRunScenarios

* Rename variable

* Cache settings

* Missed a merge conflict

* lift liftIO

* Remove the hlint-testing POC

* use useNoFile_
2019-07-12 16:17:06 +00:00
Anup Kalburgi
31319c219d Removing redundant data (#2116)
* Removing redundant data

* Adding some comments

* handling the duplicate acchive option

* renaming record field

* using plural

* Tpl name
2019-07-12 15:29:39 +00:00
Moritz Kiefer
6fb2703d6d Add useNoFile helpers matching defineNoFile (#2126) 2019-07-12 15:06:03 +00:00
Robin Krom
0f718eb371
language: fixed qualification in generated code (#2124)
we make sure the right things are qualified and the right things are not
qualified in generated code. we also add GHC.Types always to the imports
because it's potentially used by native types such as 'Int' and we don't
import Prelude.
2019-07-12 16:42:28 +02:00
Robin Krom
9a24c4a866
language: additional (hidden) compiler options needed for migrate (#2123)
This adds two compiler options ifaceDir and isGenerated to the compiler
options. These will be needed to write generated interface files to the
right directory and treat generated source files special when generating
interface files.
2019-07-12 16:41:10 +02:00
Moritz Kiefer
25c0052bce
Fix VSCode extension (#2117)
There were two issues:

1. VSCode changed their packaging so we now need to depend on
`@types/vscode`. This broke `yarn run compile`. I have no idea why
this did not cause an error in the Bazel build. Presumably the giant
tsconfig that it generates was doing something different.

2. We excluded src/webview.js in .vscodeignore which means that it was
not included in `vsce package` and thereby also not in the extension
included in the marketplace.
2019-07-12 11:09:37 +02:00
Moritz Kiefer
48a3f77c4f
Report progress in VSCode (#2112)
For now, we only show a “Progressing” message and a done/todo
indicator. We could eventually try to come up with something better
but I’m not quite sure what that would be since we try a lot of things
in parallel and the triggering request isn’t particularly
useful (users won’t know what a codelens request is and why they have
to wait for it).

Note that VSCode seems to have some delay in updating these
notifications so you only see the done/todo reports if it is
processing for a while.
2019-07-11 17:49:23 +02:00
Fran
ed904d1855 damldocs: Generate doc anchors at doc extraction. (#2109)
* Generate anchors in haddock parse.

* Simplify function anchors.

* Fix tests

* Fix golden test

* Fix empty doc test.
2019-07-11 15:22:11 +00:00
Moritz Kiefer
1083b23fc0
Use a separate thread for sending GCP log messages (#2102)
Apart from simplifying the code, this should also make startup
significantly faster in some cases, e.g., when the initial log request
times out.
2019-07-11 13:19:02 +02:00
dependabot[bot]
a04ee44eb4 Bump urllib3 from 1.24.1 to 1.24.2 in /compiler/daml-licenses/licenses (#2082)
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.24.1 to 1.24.2.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/master/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.24.1...1.24.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-10 20:57:10 -04:00
Anup Kalburgi
dfe5d15708 correcting the sytax as it breaks the dot command (#2094) 2019-07-11 00:00:25 +00:00
Rohan Jacob-Rao
55e3f7e106
Fix record dot preprocessor for class declarations (#2095)
The preprocessor was skipping over default method declarations.
2019-07-10 17:08:59 -04:00
Anup Kalburgi
22957ca06a
Color coding the consuming and non-consuming choices in graph (#2079)
Adding consuming and non consuming choice with colors
2019-07-10 12:30:32 -04:00
Gary Verhaegen
a4ea880cf3
get vsce through Bazel rather than nix (#2090) 2019-07-10 15:36:43 +02:00
Fran
8b31d5bb16 Apply annotations to JSON input. (#2087) 2019-07-10 09:47:23 +00:00
Fran
a8f98172c9 damldoc: Move towards extracting information from TypecheckedModule in HaddockParse. (#2013)
* Run typechecker in damldocs (but don't use result yet)

* Add Modulename to TypeApp constructor.

* Add md_name where appropriate.

* Thread a DocCtx through each doc extractor.

* Move template set and choices map into docctx

* Use Typename for template set and choice map

* Make Anchor a newtype and move it to Types

* Make Modulename in TypeApp an Anchor instead.

* Remove import of hidden module.

* Qualify that which doth need be qualified

* Update tests

* Build stdlib in such a way that it passes typechecking.

* Update release notes.

* Remove MOVE Prelude directives in daml-prim.

* Use optional in damldoc options

* Update function hashes

* Compile base packages to json first
2019-07-09 15:34:06 +00:00
Moritz Kiefer
2d52406199
Document damlc code layout (#2071) 2019-07-09 16:22:13 +02:00
Moritz Kiefer
13253d82d1
Turn the damlc module hierarchy into something a bit more sane (#2061)
This should hopefully be the last large reshuffling PR. I’ll write a
description of the new layout in the readme in a separate PR.
2019-07-09 15:10:40 +02:00
Shayne Fletcher
5567a5563f
Proof of concept : hlint/daml (#2050)
* Proof of concept : hlint/daml

* Copyright check is naieve

* Missing copyright

* Move hlint-testing out of compiler

fmt.sh tries to invoke hlint on the compiler directory. This then fails like,
```
2019-07-08T21:04:48.8037836Z $ hlint --git -j4
2019-07-08T21:04:48.9217137Z Couldn't find file: hlint-testing/data/HLint_QuickCheck.hs
2019-07-08T21:04:48.9277694Z UNEXPECTED HLINT FAILURE: The Bazel rules should have spotted this, please raise a GitHub issue
```

* Reformat

* This linting and formatting and so on is getting tiresome...

* Replace links with real files

* Strip the data directory

* Move files back under compiler/hlint-testing

* Copyright report_template.html so that format checks pass

* Calculate a hlint data directory path

* Whitespace and delete unneccessary file

* The format script uses this

* Use locateRunfiles

* Tweak record initialization formatting

* Reformat build file
2019-07-09 08:20:04 -04:00
Moritz Kiefer
2371d173b1
Move all damlc tests to compiler/damlc/tests (#2057)
I’ve also changed some of the names to be more sensible.
2019-07-09 13:38:58 +02:00
Moritz Kiefer
5c3620613b Fix conversion of getTag and tagToEnum# (#2055)
Previously, we unconditionally assumed that GHC will only use those on
Enum-like types, i.e., types with only nullary constructors. This
assumption turns out to be incorrect so this PR introduces additional
checks.
2019-07-09 10:47:47 +00:00
Moritz Kiefer
4f55cb3bda Fix VSCode extension and remove silly warnings (#2042) 2019-07-08 19:47:38 +00:00
Moritz Kiefer
edff8a416d
Move files in daml-foundations/daml-ghc to compiler/damlc (#2037)
* Move files in daml-foundations/daml-ghc to compiler/damlc

There is also a bit of refactoring going on to actually split things
apart into sensible targets. What is still missing is a cleanup of the
module hierarchy and a cleanup of the test targets but I’ll leave
those for separate PRs.

As a nice bonus, this also reduces dependencies between targets so it
will speed up compiles.

* Update .hie-bios
2019-07-08 17:55:51 +02:00