about summary refs log tree commit diff
path: root/nix/yants/README.md
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-20T21·47+0000
committerVincent Ambo <tazjin@google.com>2019-12-20T21·47+0000
commitb98c60ecca79bbdea08a69a55992dac7f0b7f009 (patch)
tree3b0f1ef15cd400a39fa332ac99a28f84bafa9ff7 /nix/yants/README.md
parent0e175cbe88088d319674f9104be5b36ff5f30c8b (diff)
parent210893ce090d251df1b75082035deb60a9b06be5 (diff)
merge(yants): Integrate yants into depot at //depot/nix/yants r/248
Diffstat (limited to 'nix/yants/README.md')
-rw-r--r--nix/yants/README.md86
1 files changed, 86 insertions, 0 deletions
diff --git a/nix/yants/README.md b/nix/yants/README.md
new file mode 100644
index 000000000000..54e3e4a6a4f2
--- /dev/null
+++ b/nix/yants/README.md
@@ -0,0 +1,86 @@
+yants
+=====
+
+[![Build Status](https://travis-ci.org/tazjin/yants.svg?branch=master)](https://travis-ci.org/tazjin/yants)
+
+This is a tiny type-checker for data in Nix, written in Nix.
+
+# Features
+
+* Checking of primitive types (`int`, `string` etc.)
+* Checking polymorphic types (`option`, `list`, `either`)
+* Defining & checking struct/record types
+* Defining & matching enum types
+* Defining & matching sum types
+* Defining function signatures (including curried functions)
+* Types are composable! `option string`! `list (either int (option float))`!
+* Type errors also compose!
+
+Currently lacking:
+
+* Any kind of inference
+* Convenient syntax for attribute-set function signatures
+
+## Primitives & simple polymorphism
+
+![simple](screenshots/simple.png)
+
+## Structs
+
+![structs](screenshots/structs.png)
+
+## Nested structs!
+
+![nested structs](screenshots/nested-structs.png)
+
+## Enums!
+
+![enums](screenshots/enums.png)
+
+## Functions!
+
+![functions](screenshots/functions.png)
+
+# Usage
+
+Yants can be imported from its `default.nix`. A single attribute (`lib`) can be
+passed, which will otherwise be imported from `<nixpkgs>`.
+
+Examples for the most common import methods would be:
+
+1. Import into scope with `with`:
+    ```nix
+    with (import ./default.nix {});
+    # ... Nix code that uses yants ...
+    ```
+
+2. Import as a named variable:
+    ```nix
+    let yants = import ./default.nix {};
+    in yants.string "foo" # or other uses ...
+    ````
+
+3. Overlay into `pkgs.lib`:
+    ```nix
+    # wherever you import your package set (e.g. from <nixpkgs>):
+    import <nixpkgs> {
+      overlays = [
+        (self: super: {
+          lib = super.lib // { yants = import ./default.nix { inherit (super) lib; }; };
+        })
+      ];
+    }
+
+    # yants now lives at lib.yants, besides the other library functions!
+    ```
+
+Please see my [Nix one-pager](https://github.com/tazjin/nix-1p) for more generic
+information about the Nix language and what the above constructs mean.
+
+# Stability
+
+The current API of Yants is **not yet** considered stable, but it works fine and
+should continue to do so even if used at an older version.
+
+Yants' tests use Nix versions above 2.2 - compatibility with older versions is
+not guaranteed.