move enf msg arg to end
This commit is contained in:
parent
7796800888
commit
bf82113bf2
4 changed files with 11 additions and 11 deletions
|
|
@ -38,7 +38,7 @@
|
|||
else builder;
|
||||
|
||||
parseDecl = base: decl:
|
||||
assert enfType "parseDecl" "set" decl;
|
||||
assert enfType "set" decl "parseDecl";
|
||||
# ^^^^ "Type declaration must be provided as an attribute set, got "${typeOf decl}" instead!"
|
||||
decl |> projectOnto base;
|
||||
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
};
|
||||
|
||||
mkClass = sig: decl:
|
||||
assert enfIsClassSig "mkClass" sig; let
|
||||
assert enfIsClassSig sig "mkClass"; let
|
||||
allDerivedClasses =
|
||||
decl.derive
|
||||
|> map (class: typeSig class ++ class.${ntTrapdoorKey}.derive);
|
||||
|
|
|
|||
|
|
@ -12,25 +12,25 @@
|
|||
isTypeSig
|
||||
;
|
||||
in rec {
|
||||
enfType = msg: type: value: let
|
||||
enfType = type: value: msg: let
|
||||
got = typeOf value;
|
||||
in
|
||||
got == type || throw "${msg}: expected primitive nix type \"${type}\" but got \"${got}\"";
|
||||
|
||||
# NOTE: doesn't check if xs is type set, use enfHasAttr instead
|
||||
enfHasAttr' = msg: name: xs:
|
||||
enfHasAttr' = name: xs: msg:
|
||||
hasAttr name xs || throw "${msg}: missing required attribute \"${name}\"";
|
||||
|
||||
# NOTE: use enfHasAttr' if you can guarantee xs is type set
|
||||
enfHasAttr = msg: name: xs:
|
||||
enfHasAttr = name: xs: msg:
|
||||
enfType "set" xs msg && enfHasAttr' name xs msg;
|
||||
|
||||
enfIsClassSig = msg: sig:
|
||||
enfIsClassSig = sig: msg:
|
||||
isClassSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Typeclass signature";
|
||||
|
||||
enfTypeSig = msg: sig:
|
||||
enfTypeSig = sig: msg:
|
||||
isTypeSig sig || throw "${msg}: given value \"${toString sig}\" of primitive nix type \"${typeOf sig}\" is not a valid Type signature";
|
||||
|
||||
enfIsNT = msg: T:
|
||||
enfIsNT = T: msg:
|
||||
isNT T || throw "${msg}: expected nt compatible type but got \"${toString T}\" of primitive nix type \"${typeOf T}\"";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ in rec {
|
|||
impls' = type: T: elem (toTypeSig type) T.${ntTrapdoorKey}.derive;
|
||||
|
||||
# NOTE safe variant, use impls' if you can guarantee `isNT T` holds
|
||||
impls = type: T: assert enfIsNT "nt.impls" T; impls' type T;
|
||||
impls = type: T: assert enfIsNT T "nt.impls"; impls' type T;
|
||||
|
||||
# check if a type/class implements a signature
|
||||
# NOTE: unsafe variant, use `is` if you can't guarantee `isNT T` holds
|
||||
is' = type: T: T.${ntTrapdoorKey}.sig == toTypeSig type;
|
||||
|
||||
# NOTE safe variant, use `is'` if you can guarantee `isNT T` holds
|
||||
is = type: T: assert enfIsNT "nt.is" T; is' type T;
|
||||
is = type: T: assert enfIsNT T "nt.is"; is' type T;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ in rec {
|
|||
typeSig' = T: T.${ntTrapdoorKey}.sig;
|
||||
|
||||
# NOTE: safe variant, use typeSig' if you can guarantee `isNT T` holds
|
||||
typeSig = T: assert enfIsNT "nt.typeSig" T; typeSig' T;
|
||||
typeSig = T: assert enfIsNT T "nt.typeSig"; typeSig' T;
|
||||
|
||||
toTypeSig = x:
|
||||
if isString x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue