mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
lib.isConvertibleToString: Statically compute types list
This commit is contained in:
parent
eec92ca9df
commit
a128a3f234
1 changed files with 4 additions and 2 deletions
|
@ -977,9 +977,11 @@ rec {
|
|||
Many types of value are coercible to string this way, including int, float,
|
||||
null, bool, list of similarly coercible values.
|
||||
*/
|
||||
isConvertibleWithToString = x:
|
||||
isConvertibleWithToString = let
|
||||
types = [ "null" "int" "float" "bool" ];
|
||||
in x:
|
||||
isStringLike x ||
|
||||
elem (typeOf x) [ "null" "int" "float" "bool" ] ||
|
||||
elem (typeOf x) types ||
|
||||
(isList x && lib.all isConvertibleWithToString x);
|
||||
|
||||
/* Check whether a value can be coerced to a string.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue