-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inclusion is like importing, except that all variables that in scope at the 'include' site are in scope of the included file. Thus, if ./foo.nix contains 'x', then let x = 1; in include ./foo.nix evaluates to 1. (Note that 'include' has to be a keyword, not a builtin function, because inclusion takes place within a specific scope. I.e. 'include ./foo.nix' would not be equivalent to 'let f = include; in ... f ./foo.nix ...'.)
- Loading branch information
Showing
10 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
assert include ./include-1.nix == 1; | ||
assert let x = 100; in include ./include-1.nix == 1; | ||
assert with { x = 123; }; include ./include-1.nix == 1; | ||
|
||
assert let x = 2; in include ./include-2.nix == 3; | ||
assert let x = 3; in include ./include-2.nix == 4; | ||
assert let x = 3; in let x = 4; in include ./include-2.nix == 5; | ||
assert let x = 3; in let x = 4; in include ./include-2.nix == 5; | ||
assert let x = 6; in with { x = 7; }; include ./include-2.nix == 7; | ||
assert with { x = 0; }; let x = 6; in with { x = 7; }; include ./include-2.nix == 7; | ||
assert with { x = 0; }; let x = 6; in with { x = 7; }; let x = 7; in include ./include-2.nix == 8; | ||
assert with { x = 8; }; include ./include-2.nix == 9; | ||
|
||
assert (let x = 10; in include ./include-3.nix) == 3628800; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let x = 1; in x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 + x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
if x > 0 then x * (let x_ = x; in let x = x_ - 1; in include ./include-3.nix) else 1 |