From e97af52bd431396e1ff13f4c8716b3f97a3d33c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Fri, 9 Sep 2022 09:07:20 +0100 Subject: [PATCH] remove imports --- Any/equal.dhall | 9 +-------- Function/fix.dhall | 18 ++++-------------- Function/makeExtensibleWithCustomName.dhall | 2 +- Set/mergeAttrs.dhall | 12 +----------- primops.dhall | 8 +++++++- runtime.nix | 4 ++++ 6 files changed, 18 insertions(+), 35 deletions(-) diff --git a/Any/equal.dhall b/Any/equal.dhall index eb91d35..eb2cf81 100644 --- a/Any/equal.dhall +++ b/Any/equal.dhall @@ -1,8 +1 @@ -λ(nix : ../NixPrelude.dhall) → - let Any = ./Type.dhall - - let Any/toTypeUnchecked = ./toTypeUnchecked.dhall nix - - let eqFile = nix.builtins.toFile "eq.nix" "a: b: a == b" - - in Any/toTypeUnchecked (Any → Any → Bool) (nix.builtins.import eqFile) +λ(nix : ../NixPrelude.dhall) → nix.primops.equal diff --git a/Function/fix.dhall b/Function/fix.dhall index 510577c..413de0b 100644 --- a/Function/fix.dhall +++ b/Function/fix.dhall @@ -1,22 +1,12 @@ λ(nix : ../NixPrelude.dhall) → - let fixSrc = "f: let x = f x; in x" - - let fixSrcp = "f: let x = f x // { __unfix__ = f; }; in x" - - let fixFile = nix.builtins.toFile "fix.nix" fixSrc - - let fixFilep = nix.builtins.toFile "fix.nix" fixSrcp - - let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix + let Set = ../Set/Type.dhall let fix : ∀(t : Type) → (t → t) → t - = λ(t : Type) → - Any/toTypeUnchecked ((t → t) → t) (nix.builtins.import fixFile) + = nix.primops.fix let fixp - : ∀(t : Type) → (t → t) → t - = λ(t : Type) → - Any/toTypeUnchecked ((t → t) → t) (nix.builtins.import fixFilep) + : (Set → Set) → Set + = nix.primops.`fix'` in { fix, fixp } diff --git a/Function/makeExtensibleWithCustomName.dhall b/Function/makeExtensibleWithCustomName.dhall index f2b88b3..a178021 100644 --- a/Function/makeExtensibleWithCustomName.dhall +++ b/Function/makeExtensibleWithCustomName.dhall @@ -7,7 +7,7 @@ let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix - let fixp = (./fix.dhall nix).fixp Set + let fixp = (./fix.dhall nix).fixp let Set/toSet = ../Set/toSet.dhall nix diff --git a/Set/mergeAttrs.dhall b/Set/mergeAttrs.dhall index 09d95ac..14db445 100644 --- a/Set/mergeAttrs.dhall +++ b/Set/mergeAttrs.dhall @@ -1,16 +1,6 @@ λ(nix : ../NixPrelude.dhall) → let Set = ./Type.dhall - let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix - - let mergeAttrFile = "a: b: a // b" - - let mergeAttrs = - Any/toTypeUnchecked - (Set → Set → Set) - ( nix.builtins.import - (nix.builtins.toFile "mergeAttrs.nix" mergeAttrFile) - ) - : Set → Set → Set + let mergeAttrs = nix.primops.mergeAttrs : Set → Set → Set in mergeAttrs diff --git a/primops.dhall b/primops.dhall index 64c0348..19d4848 100644 --- a/primops.dhall +++ b/primops.dhall @@ -1,5 +1,11 @@ let Any = ./Any/Type.dhall -in { toAny : ∀(t : Type) → ∀(v : t) → Any +let Set = ./Set/Type.dhall + +in { equal : Any → Any → Bool + , fix : ∀(t : Type) → (t → t) → t + , `fix'` : (Set → Set) → Set + , 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 79bfe59..e7478e8 100644 --- a/runtime.nix +++ b/runtime.nix @@ -1,5 +1,9 @@ { primops = { + equal = a: b: a == b; + fix = _: f: let x = f x; in x; + fix' = f: let x = f x // { __unfix__ = f; }; in x; + mergeAttrs = a: b: a // b; toAny = _: v: v; toTypeUnchecked = _: v: v; };