| ... | @@ -9,6 +9,14 @@ A lot of common functions do recursion over the natural numbers. But Haskell do |
... | @@ -9,6 +9,14 @@ A lot of common functions do recursion over the natural numbers. But Haskell do |
|
|
So, let's add a Natural number type. Ideally, we should also restrict the interpretation of literal numeric patterns to values of Natural, so that any unintentional use of features belonging to other numeric types can be flagged as a static error.
|
|
So, let's add a Natural number type. Ideally, we should also restrict the interpretation of literal numeric patterns to values of Natural, so that any unintentional use of features belonging to other numeric types can be flagged as a static error.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Such a type could be presented as an optimized equivalent of an ordinary algebraic data type:
|
|
|
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
data Natural = Zero | Succ !Natural
|
|
|
|
```
|
|
|
|
|
|
|
## Examples
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
|
| ... | | ... | |