From 8233d4aedf655019192538ee3e8a81e663673d30 Mon Sep 17 00:00:00 2001 From: Alex Kladov Date: Sun, 23 Jun 2024 18:39:30 +0000 Subject: [PATCH] use correct name for topological sort (#5) I am 0.8 sure this is a typo, I've never seen this being referred to as topographic sorting! Reviewed-on: https://git.auxolotl.org/auxolotl/labs/pulls/5 Reviewed-by: Jake Hamilton Co-authored-by: Alex Kladov Co-committed-by: Alex Kladov --- lib/src/dag/default.nix | 4 ++-- lib/src/dag/default.test.nix | 6 +++--- lib/src/lists/default.nix | 6 +++--- tidepool/src/builders/basic.nix | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/dag/default.nix b/lib/src/dag/default.nix index 608b46d..493ef20 100644 --- a/lib/src/dag/default.nix +++ b/lib/src/dag/default.nix @@ -21,7 +21,7 @@ lib: { ## Apply a topological sort to a DAG. ## ## @type Dag a -> { result :: List a } | { cycle :: List a, loops :: List a } - topographic = + topological = graph: let getEntriesBefore = @@ -43,7 +43,7 @@ lib: { isBefore = a: b: builtins.elem a.name b.after; - sorted = lib.lists.sort.topographic isBefore entries; + sorted = lib.lists.sort.topological isBefore entries; in if sorted ? result then { diff --git a/lib/src/dag/default.test.nix b/lib/src/dag/default.test.nix index a7702b0..5c13cd9 100644 --- a/lib/src/dag/default.test.nix +++ b/lib/src/dag/default.test.nix @@ -119,11 +119,11 @@ in }; "sort" = { - "topographic" = { + "topological" = { "handles an empty graph" = let expected = [ ]; - actual = lib.dag.sort.topographic { }; + actual = lib.dag.sort.topological { }; in actual.result == expected; @@ -147,7 +147,7 @@ in value = "d"; } ]; - actual = lib.dag.sort.topographic { + actual = lib.dag.sort.topological { a = lib.dag.entry.anywhere "a"; b = lib.dag.entry.between [ "c" ] [ "a" ] "b"; c = lib.dag.entry.before [ "c" ] "c"; diff --git a/lib/src/lists/default.nix b/lib/src/lists/default.nix index e449a65..b8cca9b 100644 --- a/lib/src/lists/default.nix +++ b/lib/src/lists/default.nix @@ -31,15 +31,15 @@ lib: { in builtins.map (x: builtins.elemAt x 1) (builtins.sort isLess prepared); - ## Perform a topographic sort on a list of items. The predicate function determines whether + ## Perform a topological sort on a list of items. The predicate function determines whether ## its first argument comes before the second argument. ## ## @type (a -> a -> Bool) -> List a -> List a - topographic = + topological = predicate: list: let searched = lib.lists.search.depthFirst true predicate list; - results = lib.lists.sort.topographic predicate (searched.visited ++ searched.rest); + results = lib.lists.sort.topological predicate (searched.visited ++ searched.rest); in if builtins.length list < 2 then { result = list; } diff --git a/tidepool/src/builders/basic.nix b/tidepool/src/builders/basic.nix index 125ff64..1864fb9 100644 --- a/tidepool/src/builders/basic.nix +++ b/tidepool/src/builders/basic.nix @@ -15,7 +15,7 @@ in package: let phases = package.phases; - sorted = lib.dag.sort.topographic phases; + sorted = lib.dag.sort.topological phases; script = lib.strings.concatMapSep "\n" ( entry: if builtins.isFunction entry.value then entry.value package else entry.value