summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorBas van Dijk <v.dijk.bas@gmail.com>2020-07-20 13:14:19 +0200
committerBas van Dijk <v.dijk.bas@gmail.com>2020-07-20 13:14:19 +0200
commit6e7822b8f3e495e3c2c12b121ca81d8565298589 (patch)
tree895a92f784e3454312a88169f0dbc226df5d4990 /lib
parente15815e885db42e642ed67527df76bbcc35f3e91 (diff)
downloadnixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar.gz
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar.bz2
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar.lz
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar.xz
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.tar.zst
nixpkgs-6e7822b8f3e495e3c2c12b121ca81d8565298589.zip
lib: toHex -> toHexString & toBase -> toBaseDigits
This makes the type of these functions more apparent from the name.
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix2
-rw-r--r--lib/tests/misc.nix8
-rw-r--r--lib/trivial.nix20
3 files changed, 15 insertions, 15 deletions
diff --git a/lib/default.nix b/lib/default.nix
index a5c768ff407..43b9ab5930c 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -67,7 +67,7 @@ let
     inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
       bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
       importJSON warn info showWarnings nixpkgsVersion version mod compare
-      splitByAndCompare functionArgs setFunctionArgs isFunction toHex toBase;
+      splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
     inherit (fixedPoints) fix fix' converge extends composeExtensions
       makeExtensible makeExtensibleWithCustomName;
     inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 7d38b56bc21..b066f577f32 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -102,13 +102,13 @@ runTests {
     expected = 9;
   };
 
-  testToHex = {
-    expr = toHex 250;
+  testToHexString = {
+    expr = toHexString 250;
     expected = "FA";
   };
 
-  testToBase = {
-    expr = toBase 2 6;
+  testToBaseDigits = {
+    expr = toBaseDigits 2 6;
     expected = [ 1 1 0 ];
   };
 
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 1114e94b523..6eb1fb3a5b1 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -336,13 +336,13 @@ rec {
   /* Convert the given positive integer to a string of its hexadecimal
      representation. For example:
 
-     toHex 0 => "0"
+     toHexString 0 => "0"
 
-     toHex 16 => "10"
+     toHexString 16 => "10"
 
-     toHex 250 => "FA"
+     toHexString 250 => "FA"
   */
-  toHex = i:
+  toHexString = i:
     let
       toHexDigit = d:
         if d < 10
@@ -357,18 +357,18 @@ rec {
             "15" = "F";
           }.${toString d};
     in
-      lib.concatMapStrings toHexDigit (toBase 16 i);
+      lib.concatMapStrings toHexDigit (toBaseDigits 16 i);
 
-  /* `toBase base i` converts the positive integer i to a list of its
+  /* `toBaseDigits base i` converts the positive integer i to a list of its
      digits in the given base. For example:
 
-     toBase 10 123 => [ 1 2 3 ]
+     toBaseDigits 10 123 => [ 1 2 3 ]
 
-     toBase 2 6 => [ 1 1 0 ]
+     toBaseDigits 2 6 => [ 1 1 0 ]
 
-     toBase 16 250 => [ 15 10 ]
+     toBaseDigits 16 250 => [ 15 10 ]
   */
-  toBase = base: i:
+  toBaseDigits = base: i:
     let
       go = i:
         if i < base