lib.path.append: Add a law

With removePrefix introduced in a future commit this law can then be
used to derive

        removePrefix p (append p s) == subpath.normalise s
        => (wrap with append)
        append p (removePrefix p (append p s)) == append p (subpath.normalise s)
        => (append is not influenced by subpath normalisation)
        append p (removePrefix p (append p s)) == append p s
        => (substitute q = append p s)
        append p (removePrefix p q) == q

Not included in the docs because it's not that important, just shows
that the first statement is more general than the second one (because
this derivation doesn't work the other way)
This commit is contained in:
Silvan Mosberger 2023-04-05 20:27:46 +02:00
parent b505951d8a
commit 866f75e5b9

View File

@ -108,6 +108,12 @@ in /* No rec! Add dependencies on this file at the top. */ {
More specifically, it checks that the first argument is a [path value type](https://nixos.org/manual/nix/stable/language/values.html#type-path"),
and that the second argument is a valid subpath string (see `lib.path.subpath.isValid`).
Laws:
- Not influenced by subpath normalisation
append p s == append p (subpath.normalise s)
Type:
append :: Path -> String -> Path