1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/positive
Paul Cadman ea09ec3068
Add builtin integer type to the surface language (#1948)
This PR adds a builtin integer type to the surface language that is
compiled to the backend integer type.

## Inductive definition

The `Int` type is defined in the standard library as:

```
builtin int
type Int :=
  | --- ofNat n represents the integer n
    ofNat : Nat -> Int
  | --- negSuc n represents the integer -(n + 1)
    negSuc : Nat -> Int;
```

## New builtin functions defined in the standard library

```
intToString : Int -> String;
+ : Int -> Int -> Int;
neg : Int -> Int;
* : Int -> Int -> Int;
- : Int -> Int -> Int;
div : Int -> Int -> Int;
mod : Int -> Int -> Int;

== : Int -> Int -> Bool;
<= : Int -> Int -> Bool;
< : Int -> Int -> Bool;
```

Additional builtins required in the definition of the other builtins:

```
negNat : Nat -> Int;
intSubNat : Nat -> Nat -> Int;
nonNeg : Int -> Bool;
```

## REPL types of literals

In the REPL, non-negative integer literals have the inferred type `Nat`,
negative integer literals have the inferred type `Int`.

```
Stdlib.Prelude> :t 1
Nat
Stdlib.Prelude> :t -1
Int
:t let x : Int := 1 in x
Int
```

## The standard library Prelude

The definitions of `*`, `+`, `div` and `mod` are not exported from the
standard library prelude as these would conflict with the definitions
from `Stdlib.Data.Nat`.

Stdlib.Prelude
```
open import Stdlib.Data.Int hiding {+;*;div;mod} public;
```

* Closes https://github.com/anoma/juvix/issues/1679
* Closes https://github.com/anoma/juvix/issues/1984

---------

Co-authored-by: Lukasz Czajka <lukasz@heliax.dev>
2023-04-13 08:16:49 +01:00
..
265 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
272 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
BuiltinsMultiImport Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
BuiltinsMultiOpenImport Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Dependencies Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Imports Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
ImportShadow Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Internal Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
issue1333 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
issue1466 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
issue1693 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
issue1731 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
issue1879 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
QualifiedConstructor Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
QualifiedSymbol Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
QualifiedSymbol2 Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Reachability Add builtin integer type to the surface language (#1948) 2023-04-13 08:16:49 +01:00
StdlibImport Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
StdlibList Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Termination Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Ape.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Axiom.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Builtins.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
BuiltinsBool.juvix Fix: pprint positive kw for data types (#1980) 2023-04-05 16:40:46 +02:00
Format.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Inductive.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
InductivePipes.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Judoc.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
juvix.yaml Rename MiniJuvix to Juvix (#259) 2022-07-08 13:59:45 +02:00
LetShadow.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Literals.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
MultiParams.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
MutualLet.juvix Automatically detect and split mutually recursive blocks in let expressions (#1894) 2023-03-17 11:05:55 +00:00
Operators.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
Parsing.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Polymorphism.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
PolymorphismHoles.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
ShadowPublicOpen.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
SignatureWithBody.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Symbols.juvix Fix: format juvix files in test/positive (#1978) 2023-04-12 10:07:01 +02:00
TypeAlias.juvix Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00