natural-numbers- Natural numbers

Safe HaskellSafe-Infered



Provides a type for natural numbers.



data Natural Source

The type of natural numbers.

Note that matching a natural number against a negative pattern might not work as you expect. For example, evaluating the following expression results in a run-time error, instead of the result "plus five":

case 5 :: Natural of
    -5 -> "minus five"
     5 -> "plus five"

The reason is that the == operator of Natural is used for checking if the patterns match, making it necessary to convert -5 to Natural.