rename enfType -> enfIsType
This commit is contained in:
parent
bf82113bf2
commit
d20a15c01c
4 changed files with 11 additions and 11 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
(this.util)
|
(this.util)
|
||||||
enfType
|
enfIsType
|
||||||
enfIsClassSig
|
enfIsClassSig
|
||||||
flipCurry
|
flipCurry
|
||||||
hasAttrAt
|
hasAttrAt
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
else builder;
|
else builder;
|
||||||
|
|
||||||
parseDecl = base: decl:
|
parseDecl = base: decl:
|
||||||
assert enfType "set" decl "parseDecl";
|
assert enfIsType "set" decl "parseDecl";
|
||||||
# ^^^^ "Type declaration must be provided as an attribute set, got "${typeOf decl}" instead!"
|
# ^^^^ "Type declaration must be provided as an attribute set, got "${typeOf decl}" instead!"
|
||||||
decl |> projectOnto base;
|
decl |> projectOnto base;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
isTypeSig
|
isTypeSig
|
||||||
;
|
;
|
||||||
in rec {
|
in rec {
|
||||||
enfType = type: value: msg: let
|
enfIsType = type: value: msg: let
|
||||||
got = typeOf value;
|
got = typeOf value;
|
||||||
in
|
in
|
||||||
got == type || throw "${msg}: expected primitive nix type \"${type}\" but got \"${got}\"";
|
got == type || throw "${msg}: expected primitive nix type \"${type}\" but got \"${got}\"";
|
||||||
|
|
@ -23,12 +23,12 @@ in rec {
|
||||||
|
|
||||||
# NOTE: use enfHasAttr' if you can guarantee xs is type set
|
# NOTE: use enfHasAttr' if you can guarantee xs is type set
|
||||||
enfHasAttr = name: xs: msg:
|
enfHasAttr = name: xs: msg:
|
||||||
enfType "set" xs msg && enfHasAttr' name xs msg;
|
enfIsType "set" xs msg && enfHasAttr' name xs msg;
|
||||||
|
|
||||||
enfIsClassSig = sig: msg:
|
enfIsClassSig = sig: msg:
|
||||||
isClassSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Typeclass signature";
|
isClassSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Typeclass signature";
|
||||||
|
|
||||||
enfTypeSig = sig: msg:
|
enfIsTypeSig = sig: msg:
|
||||||
isTypeSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Type signature";
|
isTypeSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Type signature";
|
||||||
|
|
||||||
enfIsNT = T: msg:
|
enfIsNT = T: msg:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
(this)
|
(this)
|
||||||
enfType
|
enfIsType
|
||||||
is
|
is
|
||||||
Wrap
|
Wrap
|
||||||
;
|
;
|
||||||
|
|
@ -17,7 +17,7 @@ in rec {
|
||||||
# given path as a list of strings, return that value of an
|
# given path as a list of strings, return that value of an
|
||||||
# attribute set at that path
|
# attribute set at that path
|
||||||
getAttrAt = path: xs:
|
getAttrAt = path: xs:
|
||||||
assert enfType "set" xs "getAttrAt";
|
assert enfIsType "set" xs "getAttrAt";
|
||||||
foldl' (left: right:
|
foldl' (left: right:
|
||||||
if left != null && isAttrs left.value && hasAttr right left.value
|
if left != null && isAttrs left.value && hasAttr right left.value
|
||||||
then Wrap left.value.${right}
|
then Wrap left.value.${right}
|
||||||
|
|
@ -29,7 +29,7 @@ in rec {
|
||||||
# given path as a list of strings, return that value of an
|
# given path as a list of strings, return that value of an
|
||||||
# attribute set at that path
|
# attribute set at that path
|
||||||
hasAttrAt = path: xs:
|
hasAttrAt = path: xs:
|
||||||
assert enfType "set" xs "hasAttrAt";
|
assert enfIsType "set" xs "hasAttrAt";
|
||||||
getAttrAt path xs != null; # NOTE: inefficient (im lazy)
|
getAttrAt path xs != null; # NOTE: inefficient (im lazy)
|
||||||
|
|
||||||
# Alternative to mapAttrsRecursiveCond
|
# Alternative to mapAttrsRecursiveCond
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
(this)
|
(this)
|
||||||
enfHasAttr
|
enfHasAttr
|
||||||
enfHasAttr'
|
enfHasAttr'
|
||||||
enfType
|
enfIsType
|
||||||
;
|
;
|
||||||
|
|
||||||
masterkey = "_''traps''_";
|
masterkey = "_''traps''_";
|
||||||
|
|
@ -50,11 +50,11 @@ in rec {
|
||||||
|
|
||||||
openTrapdoorSet = key: xs: xs.${key};
|
openTrapdoorSet = key: xs: xs.${key};
|
||||||
|
|
||||||
# TODO: implement a function called enfTypeAny (for cases like this where it might be function or set)
|
# TODO: implement a function called enfIsTypeAny (for cases like this where it might be function or set)
|
||||||
openTrapdoor = key: T:
|
openTrapdoor = key: T:
|
||||||
if isFunction T
|
if isFunction T
|
||||||
then openTrapdoorFn key T
|
then openTrapdoorFn key T
|
||||||
else
|
else
|
||||||
assert enfType "set" T "openTrapdoor";
|
assert enfIsType "set" T "openTrapdoor";
|
||||||
openTrapdoorSet key T;
|
openTrapdoorSet key T;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue