mirror of
https://github.com/anoma/juvix.git
synced 2024-12-01 00:04:58 +03:00
ea09ec3068
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> |
||
---|---|---|
.. | ||
230 | ||
258 | ||
265 | ||
BindGroupConflict | ||
ImportCycle | ||
Internal | ||
issue1337 | ||
issue1344 | ||
issue1700 | ||
StdlibConflict | ||
Termination | ||
AmbiguousConstructor.juvix | ||
AmbiguousExport.juvix | ||
AmbiguousModule.juvix | ||
AmbiguousSymbol.juvix | ||
AppLeftImplicit.juvix | ||
AsPatternAlias.juvix | ||
ConstructorExpectedLeftApplication.juvix | ||
DuplicateClause.juvix | ||
DuplicateFixity.juvix | ||
DuplicateInductiveParameterName.juvix | ||
ImplicitPatternLeftApplication.juvix | ||
InfixError.juvix | ||
InfixErrorP.juvix | ||
juvix.yaml | ||
LacksFunctionClause.juvix | ||
LacksTypeSig2.juvix | ||
LacksTypeSig.juvix | ||
LetMissingClause.juvix | ||
ModuleNotInScope.juvix | ||
MultipleDeclarations.juvix | ||
MultipleExportConflict.juvix | ||
NestedAsPatterns.juvix | ||
NestedPatternBraces.juvix | ||
NotInScope.juvix | ||
QualSymNotInScope.juvix | ||
Tab.juvix | ||
UnusedOperatorDef.juvix | ||
WrongModuleName.juvix |