Skip to content

Commit 5a58531

Browse files
authored
Merge branch 'dev' into fix-probe-duplication
2 parents 4b81659 + 1e3ccd6 commit 5a58531

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5691
-2324
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ This can be combined with using `make hot` rather than `make serve` to add hot r
8888

8989
## Debugging
9090

91+
92+
### Troubleshooting dependency updates and build failures
93+
94+
- If Hazel fails to compile after you update or pull new dependencies, first run:
95+
96+
```sh
97+
make deps
98+
```
99+
100+
- If that doesn't work, your opam switch may be out of sync. Remove and recreate it, then reinstall deps:
101+
102+
```sh
103+
# Replace 5.2.0 with the name of your switch
104+
opam switch remove 5.2.0
105+
```
106+
107+
Then recreate the switch following the steps in this guide (see "Install OCaml" and "Install Library Dependencies"), run `eval $(opam env)`, `make deps`, and rebuild.
108+
109+
91110
### Printing
92111
You can print to the browser console using the standard `print_endline` function. This is probably the easiest method to debug right now.
93112

src/haz3lcore/TyDi/ErrorPrint.re

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Print = {
3030
);
3131
};
3232

33-
let term = (term: Term.Any.t): string => {
33+
let term = (term: Any.t): string => {
3434
let settings =
3535
ExpToSegment.Settings.of_core(~inline=false, CoreSettings.off);
3636
term |> ExpToSegment.any_to_pretty(~settings) |> seg(~holes="");
@@ -126,13 +126,52 @@ let typ_error: Info.error_typ => string =
126126
prn("Constructor %s already used in this sum", name)
127127
| WantLabel => "Expected a label"
128128
| ParseFailure => "Parse failure"
129+
| InvalidLabel(name, labels) =>
130+
prn(
131+
"Label %s is not valid. Valid labels are: %s",
132+
name,
133+
String.concat(", ", labels),
134+
)
129135
| DuplicateLabels(labels, ty) =>
130136
prn(
131137
"Duplicate labels in type %s: %s",
132138
Print.typ(ty),
133139
String.concat(", ", labels),
134140
)
135-
| Duplicate(name, _) => prn("Type %s is already defined", name);
141+
| Duplicate(name, _) => prn("Type %s is already defined", name)
142+
| WantProduct(ty) =>
143+
prn("Expected a tuple type, found type %s", Print.typ(ty));
144+
145+
let underdetermined_typ: Info.underdetermined_typ => string =
146+
fun
147+
| ProdExtensionUnderdetermined(tys) =>
148+
prn(
149+
"Cannot determine type of tuple extension with argument types: %s",
150+
List.map(Print.typ, tys) |> String.concat(", "),
151+
)
152+
| ProdProjectionMissingLabel(label, labels) =>
153+
prn(
154+
"Cannot project label %s. Valid labels are: %s",
155+
label,
156+
String.concat(", ", labels),
157+
)
158+
| ProdProjectionBadArgs({product, label}) =>
159+
prn(
160+
"Cannot determine projection type because %s",
161+
String.concat(
162+
" and ",
163+
[
164+
switch (product) {
165+
| Some(ty) => "Type is not a tuple type: " ++ Print.typ(ty)
166+
| None => ""
167+
},
168+
switch (label) {
169+
| Some(ty) => "Label is not a valid label: " ++ Print.typ(ty)
170+
| None => ""
171+
},
172+
],
173+
),
174+
);
136175

137176
let tpat_error: Info.error_tpat => string =
138177
fun

src/haz3lcore/lang/Form.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ type atomic_form =
9292
| EmptyList
9393
| EmptyTuple
9494
| Deferral
95+
| ExplicitNonlabel
9596
| TyVar
9697
| TyVarP
9798
| Ctr
@@ -148,6 +149,8 @@ type compound_form =
148149
| DotTyp
149150
| TypeAsc
150151
| TypPlus
152+
| ProdProjection
153+
| ProdExtension
151154
// UNARY PREFIX OPERATORS
152155
| Not
153156
| TypSumSingle
@@ -236,6 +239,8 @@ let get: compound_form => t =
236239
| TypeAsc => mk_infix(":", Exp, ~l=Exp, ~r=Typ, P.asc)
237240
| TupleExtension => mk_infix("...", Exp, P.plus)
238241
| TypPlus => mk_infix("+", Typ, P.type_plus)
242+
| ProdProjection => mk_infix(".", Typ, P.dot)
243+
| ProdExtension => mk_infix("...", Typ, P.ap)
239244
// UNARY PREFIX OPERATORS
240245
| Not => mk_prefix("!", Exp, P.not_)
241246
| TypSumSingle => mk_prefix("+", Typ, P.or_)
@@ -377,6 +382,7 @@ let get_atomic_form: atomic_form => (Token.t => bool, list(Mold.t)) =
377382
| EmptyList => (Token.is_empty_list, [op(Exp), op(Pat)])
378383
| EmptyTuple => (Token.is_empty_tuple, [op(Exp), op(Pat), op(Typ)])
379384
| Deferral => (Token.is_wild, [op(Exp)])
385+
| ExplicitNonlabel => (Token.is_wild, [op(Typ)])
380386
| TyVar => (Token.is_typ_var, [op(Typ)])
381387
| TyVarP => (Token.is_typ_var, [op(TPat)])
382388
| Ctr => (Token.is_ctr, [op(Exp), op(Pat)])

src/haz3lcore/lang/MakeTerm.re

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ let mk_bad = (ctr, ids, value) => {
187187
let is_hole_label = (t: string) =>
188188
t == " " || Token.is_explicit_hole(t) || Token.is_llm_hole(t);
189189

190-
let rec go_s = (s: Sort.t, skel: Skel.t, seg: Segment.t): Term.Any.t =>
190+
let rec go_s = (s: Sort.t, skel: Skel.t, seg: Segment.t): Any.t =>
191191
switch (s) {
192192
| Pat => Pat(pat(unsorted(Pat, skel, seg)))
193193
| TPat => TPat(tpat(unsorted(TPat, skel, seg)))
@@ -409,14 +409,13 @@ and exp_term: unsorted => (Exp.term, list(Id.t)) = {
409409
@ [r]
410410
|> List.map((child: Exp.t) => {
411411
switch (child) {
412-
| {term: Tuple([{term: TupLabel(_) as tl, _}]), _} as tup =>
412+
| {term: Tuple([{term: _ as tl, _}]), _} as tup =>
413413
// We use the Id for the tuple as the ids for the tuplabels
414414
let (_, rewrap) = IdTagged.unwrap(tup);
415415
rewrap(tl);
416416
| _ => child
417417
}
418418
});
419-
420419
ret(Tuple(tuple_children));
421420
| None =>
422421
switch (tiles) {
@@ -454,6 +453,14 @@ and exp_term: unsorted => (Exp.term, list(Id.t)) = {
454453
| (["..."], []) => TupleExtension(l, r)
455454
| (["="], []) =>
456455
switch (l.term) {
456+
| Deferral(_) =>
457+
TupLabel(
458+
{
459+
annotation: l.annotation,
460+
term: ExplicitNonlabel,
461+
},
462+
r,
463+
) // Unlabeled tuple using deferred ap in tuplabel
457464
| Var(name) =>
458465
TupLabel(
459466
{
@@ -595,6 +602,16 @@ and pat_term: unsorted => (Pat.term, list(Id.t)) = {
595602
switch (tiles) {
596603
| ([(_id, (["="], []))], []) =>
597604
switch (l.term) {
605+
| Wild =>
606+
ret(
607+
TupLabel(
608+
{
609+
annotation: l.annotation,
610+
term: ExplicitNonlabel,
611+
},
612+
r,
613+
),
614+
) // Unlabeled tuple using deferred ap in tuplabel
598615
| Var(name) =>
599616
ret(
600617
TupLabel(
@@ -657,6 +674,7 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
657674
| (["Float"], []) => Atom(Float)
658675
| (["String"], []) => Atom(String)
659676
| (["Nat"], []) => Atom(Nat)
677+
| (["_"], []) => ExplicitNonlabel
660678
| ([t], []) when Token.is_typ_var(t) => Var(t)
661679
| ([t], []) when Token.is_quoted_label(t) =>
662680
Label(Token.sub(t, 1, Token.length(t) - 2))
@@ -737,6 +755,21 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
737755
)
738756
| _ => ret(TupLabel(l, r))
739757
}
758+
| ([(_id, (["."], []))], []) =>
759+
switch (r.term) {
760+
| Var(name) =>
761+
ret(
762+
ProdProjection(
763+
l,
764+
{
765+
annotation: r.annotation,
766+
term: Label(name),
767+
},
768+
),
769+
)
770+
| _ => ret(ProdProjection(l, r))
771+
}
772+
| ([(_id, (["..."], []))], []) => ret(ProdExtension(l, r))
740773
| _ => ret(hole(tm))
741774
}
742775
}
@@ -808,7 +841,7 @@ and rul = (unsorted): Rul.t => {
808841
and unsorted = (sort: Sort.t, skel: Skel.t, seg: Segment.t): unsorted => {
809842
/* Remove projectors. We do this here as opposed to removing
810843
* them in an external call to save a whole-syntax pass. */
811-
let tile_kids = (p: Piece.t): list(Term.Any.t) =>
844+
let tile_kids = (p: Piece.t): list(Any.t) =>
812845
switch (p) {
813846
| Secondary(_)
814847
| Grout(_) => []

0 commit comments

Comments
 (0)