Commit a128a3f2 authored by adisbladis's avatar adisbladis
Browse files

lib.isConvertibleToString: Statically compute types list

parent eec92ca9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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.