[Nix-dev] Re: [Nix-commits] SVN commit: nix - 18536 - MarcWeber - nixpkgs/trunk/pkgs/lib
Nicolas Pierron
nicolas.b.pierron at gmail.com
Mon Nov 23 13:37:47 CET 2009
Hi,
On Sun, Nov 22, 2009 at 22:28, Marc Weber <marco-oweber at gmx.de> wrote:
> Modified: nixpkgs/trunk/pkgs/lib/debug.nix
> ===================================================================
> --- nixpkgs/trunk/pkgs/lib/debug.nix 2009-11-22 21:28:28 UTC (rev 18535)
> +++ nixpkgs/trunk/pkgs/lib/debug.nix 2009-11-22 21:28:36 UTC (rev 18536)
> @@ -61,4 +65,47 @@
> then [ { inherit name; expected = test.expected; result = test.expr; } ]
> else [] ) tests));
>
> +
> +
> + # evaluate everything once so that errors will occur earlier
> + # hacky: traverse attrs by adding a dummy
> + # ignores functions (should this behavior change?) See strictf
> + #
> + # Note: This should be a primop! Something like seq of haskell would be nice to
> + # have as well. It's used fore debugging only anyway
I agree, this should be a prim-op which returns the result of the
evaluate expression. By the way I don't think this would be too
difficult to add because there is already a "strictEvalExpr" function
which does the job.
The best should be to ask the opinion of Eelco because he has already
made some test on that.
> + strict = x :
> + let
> + traverse = x :
> + if isString x then true
> + else if isAttrs x then
> + if x ? outPath then true
> + else all id (mapAttrsFlatten (n: traverse) x)
> + else if isList x then
> + all id (map traverse x)
> + else if isBool x then true
> + else if isFunction x then true
> + else if isInt x then true
> + else if x == null then true
> + else true; # a (store) path?
> + in if (traverse x) then x else throw "else never reached";
I have another implementation of such function:
strict = x:
let r = builtins.tryEval (builtins.toXML x); in
assert r.success; x
I prefer this implementation because I don't like the strictness of
the isType functions.
--
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
Albert Einstein - Never memorize what you can look up on books.
More information about the nix-dev
mailing list