Is nickel evaluation lazy? #852
-
A question I could not find answered in the README: Is nickel evaluation lazy, that is will it only evaluate the minimal subset of the configuration that needs to be evaluated? This has multiple dimensions:
I’m asking because in practice, any nontrivial e.g. kubernetes config will depend on thousands of definition files, yet e.g. a single service will only need a tiny subset to be instantiated. Even in nixpkgs we have some problems when it comes to NixOS configs, even though the language implementation is lazy in theory (yet the module option merging implementation in practice is not). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Those are interesting questions, because lazyness indeed comes in many different flavours and definitions. Nickel is lazy in the usual PLT sense, in that the evaluation is call-by-need, as in Haskell and Nix. If you only need one subfield of a huge configuration, you will only evaluate this field. Let me try to address your other questions:
Summing up, the evaluation of model of Nickel seems to tick your boxes with respect to laziness, at the exception of imports. But the latter is not totally inevitable, as the typechecking model doesn't require to process imports (such as performing type inference) and relies on a form of external interface declaration: it's just that this interface is currently just a top-level annotation, which is a bit clunky to separate from the rest of the code. |
Beta Was this translation helpful? Give feedback.
Those are interesting questions, because lazyness indeed comes in many different flavours and definitions.
Nickel is lazy in the usual PLT sense, in that the evaluation is call-by-need, as in Haskell and Nix. If you only need one subfield of a huge configuration, you will only evaluate this field. Let me try to address your other questions:
Currently, not entirely, because Nickel needs to peek at the top-level annotation of an import to get its type. Because there is currently no notion of module and interface, if you do
and use it at some point in a statically typed context, you need to know the type of
mylib
. How it is currently done is that all import…