Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dhall-nix] merge operator on Optional not transpiled correctly #2443

Open
DarkKirb opened this issue Sep 2, 2022 · 0 comments · May be fixed by #2446
Open

[dhall-nix] merge operator on Optional not transpiled correctly #2443

DarkKirb opened this issue Sep 2, 2022 · 0 comments · May be fixed by #2446

Comments

@DarkKirb
Copy link

DarkKirb commented Sep 2, 2022

I’m currently working on creating bindings for nix library functions in dhall so that you can write more of your NixOS configuration in dhall and I have run into some friction surrounding the merge operator, as it is not translated correctly.

let Optional/default =
      ./default.dhall
        sha256:5bd665b0d6605c374b3c4a7e2e2bd3b9c1e39323d41441149ed5e30d86e889ad

in  λ(v : Optional Natural)  Optional/default Natural 0 v

is translated as

v:
  v { None = 0; Some = _: _; }

and not as the working

v: if v != null then (_: _) v else 0

It generates the same code as normal unions, which is inappropriate because Some v is mapped to v and None t is mapped to null.

DarkKirb added a commit to DarkKirb/dhall-haskell that referenced this issue Sep 6, 2022
This is done by checking the type of the merge input, and emitting
special code for Optionals.

This commit fixes dhall-lang#2443
@DarkKirb DarkKirb linked a pull request Sep 6, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant