diff --git a/dhallToNix.nix b/dhallToNix.nix index 384017a..fe98fa2 100644 --- a/dhallToNix.nix +++ b/dhallToNix.nix @@ -15,4 +15,4 @@ nativeBuildInputs = [pkgs.dhall-nix]; }; in - import "${drv}" (import ./runtime.nix) + import "${drv}" (import ./runtime.nix pkgs.lib) diff --git a/primops.dhall b/primops.dhall index 19d4848..247bfeb 100644 --- a/primops.dhall +++ b/primops.dhall @@ -5,6 +5,7 @@ let Set = ./Set/Type.dhall in { equal : Any → Any → Bool , fix : ∀(t : Type) → (t → t) → t , `fix'` : (Set → Set) → Set + , ignoreOtherArgs : ∀(A: Type) → ∀(B: Type) → (A → B) → A → B , mergeAttrs : Set → Set → Set , toAny : ∀(t : Type) → ∀(v : t) → Any , toTypeUnchecked : ∀(t : Type) → ∀(v : Any) → t diff --git a/runtime.nix b/runtime.nix index e7478e8..580efb9 100644 --- a/runtime.nix +++ b/runtime.nix @@ -1,8 +1,13 @@ -{ +lib: { primops = { equal = a: b: a == b; fix = _: f: let x = f x; in x; fix' = f: let x = f x // { __unfix__ = f; }; in x; + ignoreOtherArgs = _: _: f: let + args = lib.trivial.functionArgs f; + filterFunction = k: _: builtins.hasAttrs k set; + filteredFunction = s: f (lib.attrsets.filterAttrs filterFunction s); + in lib.trivial.setFunctionArgs filteredFunction args; mergeAttrs = a: b: a // b; toAny = _: v: v; toTypeUnchecked = _: v: v;