1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-04 17:07:28 +03:00
juvix/tests/positive/Records.juvix

60 lines
847 B
Plaintext
Raw Normal View History

module Records;
type T := constructT : T;
type T-wrapper := mkWrapper {unwrap : T};
type Pair (A B : Type) :=
--- creates a pair
mkPair {
fst : A;
snd : B
};
p1 : Pair T T :=
mkPair@{
fst := constructT;
snd := constructT
};
type EnumRecord :=
| --- doc for C1
C1 {
c1a : T;
c1b : T
}
| C2 {
c2a : T;
c2b : T
};
p2 : Pair EnumRecord EnumRecord :=
mkPair@{
fst :=
C1@?{
c1a := constructT;
c1b := constructT
};
snd :=
C2@{
c2a := constructT;
c2b := constructT
}
};
type newtype := mknewtype {f : T};
p3 : Pair T T -> T := Pair.fst;
open Pair;
p4 {A : Type} : Pair A T -> A := fst;
type Bool :=
| false
| true;
module Update;
f {A B : Type} (p : Pair A B) : Pair Bool B := p@Pair{fst := true};
end;