dhall-nix-lib/Integer/fromAny.dhall

11 lines
344 B
Text

λ(nix : ../NixPrelude.dhall) →
let Any = ../Any/Type.dhall
let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix
let Misc/throw = ../Misc/throw.dhall nix
in λ(v : Any) →
if nix.builtins.isInt v
then Any/toTypeUnchecked Integer v
else Misc/throw Integer "Failed to coerce object into Integer"