Skip to content

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

Open
@DarkKirb

Description

@DarkKirb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions