about summary refs log tree commit diff
path: root/yants.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-08T12·13+0100
committerVincent Ambo <tazjin@google.com>2019-08-28T13·36+0100
commit76f9b1638cef4f77fea94e77c1440bf85eaf52d3 (patch)
tree3518a204ca1061c8bdf0eb947a5b134fff0e4c5e /yants.nix
parent103e0b4d2531569903c362e9e592b297248057ca (diff)
feat: Add function type
It's not currently possible to check arguments for curried functions,
but there might be something on the horizon for attribute set
functions.
Diffstat (limited to 'yants.nix')
-rw-r--r--yants.nix5
1 files changed, 3 insertions, 2 deletions
diff --git a/yants.nix b/yants.nix
index c5fff0ea7d0f..e7b758f4b955 100644
--- a/yants.nix
+++ b/yants.nix
@@ -78,8 +78,9 @@ in (typeSet [
   (typedef "bool" isBool)
   (typedef "float" isFloat)
   (typedef "string" isString)
-  (typedef "derivation" (ofType "derivation"))
-
+  (typedef "derivation" (x: isAttrs x && x ? "type" && x.type == "derivation"))
+  (typedef "function" (x: isFunction x || (isAttrs x && x ? "__functor"
+                                           && isFunction x.__functor)))
   # Polymorphic types
   (poly "option" (t: v: (isNull v) || t.check v))