typeOf
builtins.typeOf
Primop
Docs pulled from | This Revision | about 4 hours ago
Nix manual
Takes 1 arguments
e
Return a string representing the type of the value e, namely
"int", "bool", "string", "path", "null", "set",
"list", "lambda" or "float".
Noogle detected
Detected Type
typeOf :: a -> String
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_typeOf(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
state.forceValue(*args[0], pos);
switch (args[0]->type()) {
case nInt:
v.mkStringNoCopy("int"_sds);
break;
case nBool:
v.mkStringNoCopy("bool"_sds);
break;
case nString:
v.mkStringNoCopy("string"_sds);
break;
case nPath:
v.mkStringNoCopy("path"_sds);
break;
case nNull:
v.mkStringNoCopy("null"_sds);
break;
case nAttrs:
v.mkStringNoCopy("set"_sds);
break;
case nList:
v.mkStringNoCopy("list"_sds);
break;
case nFunction:
v.mkStringNoCopy("lambda"_sds);
break;
case nExternal:
v.mkString(args[0]->external()->typeOf(), state.mem);
break;
case nFloat:
v.mkStringNoCopy("float"_sds);
break;
case nThunk:
case nFailed:
unreachable();
}
}