Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Referential opacity exposed by the module system #217

Closed
shlevy opened this Issue · 0 comments

2 participants

@shlevy
Collaborator
$ cat module.nix 
let
  lib = import <nixpkgs/lib>;
  eval = (lib.evalModules {
    modules = [ ({ options, lib, ... }:
      let
        tr1 = builtins.trace (builtins.typeOf options) null;
        tr2 = builtins.trace (builtins.typeOf options) null;
      in lib.seq tr1 {
        options = {
          foo = lib.seq tr2 {};
        };
      }
    ) ];
  }).options.foo;
in builtins.trace ''
  nix version is ${builtins.nixVersion}
  nixpkgs version is ${lib.nixpkgsVersion}'' (lib.seq eval {})
$ nix-instantiate module.nix 
trace: nix version is 1.7pre3488_36b90e7
nixpkgs version is 14.02pre39778.d5211b0
trace: lambda
trace: set

Note that the last two traces should be identical.

@edolstra edolstra self-assigned this
@edolstra edolstra closed this issue from a commit
@edolstra edolstra Correctly detect infinite recursion in function application
If we're evaluating some application ‘v = f x’, we can't store ‘f’
temporarily in ‘v’, because if ‘f x’ refers to ‘v’, it will get ‘f’
rather than an infinite recursion error.

Unfortunately, this breaks the tail call optimisation introduced in
c897bac.

Fixes #217.
c9f6232
@edolstra edolstra closed this in c9f6232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.