55 lines
1.8 KiB
Text
55 lines
1.8 KiB
Text
λ(nix : ../NixPrelude.dhall) →
|
|
let Any = ../Any/Type.dhall
|
|
|
|
let Set = ../Set/Type.dhall
|
|
|
|
let Optional/fold =
|
|
https://raw.githubusercontent.com/dhall-lang/dhall-lang/v22.0.0/Prelude/Optional/fold.dhall
|
|
sha256:c5b9d72f6f62bdaa0e196ac1c742cc175cd67a717b880fb8aec1333a5a4132cf
|
|
|
|
let Any/toAny = ../Any/toAny.dhall nix
|
|
|
|
let Any/hasAttr = ../Any/hasAttr.dhall nix
|
|
|
|
let Any/select = ../Any/select.dhall nix
|
|
|
|
let Any/selectOptional = ../Any/selectOptional.dhall nix
|
|
|
|
let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix
|
|
|
|
let FunctionType = λ(x : Type) → x → ∀(a : Type) → ∀(b : Type) → (a → b) → Set
|
|
|
|
let function =
|
|
λ(function : FunctionType Any) →
|
|
let functionArgs =
|
|
Any/toTypeUnchecked
|
|
(FunctionType (FunctionType Any))
|
|
(Any/toAny (FunctionType Any) function)
|
|
function
|
|
|
|
in λ(a : Type) →
|
|
λ(b : Type) →
|
|
λ(f : a → b) →
|
|
let fAny = Any/toAny (a → b) f
|
|
|
|
let functor =
|
|
Any/toTypeUnchecked (a → b) (Any/select fAny "__functor")
|
|
|
|
let functorArg =
|
|
Optional/fold
|
|
Any
|
|
(Any/selectOptional fAny "__functionArgs")
|
|
Set
|
|
(Any/toTypeUnchecked Set)
|
|
(functionArgs a b functor)
|
|
|
|
in if Any/hasAttr fAny "__functor"
|
|
then functorArg
|
|
else nix.builtins.functionArgs (Any/toAny (a → b) f)
|
|
|
|
let functionErased =
|
|
Any/toTypeUnchecked
|
|
(FunctionType Any)
|
|
(Any/toAny (FunctionType (FunctionType Any)) function)
|
|
|
|
in function functionErased
|