allow ignoring additional arguments
This commit is contained in:
parent
e97af52bd4
commit
bc74bc8af5
3 changed files with 8 additions and 2 deletions
|
@ -15,4 +15,4 @@
|
||||||
nativeBuildInputs = [pkgs.dhall-nix];
|
nativeBuildInputs = [pkgs.dhall-nix];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
import "${drv}" (import ./runtime.nix)
|
import "${drv}" (import ./runtime.nix pkgs.lib)
|
||||||
|
|
|
@ -5,6 +5,7 @@ let Set = ./Set/Type.dhall
|
||||||
in { equal : Any → Any → Bool
|
in { equal : Any → Any → Bool
|
||||||
, fix : ∀(t : Type) → (t → t) → t
|
, fix : ∀(t : Type) → (t → t) → t
|
||||||
, `fix'` : (Set → Set) → Set
|
, `fix'` : (Set → Set) → Set
|
||||||
|
, ignoreOtherArgs : ∀(A: Type) → ∀(B: Type) → (A → B) → A → B
|
||||||
, mergeAttrs : Set → Set → Set
|
, mergeAttrs : Set → Set → Set
|
||||||
, toAny : ∀(t : Type) → ∀(v : t) → Any
|
, toAny : ∀(t : Type) → ∀(v : t) → Any
|
||||||
, toTypeUnchecked : ∀(t : Type) → ∀(v : Any) → t
|
, toTypeUnchecked : ∀(t : Type) → ∀(v : Any) → t
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
{
|
lib: {
|
||||||
primops = {
|
primops = {
|
||||||
equal = a: b: a == b;
|
equal = a: b: a == b;
|
||||||
fix = _: f: let x = f x; in x;
|
fix = _: f: let x = f x; in x;
|
||||||
fix' = f: let x = f x // { __unfix__ = f; }; 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;
|
mergeAttrs = a: b: a // b;
|
||||||
toAny = _: v: v;
|
toAny = _: v: v;
|
||||||
toTypeUnchecked = _: v: v;
|
toTypeUnchecked = _: v: v;
|
||||||
|
|
Loading…
Reference in a new issue