lib/strings: add concatLines

Like `unlines` from Haskell.

The aim is to replace the `concatStringsSep "\n"` pattern for generated
files, which doesn't add a final newline.
This commit is contained in:
Naïm Favier
2022-12-10 15:56:30 +01:00
parent f8fc2323e9
commit ed0b8c26f1
3 changed files with 17 additions and 1 deletions

View File

@@ -127,6 +127,17 @@ rec {
# List of input strings
list: concatStringsSep sep (lib.imap1 f list);
/* Concatenate a list of strings, adding a newline at the end of each one.
Defined as `concatMapStrings (s: s + "\n")`.
Type: concatLines :: [string] -> string
Example:
concatLines [ "foo" "bar" ]
=> "foo\nbar\n"
*/
concatLines = concatMapStrings (s: s + "\n");
/* Construct a Unix-style, colon-separated search path consisting of
the given `subDir` appended to each of the given paths.