From e5c8479a8f130560c2b23f34db0367e6b952f595 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 27 Jan 2026 08:35:55 +1000 Subject: [PATCH] update inherit paths --- nt/mix/default.nix | 12 +++++++++-- nt/primitives/bootstrap/default.nix | 2 ++ nt/primitives/bootstrap/nt.nix | 2 +- nt/primitives/bootstrap/parse/parse.nix | 5 +++++ nt/primitives/bootstrap/std/attrs.nix | 8 ++++++- nt/primitives/bootstrap/std/bootstrap.nix | 21 ++++++++++-------- nt/primitives/bootstrap/types/maybe.nix | 26 +++++++++++++++-------- nt/primitives/bootstrap/types/null.nix | 13 +++++++----- nt/primitives/bootstrap/types/wrap.nix | 16 ++++++++------ nt/primitives/nt.nix | 20 +++++++++++++---- 10 files changed, 88 insertions(+), 37 deletions(-) diff --git a/nt/mix/default.nix b/nt/mix/default.nix index 9f35f16..61fb95f 100644 --- a/nt/mix/default.nix +++ b/nt/mix/default.nix @@ -9,13 +9,21 @@ ; inherit - (this.util) + (this.std) filterAttrs hasInfix mergeAttrsList nameValuePair - projectOnto removeSuffix + ; + + inherit + (this.parse) + projectOnto + ; + + inherit + (this.types) Wrap ; diff --git a/nt/primitives/bootstrap/default.nix b/nt/primitives/bootstrap/default.nix index 6fdc608..e78a733 100644 --- a/nt/primitives/bootstrap/default.nix +++ b/nt/primitives/bootstrap/default.nix @@ -29,10 +29,12 @@ let delegate; this = bootstrap {inherit this bootstrap;} [ + ./nt.nix { std = ./std/bootstrap.nix; types = ./types/bootstrap.nix; parse = ./parse/bootstrap.nix; + trapdoor = ./trapdoor.nix; } ]; in diff --git a/nt/primitives/bootstrap/nt.nix b/nt/primitives/bootstrap/nt.nix index 7462a06..ef91d19 100644 --- a/nt/primitives/bootstrap/nt.nix +++ b/nt/primitives/bootstrap/nt.nix @@ -10,7 +10,7 @@ ; inherit - (this) + (this.trapdoor) mkTrapdoorKey openTrapdoor ; diff --git a/nt/primitives/bootstrap/parse/parse.nix b/nt/primitives/bootstrap/parse/parse.nix index f63eada..881c53a 100644 --- a/nt/primitives/bootstrap/parse/parse.nix +++ b/nt/primitives/bootstrap/parse/parse.nix @@ -16,6 +16,11 @@ (this.std) enfIsAttrs ; + + inherit + (this.types) + Wrap + ; in rec { # form: getAttrAt :: list string -> set -> null | Wrap Any # given path as a list of strings, return that value of an diff --git a/nt/primitives/bootstrap/std/attrs.nix b/nt/primitives/bootstrap/std/attrs.nix index ab58037..939d682 100644 --- a/nt/primitives/bootstrap/std/attrs.nix +++ b/nt/primitives/bootstrap/std/attrs.nix @@ -1,4 +1,4 @@ -{...}: let +{this, ...}: let inherit (builtins) attrNames @@ -14,6 +14,12 @@ tail typeOf ; + + inherit + (this) + flipCurry + id + ; in rec { enfIsAttrs = value: msg: let got = typeOf value; diff --git a/nt/primitives/bootstrap/std/bootstrap.nix b/nt/primitives/bootstrap/std/bootstrap.nix index 4e8b06e..5c5875e 100644 --- a/nt/primitives/bootstrap/std/bootstrap.nix +++ b/nt/primitives/bootstrap/std/bootstrap.nix @@ -1,11 +1,14 @@ # WARNING: /nt/primitives/bootstrap cannot depend on mix # WARNING: this file is strictly for bootstrapping nt -{bootstrap, ...} @ inputs: -bootstrap inputs [ - ./attrs.nix - ./enforce.nix - ./fn.nix - ./list.nix - ./num.nix - ./string.nix -] +{bootstrap, ...}: let + # WARNING: do not propagate `this` from parent, bootstrap/std must + # WARNING: remain entirely independent from bootstrap + this = bootstrap {inherit this bootstrap;} [ + ./attrs.nix + ./fn.nix + ./list.nix + ./num.nix + ./string.nix + ]; +in + this diff --git a/nt/primitives/bootstrap/types/maybe.nix b/nt/primitives/bootstrap/types/maybe.nix index ebba469..8ab36b1 100644 --- a/nt/primitives/bootstrap/types/maybe.nix +++ b/nt/primitives/bootstrap/types/maybe.nix @@ -1,13 +1,21 @@ {this, ...}: let - # inherit - # (this) - # enfImpls - # mkTrapdoorFn - # mkTrapdoorSet - # ntTrapdoorKey - # ntDynamicTrapdoorKey - # openTrapdoor - # ; + inherit + (this) + ntTrapdoorKey + ntDynamicTrapdoorKey + ; + + inherit + (this.std) + enfImpls + ; + + inherit + (this.trapdoor) + mkTrapdoorFn + mkTrapdoorSet + openTrapdoor + ; in { # NOTE: Maybe is used to simplify parsing Type/Class declarations # NOTE: and therefore must be implemented manually diff --git a/nt/primitives/bootstrap/types/null.nix b/nt/primitives/bootstrap/types/null.nix index 399c3d6..05c250f 100644 --- a/nt/primitives/bootstrap/types/null.nix +++ b/nt/primitives/bootstrap/types/null.nix @@ -1,10 +1,13 @@ # XXX: TODO: replace Null with the naive Maybe type {this, ...}: let - # inherit - # (this) - # ntTrapdoorKey - # mkTrapdoorSet - # ; + inherit + (this) + ntTrapdoorKey + ; + inherit + (this.trapdoor) + mkTrapdoorSet + ; in { # NOTE: This is not good for writing type safe code # NOTE: it is however efficient for bootstrapping the primitives diff --git a/nt/primitives/bootstrap/types/wrap.nix b/nt/primitives/bootstrap/types/wrap.nix index 55a218e..e601933 100644 --- a/nt/primitives/bootstrap/types/wrap.nix +++ b/nt/primitives/bootstrap/types/wrap.nix @@ -1,10 +1,14 @@ {this, ...}: let - # inherit - # (this) - # ntTrapdoorKey - # mkTrapdoorFn - # mkTrapdoorSet - # ; + inherit + (this) + ntTrapdoorKey + ; + + inherit + (this.trapdoor) + mkTrapdoorFn + mkTrapdoorSet + ; in { # NOTE: Wrap is used to simplify parsing Type/Class declarations # NOTE: and therefore must be implemented manually diff --git a/nt/primitives/nt.nix b/nt/primitives/nt.nix index de48737..cf249e9 100644 --- a/nt/primitives/nt.nix +++ b/nt/primitives/nt.nix @@ -8,17 +8,29 @@ ; inherit - (this.util) + (this) enfIsType - enfIsClassSig + typeSig + ; + + inherit + (this.std) flipCurry + removeAttrsRec + ; + + inherit + (this.parse) + enfIsClassSig hasAttrAt mkTrapdoorSet ntTrapdoorKey parseClassSig projectOnto - removeAttrsRec - typeSig + ; + + inherit + (this.types) Wrap ;