diff options
author | Vincent Ambo <tazjin@google.com> | 2019-08-24T13·10+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-08-28T13·36+0100 |
commit | f6635fec982ecf892f77dde82568689631932d85 (patch) | |
tree | fad487487f543d066c67d9244a23d0056b7f62c8 /z-yants-tests.nix | |
parent | ef4ded7b98f503b6d39c9e2fb843fb8de94279d9 (diff) |
feat: Add rough initial version of sum types
Sum types are represented as attribute sets with a single key in them.
Diffstat (limited to 'z-yants-tests.nix')
-rw-r--r-- | z-yants-tests.nix | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/z-yants-tests.nix b/z-yants-tests.nix index e089aab4670a..f468f61322ec 100644 --- a/z-yants-tests.nix +++ b/z-yants-tests.nix @@ -46,6 +46,23 @@ deepSeq rec { green = throw "It should not be green!"; }; + # Test sum type definitions + creature = sum "creature" { + human = struct { + name = string; + age = option int; + }; + + pet = enum "pet" [ "dog" "lizard" "cat" ]; + }; + + testSum = creature { + human = { + name = "Brynhjulf"; + age = 42; + }; + }; + # Test curried function definitions func = defun [ string int string ] (name: age: "${name} is ${toString age} years old"); |