diff options
author | tv <tv@shackspace.de> | 2015-03-05 13:01:05 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-05-19 23:10:57 +0200 |
commit | f93ca99fab906b6d2b83dc3b4c9410da7c29bdde (patch) | |
tree | e34e330c04beb0822d59da3f43b0a1e32c06b582 /lib |
initial commit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 000000000..c1663a7b8 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,44 @@ +{ pkgs, ... }: + +with builtins; + +let + inherit (pkgs.lib) stringAsChars; +in + +{ + + + # "7.4.335" -> "74" + majmin = with pkgs.lib; x : concatStrings (take 2 (splitString "." x)); + + + concat = xs : + if xs == [] + then "" + else head xs + concat (tail xs) + ; + + flip = f : x : y : f y x; + + # isSuffixOf :: String -> String -> Bool + isSuffixOf = + s : xs : + let + sn = stringLength s; + xsn = stringLength xs; + in + xsn >= sn && substring (xsn - sn) sn xs == s ; + + removeSuffix = + s : xs : substring 0 (stringLength xs - stringLength s) xs; + + # setMap :: (String -> a -> b) -> Set String a -> [b] + #setMap = f: xs: map (k : f k (getAttr k xs)) (attrNames xs); + + # setToList :: Set k a -> [a] + #setToList = setMap (_: v: v); + + shell-escape = + stringAsChars (c: if c == "\n" then ''"${c}"'' else "\\${c}"); +} |