2 situations where you use these operations instead of the ones in InNat:
Your value is of type Nat (Min ...)
nat3 |> NNat.toIn
|> InNat.mul (nat3 |> NNat.toIn)
--> Nat (Min Nat3)The maximum isn't fixed
divideBy : Nat (In (Nat1Plus minMinus1) max) -> --...Is the Nat (Min ...)
equalOrGreater than a Nat or
less?
factorial : MinNat min -> MinNat Nat1
factorial =
MinNat.lowerMin (nat0 |> NNat.toIn)
>> MinNat.isAtLeast (nat1 |> NNat.toIn)
{ min = nat0 }
{ less = \_ -> nat1 |> NNat.toMin
, equalOrGreater =
\atLeast1 ->
atLeast1
|> MinNat.mul
(factorial
(atLeast1 |> MinNat.subN nat1)
)
}Is the Nat (Min ...)
equalOrLess than a Nat or
greater?
goToU18Party : { age : Nat (In min Nat17) } -> List Snack
tryToGoToU18Party =
MinNat.lowerMin (nat0 |> NNat.toIn)
>> MinNat.isAtMost nat17
{ min = nat0 }
{ equalOrLess = \age -> Just (goToU18Party { age = age })
, greater = Nothing
}Subtract an exact Nat (N ...).
(nat7 |> NNat.toMin)
|> MinNat.subN nat2
--> is of type Nat (Min Nat5)Add a Nat (Min ...). The second argument is the minimum if the added Nat (Min ...).
nat5
|> NNat.toMin
|> MinNat.add atLeast2 nat2
--> is of type Nat (Min Nat7)If you have don't the minimum added value at hand, use InNat.addLossy.
Subtract a Nat (In ...). The second argument is the maximum of the subtracted Nat (In ...).
atLeast6 |> InNat.subLossyMax in0To5 nat5
--> is of type Nat (In Nat1 (Nat6Plus a))If you have don't the maximum subtracted value at hand, use subLossy.
Add a fixed Nat (N ...) value.
nat70
|> NNat.toMin
|> InNat.addN nat7For every other operation, use InNat.
Compare the
Nat (Min ...)to aNat (N ...). Is itgreater,lessorequal?minensures that theNat (N ...)is bigger than the minimum.