packages feed

dhall-1.28.0: dhall-lang/Prelude/Integer/toNatural

{-
Convert an `Integer` to an `Optional Natural`, with negative numbers becoming `None Natural`.
-}
let Integer/lessThan =
        ./lessThan sha256:14cc3bc6ca8757f7c3af338f079fcc18e0c7ee3ed0d20914a9693aec81ae628d
      ? ./lessThan

let toNatural
    : Integer → Optional Natural
    =   λ(n : Integer)
      → if Integer/lessThan n +0 then None Natural else Some (Integer/clamp n)

let example0 = assert : toNatural +7 ≡ Some 7

let example2 = assert : toNatural +0 ≡ Some 0

let example3 = assert : toNatural -3 ≡ None Natural

in  toNatural