Skip to content
Branch: master
Find file History
ocharles and mergify Remove Dhall.X and replace with Data.Void (#1172)
* Remove Dhall.X and replace with Data.Void

This commit removes the Dhall.X module and the Dhall.X.X type,
preferring the use of Data.Void.Void. As I'm sure a lot of people are
actually using X, I've added a type-alias type X = Void. However,
pattern matching on X would be a breaking change.

Fixes #1120.

* Restore unsafeCoerce

* Fix regression

* Unused

* Reorganise exports

* Fix dhall-nix

* Another fix

* Fix Dhall.LSP.Backend.Typing

* Fix dhall-bash
Latest commit 4a93c25 Aug 5, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
exec
src/Dhall Remove Dhall.X and replace with Data.Void (#1172) Aug 5, 2019
.travis.yml Remove support for GHC 7.10 Jan 22, 2017
LICENSE Initial commit Jan 21, 2017
README.md Explain use case for `dhall-to-nix` (#913) Apr 28, 2019
Setup.hs Initial commit Jan 21, 2017
default.nix Integrate `dhall-nix` into CI (#887) Apr 11, 2019
dhall-nix.cabal Use ghc-8.6.5 in default stack.yaml and make appveyor use it (#1182) Aug 1, 2019
release.nix Remove old union literal syntax (#1176) Jul 31, 2019
shell.nix Integrate `dhall-nix` into CI (#887) Apr 11, 2019

README.md

dhall-nix

For installation or development instructions, see:

Full documentation here:

Introduction

This dhall-nix package provides a Dhall to Nix compiler. You can use this compiler to program Nix using the Dhall language. This package targets people who wish Nix had a type system.

Note that this is a proof-of-concept illustration of how Dhall language constructs map onto the Nix language. You might get value out of this on small Nix expressions, but you will likely run into friction using this in a larger scale with Nixpkgs or NixOS, because Dhall cannot encode many common Nixpkgs/NixOS idioms, such as:

  • general recursion (such as pkgs.callPackages, the overlay system, and the NixOS module system)
  • weakly-typed conversions (such as builtins.listToAttrs)
  • row polymorphism (i.e. the ... in { foo, bar, ... })

You can use this project to embed existing Dhall code with Nix, but probably not as a general-purpose Nix replacement.

Quick start

If you have Nix installed then you can build and run this package using:

$ dhall-to-nix <<< "λ(x : Bool) → x == False"
x: x == false
$ dhall-to-nix <<< "{ foo = 1, bar = True }"
{ bar = true; foo = 1; }
$ dhall-to-nix <<< "< Left = 2 | Right : Natural >"
{ Left, Right }: Left 2

However, this package is also designed to be used directly from Nix. You can use the following dhallToNix utility to translate Dhall source code to the corresponding Nix expression directly within Nix:

dhallToNix = code :
  let
    file = builtins.toFile "dhall-expr" code;

    drv = pkgs.stdenv.mkDerivation {
      name = "dhall-expr-as-nix";

      buildCommand = ''
        dhall-to-nix <<< "${file}" > $out
      '';

      buildInputs = [ pkgs.haskellPackages.dhall-nix ];
    };
  in
    import "${drv}";

The above dhallToNix utility is now in nixpkgs so you can use pkgs.dhallToNix to transform Dhall expressions to Nix expressions

You can’t perform that action at this time.