Include dhall-nix in stack and cabal project configs (#1178)

Note that `dhall-nix` cannot be built on Windows due to its transitive
dependency on the `unix` package.

Also:

* Nix: Enable `-Werror` for `dhall-nix`

* Add support for `toMap` in `dhall-nix`:

    \(x : { a : Bool }) -> toMap x

is translated as

    x:
      (kvs:
        map (k:
          {
            mapKey = k;
            mapValue = builtins.getAttr k kvs;
            }) (builtins.attrNames kvs)) x
This commit is contained in:
Simon Jakobi 2019-07-31 18:24:15 +02:00 committed by GitHub
parent cb38ba2941
commit 42d80b057d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View File

@ -1 +1 @@
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-lsp-server
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-lsp-server ./dhall-nix

View File

@ -490,6 +490,17 @@ dhallToNix e = loop (Dhall.Core.normalize e)
a' <- loop a
b' <- loop b
return (Fix (NBinary NApp b' a'))
loop (ToMap a _) = do
a' <- loop a
let ks = Fix (NBinary NApp "builtins.attrNames" "kvs")
let v = Fix (NBinary NApp (Fix (NBinary NApp "builtins.getAttr" "k")) "kvs")
let setBindings =
[ NamedVar [StaticKey "mapKey"] "k" Nix.nullPos
, NamedVar [StaticKey "mapValue"] v Nix.nullPos
]
let map_ = Fix (NBinary NApp "map" (Fix (NAbs "k" (Fix (NSet setBindings)))))
let toMap = Fix (NAbs "kvs" (Fix (NBinary NApp map_ ks)))
return (Fix (NBinary NApp toMap a'))
loop (Prefer a b) = do
a' <- loop a
b' <- loop b

View File

@ -151,6 +151,7 @@ let
"dhall"
"dhall-bash"
"dhall-json"
"dhall-nix"
];
extension =

View File

@ -3,11 +3,17 @@ packages:
- dhall
- dhall-bash
- dhall-json
- dhall-nix
- dhall-lsp-server
extra-deps:
- repline-0.2.1.0
- th-lift-instances-0.1.13@sha256:2852e468511805cb25d9e3923c9e91647d008ab4a764ec0921e5e40ff8a8e874,2625
- th-lift-0.8.0.1@sha256:cceb81b12c0580e02a7a3898b6d60cca5e1be080741f69ddde4f12210d8ba7ca,1960
- hnix-0.6.1@sha256:13da97c09489ccf0b908fbe7817401137559eebc377c00cd7b8a66b77e8c251b,24519
- hashing-0.1.0.1@sha256:98861f16791946cdf28e3c7a6ee9ac8b72d546d6e33c569c7087ef18253294e7,2816
- hnix-store-core-0.1.0.0@sha256:719a261870367b3ce2e2e8d11502e7170faa664109a14486b95b555bc3672807,2541
- monadlist-0.0.2@sha256:978305e3f03dd5f65c673b551124dac0c39a247c2c14d84739ca9a3405fbb63a,904
- ref-tf-0.4.0.1@sha256:369e5c6237e4b6fe330fde021b94a9f98971690cbec5b910faa9af3cbcb15610,1133
nix:
packages:
- ncurses