1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 14:13:27 +03:00
juvix/tests/Compilation/positive/test043.juvix
Łukasz Czajka 485f6e7920
Literal casting (#2457)
* Closes #2453 
* Closes #2432
* Any nonnegative literal `n` is replaced with `fromNat {_} {{_}} n`
where `fromNat` is the builtin conversion function defined in the
`Natural` trait in `Stdlib.Trait.Natural`.
* Any negative literal `-n` is replaced with `fromInt {_} {{_}} -n`
where `fromInt` is the builtin conversion function defined in the
`Integral` trait in `Stdlib.Trait.Integral`.
* Before resolving instance holes, it is checked whether the type holes
introduced for `fromNat` and `fromInt` have been inferred. If not, an
attempt is made to unify them with `Nat` or `Int`. This allows to
type-check e.g. `1 == 1` (there is no hint in the context as to what the
type of `1` should be, so it is decided to be `Nat` after inferring the
hole fails).
2023-11-03 10:01:03 +01:00

22 lines
308 B
Plaintext

-- builtin trace
module test043;
builtin nat
type Nat :=
| zero : Nat
| suc : Nat → Nat;
builtin string
axiom String : Type;
builtin trace
axiom trace : {A : Type} → A → A;
builtin seq
seq : {A B : Type} → A → B → B
| x y := y;
f : Nat := seq (trace "a") (suc zero);
main : Nat := f;