dhall-nix-lib/Function/makeExtensibleWithCustomName.dhall

52 lines
1.5 KiB
Text
Raw Permalink Normal View History

2022-09-09 07:23:27 +00:00
λ(nix : ../NixPrelude.dhall) →
let Any = ../Any/Type.dhall
let Set = ../Set/Type.dhall
let Any/toAny = ../Any/toAny.dhall nix
let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix
2022-09-09 08:07:20 +00:00
let fixp = (./fix.dhall nix).fixp
2022-09-09 07:23:27 +00:00
let Set/toSet = ../Set/toSet.dhall nix
let Set/mergeAttrs = ../Set/mergeAttrs.dhall nix
let extends = ./extends.dhall nix
let FunctionType = λ(x : Type) → x → Text → (Set → Set) → Set
let function =
λ(function : FunctionType Any) →
let functionArgs =
Any/toTypeUnchecked
(FunctionType (FunctionType Any))
(Any/toAny (FunctionType Any) function)
function
in λ(extenderName : Text) →
λ(rattrs : Set → Set) →
let extset =
Set/toSet
((Set → Set → Set) → Set)
[ { mapKey = extenderName
, mapValue =
λ(f : Set → Set → Set) →
functionArgs extenderName (extends f rattrs)
}
]
in Set/mergeAttrs (fixp rattrs) extset
let functionErased =
Any/toTypeUnchecked
(FunctionType Any)
(Any/toAny (FunctionType (FunctionType Any)) function)
let makeExtensibleWithCustomName
: Text → (Set → Set) → Set
= function functionErased
in makeExtensibleWithCustomName