daml/compiler
Martin Huschenbett 03a03957d9
Reverts digital-asset/daml#7725 (#7744)
I tried a compiler with these new warnings on a giant codebase and I
turned out they are _extremely_ noisy. There are basically two things we
want to warn about:

1.  Usage of the promoted kinds and types coming from the `DA.Generics`
    module.

    We already have a warning that importing `DA.Generics` will break
    data-dependencies. Adding a warning to every single use site of its
    exports seems rather excessive and doesn't add any new information.

2.  Usage of the `Symbol` kind and type-level strings.

    The `Symbol` kind seems to work better with data-dependencies than I
    expected although it is erased into kind `*` during conversion to
    DAML-LF. This is for two reasons: (1) The only _legal_ way to
    introduce a type variable of kind `Symbol` is by means of the
    `HasField` typeclass (you can technically get your hands on the
    `Symbol` kind directly, but you need work around not being able to
    import the internal module `GHC.Types`). (2) In data-dependencies,
    we reconstruct type variables of kind `*` not as kind `*` but rather
    ask GHC to infer their kinds (via
    [`UserTyVar`](https://hackage.haskell.org/package/ghc-8.10.1/docs/src/GHC.Hs.Types.html#UserTyVar)).
    This means that every type variable that was originally of kind
    `Symbol` will be reconstructed at that kind again since the
    necessary `HasField` constraint will force GHC to infer it.

    I'm totally aware that it looks a lot like this works by accident
    but I'm not completely opposed to making it a feature after the
    fact. Before we make any decisions in this regard though, we should
    decide on what uses of kind `Symbol` we want to make compatible with
    data-dependencies. For instance, functions of types like

        overField: forall x r a. HasField x r a => (a -> a) -> r -> r

    might be something we want to support. We also need to support
    constraints of the form `HasField "abc" ...` with a concrete
    type-level string everywhere. The current implementation would have
    warned about them. Thus, I see two open questions around the
    `Symbol` kind: (1) Do we want to allow `HasField x r a`, where `r`
    is a type variable and _not_ a type-level string, to be a superclass
    constraint? (2) Do we want to allow the same constraint in the
    context of a typeclass instance?

    One thing we should definitely not allow is using the `Symbol` kind
    directly under its name `GHC.Types.Symbol`, which is always in scope
    for our record preprocessor. I will add an error when users try to
    access that kind in a separate PR.

CHANGELOG_BEGIN
[DAML Compiler] The warning about advanced types combined with type
classes in a way that is supported by data-dependencies has been removed
again.
CHANGELOG_END
2020-10-20 22:15:14 +02:00
..
daml-extension Remove version header from vscode snippet (#7452) 2020-09-21 16:59:47 +02:00
daml-lf-ast LF: Add ExerciseByKey Update (#7663) 2020-10-14 12:06:36 +02:00
daml-lf-proto LF: Add ExerciseByKey Update (#7663) 2020-10-14 12:06:36 +02:00
daml-lf-reader DEL-8132 extract DAML LF haskell libraries (scripted) (#7246) 2020-09-01 12:09:26 +10:00
daml-lf-tools Use $$ instead of $ for new name prefixes in damlc (#7701) 2020-10-16 12:13:44 +01:00
daml-lf-verify Fix record update evaluation order. (#6590) 2020-07-03 11:25:44 +01:00
daml-licenses Connectify user-facing output (#7624) 2020-10-09 15:45:02 +02:00
damlc Reverts digital-asset/daml#7725 (#7744) 2020-10-20 22:15:14 +02:00
ghcide Get ghcide from the new upstream repo (#2867) 2019-09-11 08:57:48 +02:00
hie-core Get ghcide from the new upstream repo (#2867) 2019-09-11 08:57:48 +02:00
lsp-tests Deprecate the "daml 1.2" version header. (#7513) 2020-09-29 13:14:59 +00:00
repl-service LF: add PackageInterface a lightweigh Package (#7577) 2020-10-13 12:41:22 +02:00
scenario-service LF: enforce non-empty maintainers in contract key in fetchByKey (#7649) 2020-10-15 12:22:56 +02:00
README.md open-sourcing daml 2019-04-04 09:33:38 +01:00

DAML Compiler

This directory contains several libraries used by and the executable for the DAML compiler.

Libraries

  • daml-lf-ast: The DAML-LF AST and type checker.