nix-helpers: c73eb24132a53ff3e7842c0c42e6c34c78c7bdfd
1: { bash, dummyBuild, getType, hello, lib }:
2:
3: with builtins;
4: with lib;
5: with rec {
6: basic = x: y: if x < y then -1 else if y < x then 1 else 0;
7: funcs = {
8: callable = _: _: trace "Warning: Can't compare functions, assuming equal" 0;
9: derivation = funcs.set;
10: int = basic;
11: list = compareLists go;
12: null = _: _: 0;
13: set = x: y:
14: with rec {
15: nX = sort (x: y: basic x y == -1) (attrNames x);
16: nY = sort (x: y: basic x y == -1) (attrNames y);
17: ns = go nX nY;
18: };
19: # Compare attr names first; if they differ, return that result.
20: if ns != 0 then
21: ns
22: # If names match, check each one in order.
23: else
24: fold (n: old:
25: if old != 0 then
26: old # Propagate prior answer if we have one
27: else
28: go (getAttr n x) (getAttr n y)) # Recurse
29: 0 nX;
30: string = basic;
31: };
32:
33: # Recursive comparison function. If arg types match, look up comparison func.
34: go = x: y:
35: if getType x == getType y then
36: getAttr (getType x) funcs x y
37: # If types are different, compare the type strings instead.
38: else
39: getType x < getType y;
40: };
41: go
Generated by git2html.