* Realisation of File(...) expressions.

This commit is contained in:
Eelco Dolstra 2003-06-27 13:55:12 +00:00
parent bb03c45ca0
commit 3da9687854
11 changed files with 137 additions and 368 deletions

View file

@ -10,14 +10,12 @@ extern "C" {
using namespace std;
/* \section{Abstract syntax of Nix expressions}
/* \section{Abstract syntax of Nix file system state expressions}
An expression describes a (partial) state of the file system in a
referentially transparent way. The operational effect of
evaluating an expression is that the state described by the
expression is realised.
A Nix file system state expression, or FState, describes a
(partial) state of the file system.
File : Path * Content * [Expr] -> Expr
File : Path * Content * [FState] -> FState
File(path, content, refs) specifies a file object (its full path
and contents), along with all file objects referenced by it (that
@ -25,7 +23,7 @@ using namespace std;
self-referential. This prevents us from having to deal with
cycles.
Derive : String * Path * [Expr] * [Expr] * [Expr] -> Expr
Derive : String * Path * [FState] * [Path] * [(String, String)] -> [FState]
Derive(platform, builder, ins, outs, env) specifies the creation of
new file objects (in paths declared by `outs') by the execution of
@ -33,14 +31,6 @@ using namespace std;
place in a file system state given by `ins'. `env' specifies a
mapping of strings to strings.
Str : String -> Expr
A string constant.
Tup : Expr * Expr -> Expr
Tuples of expressions.
[ !!! NOT IMPLEMENTED
Regular : String -> Content
Directory : [(String, Content)] -> Content
@ -49,7 +39,11 @@ using namespace std;
CHash : Hash -> Content
File content, given either in situ, or through an external reference
to the file system or url-space decorated with a hash to preserve purity.
to the file system or url-space decorated with a hash to preserve
purity.
A FState expression is in {\em $f$-normal form} if all Derive nodes
have been reduced to File nodes.
DISCUSSION: the idea is that a Regular/Directory is interchangeable
with its CHash. This would appear to break referential
@ -60,63 +54,20 @@ using namespace std;
CHash, we should also export the file object referenced by that
CHash.
\section{Reduction rules}
...
\section{Normals forms}
An expression is in {\em weak head normal form} if it is a lambda,
a string or boolean value, or a File or Derive value.
An expression is in {\em $d$-normal form} if it matches the
signature FExpr:
File : String * Content * [DExpr] -> DExpr
Derive : String * Path * [Tup] * [Tup2] -> DExpr
Tup : Str * DExpr -> Tup
Tup : Str * Str -> Tup
Tup : Str * Str -> Tup2
Str : String -> Str
These are Nix expressions in which the file system result of Derive
expressions has not yet been computed. This is useful for, e.g.,
querying dependencies.
An expression is in {\em $f$-normal form} if it matches the
signature FExpr:
File : String * Content * [FExpr] -> FExpr
These are completely evaluated Nix expressions.
*/
typedef ATerm Expr;
typedef ATerm FState;
typedef ATerm Content;
/* Expression normalisation. */
Expr whNormalise(Expr e);
Expr dNormalise(Expr e);
Expr fNormalise(Expr e);
/* Realise a $f$-normalised expression in the file system. */
void realise(Expr e);
void realiseFState(FState fs);
/* Return a canonical textual representation of an expression. */
string printExpr(Expr e);
string printTerm(ATerm t);
/* Perform variable substitution. */
Expr substExpr(string x, Expr rep, Expr e);
/* Hash an expression. */
Hash hashExpr(Expr e);
/* Hash an aterm. */
Hash hashTerm(ATerm t);
#endif /* !__EVAL_H */