Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
e664ee4
Refactoring Plan
MaxCarroll0 Dec 13, 2024
8c7416f
TypSlice type model
MaxCarroll0 Dec 13, 2024
274a498
Fix model
MaxCarroll0 Dec 13, 2024
0880c2f
module TypSlice
MaxCarroll0 Dec 14, 2024
bf7f29b
Refactor Type Slices
MaxCarroll0 Dec 16, 2024
a145ac5
Merge commit 'b429e5731f57785da473b964dd3e80b8f98cf9ea' into witnesse…
MaxCarroll0 Dec 16, 2024
a4b1948
Fix slice substitution
MaxCarroll0 Dec 16, 2024
4c9d5ac
Note Bug
MaxCarroll0 Dec 16, 2024
f154050
Fix slice joins
MaxCarroll0 Dec 17, 2024
14a3897
Fix slice joining, add full slice calc
MaxCarroll0 Dec 17, 2024
291ec59
Basic display of slices
MaxCarroll0 Dec 17, 2024
4066630
Synthesis Slices
MaxCarroll0 Dec 17, 2024
0dd744b
Merge commit '82d39a967f304c24cce2e100b74ced00d67b6f2c' into witnesse…
MaxCarroll0 Dec 17, 2024
a5588bb
Update TODO.md
MaxCarroll0 Dec 17, 2024
facf194
Analysis slices; fix normalisation; fix annot slices
MaxCarroll0 Dec 21, 2024
5c97543
Type alias slices
MaxCarroll0 Dec 21, 2024
d500037
Ctx slice view; ctr var slices
MaxCarroll0 Dec 21, 2024
6b50f54
Update TODO.md
MaxCarroll0 Dec 21, 2024
0b292ac
TypFun slices (partial)
MaxCarroll0 Dec 21, 2024
10dba0f
Update TODO.md
MaxCarroll0 Dec 21, 2024
e9ba047
Styling slices
MaxCarroll0 Dec 21, 2024
3c89fc6
Fun slices
MaxCarroll0 Dec 21, 2024
f03836d
Merge from dev
MaxCarroll0 Jan 27, 2025
cfb86e3
Fix pretty pat cast precedence
MaxCarroll0 Jan 27, 2025
298b8cf
Update bug log
MaxCarroll0 Jan 27, 2025
3f8cd0a
Fix pat slice highlighting
MaxCarroll0 Jan 27, 2025
c004758
Start Hole Instantiation
MaxCarroll0 Jan 30, 2025
122ab0e
SearchProc Plan
MaxCarroll0 Jan 31, 2025
c6f23de
Merge commit '7722f01dfab16aef8b246b8db4ce1a39298d8578' into witnesse…
MaxCarroll0 Jan 31, 2025
d6de3dc
Debug console elaboration
MaxCarroll0 Feb 6, 2025
8eb380a
Indeterminate Evaluation framework
MaxCarroll0 Feb 6, 2025
5723081
Temp: Switch to IndetEvaluator
MaxCarroll0 Feb 6, 2025
d7c0825
Instantiation failure error
MaxCarroll0 Feb 6, 2025
d44ab46
Remedy indication bug in types in evaluation
MaxCarroll0 Feb 6, 2025
f082201
Merge commit '61b5c0bc0f62c2e8e367f5621a57939353b4d370' into witnesse…
MaxCarroll0 Feb 6, 2025
7f00595
Merge fixes
MaxCarroll0 Feb 6, 2025
ff370b4
Fix type id bug
MaxCarroll0 Feb 6, 2025
7c07d8c
Maintain ids properly in typslice map_term
MaxCarroll0 Feb 6, 2025
486e52f
Fix fun casts
MaxCarroll0 Feb 6, 2025
adba826
Replace typslice ids correctly during evaluation
MaxCarroll0 Feb 6, 2025
29d279a
Parenthesise typ slices
MaxCarroll0 Feb 6, 2025
4995a44
Slices in Stepper
MaxCarroll0 Feb 6, 2025
5c61c55
Ignore Fun in analysis slices
MaxCarroll0 Feb 21, 2025
4d05488
Indet Evaluation
MaxCarroll0 Feb 23, 2025
bde831b
Make WorkerServer use IndetEval
MaxCarroll0 Feb 23, 2025
b4f60b7
Merge commit 'bde831b965c2a1fd3ebcaf95b26e3f84dd563dff' into witnesse…
MaxCarroll0 Feb 23, 2025
6f5473d
Optimise indet eval
MaxCarroll0 Feb 23, 2025
bb82163
Indet Index
MaxCarroll0 Feb 23, 2025
b4cfd6b
Cons regular evaluation to Indet evaluator
MaxCarroll0 Feb 23, 2025
87645ba
Terrible Indet UI
MaxCarroll0 Feb 23, 2025
db20b72
Substitute holes within closures
MaxCarroll0 Feb 25, 2025
81ff2fd
TODO updates
MaxCarroll0 Feb 25, 2025
bb2fe40
Error Search Toggle
MaxCarroll0 Feb 25, 2025
525e526
TODO update
MaxCarroll0 Feb 25, 2025
d902579
TODO update
MaxCarroll0 Feb 25, 2025
83c425e
Fix Instantiator
MaxCarroll0 Feb 25, 2025
39f2bdf
Check casts at head of evaluation only
MaxCarroll0 Feb 27, 2025
1a63908
TODO update
MaxCarroll0 Feb 27, 2025
4327c61
Maintain slice when casting to ground types
MaxCarroll0 Feb 27, 2025
ace0ca5
TODO update
MaxCarroll0 Feb 27, 2025
73dd1a7
TODO update
MaxCarroll0 Feb 27, 2025
94cc82d
Instantiate lists with Cons
MaxCarroll0 Mar 17, 2025
ecf98c1
Structure pattern matching instantiation
MaxCarroll0 Mar 17, 2025
fc00fe4
least specific pattern instantiations (incomplete)
MaxCarroll0 Mar 17, 2025
6f83a96
Revert "least specific pattern instantiations (incomplete)"
MaxCarroll0 Mar 17, 2025
abfc7b8
Revert "Structure pattern matching instantiation"
MaxCarroll0 Mar 17, 2025
2f34d7e
Revert "Instantiate lists with Cons"
MaxCarroll0 Mar 17, 2025
2979a56
Indet Match Hole Instantiations
MaxCarroll0 Mar 17, 2025
3fdcd3f
Restructure Unboxing code
MaxCarroll0 Mar 17, 2025
355d6a2
Nondeterminism model
MaxCarroll0 Apr 7, 2025
ebb3d55
Abstract indeterminate evaluation
MaxCarroll0 Apr 7, 2025
d7a2e2a
Merge Labelled Tuples (4 TESTS FAILING)
MaxCarroll0 Apr 7, 2025
d5cd1aa
fix test
MaxCarroll0 Apr 8, 2025
b671df9
Merge commit '75f48e60edfac8b9a73883119abc5c5a33f44e99' into witnesse…
MaxCarroll0 Apr 8, 2025
f288788
Merge commit '4759f2c9447d80bac7092939f2027ecb2195d7b6' into witnesse…
MaxCarroll0 Apr 8, 2025
661eae7
Merge commit 'aa56aba8b9ff18aa195914b34ab88850bd7d2102' into witnesse…
MaxCarroll0 Apr 8, 2025
fbf415e
Merge commit '847a4380a6093f39881bda7c9ae176539f011746' into witnesse…
MaxCarroll0 Apr 8, 2025
0ad08c4
Merge commit '29b7b72b0340953e315bac93179f574860b050ac' into witnesse…
MaxCarroll0 Apr 8, 2025
f197b65
Merge commit 'a08c377a45e92e4b01c845d67c94cdc5a062a744' into witnesse…
MaxCarroll0 Apr 8, 2025
337edab
Merge fixes
MaxCarroll0 Apr 8, 2025
c2febf7
Treat Tuple Label as parentheses
MaxCarroll0 Apr 8, 2025
ce926d8
Right branch always used joining foralls
MaxCarroll0 Apr 8, 2025
a757029
Note merge bugs
MaxCarroll0 Apr 8, 2025
5f18db6
Merge commit '40bdf7aaeae451bf8ee97ed6850688c81eb5aae1' into witnesse…
MaxCarroll0 Apr 8, 2025
7404b6c
Merge commit '38f92220e33deabb1404b42a0a3b0742e74603a4' into witnesse…
MaxCarroll0 Apr 8, 2025
9717639
Merge commit 'ffaad0d5841896237207af19b94ca662a863f802' into witnesse…
MaxCarroll0 Apr 8, 2025
672f7ed
Merge commit '882dfda8ea9ff7f2847b47d4e43bb89572efc711' into witnesse…
MaxCarroll0 Apr 8, 2025
117f689
Merge commit 'd55ff4aeba4d4c675ac383226d73e3f30e5984b9' into witnesse…
MaxCarroll0 Apr 8, 2025
451e6f7
Merge commit '63e82281208b6c812e96fb286fbec615cfffec6d' into witnesse…
MaxCarroll0 Apr 8, 2025
2d1ab30
Merge: IdTagged now a type parameter
MaxCarroll0 Apr 8, 2025
96adcc1
Merge commit '6df1774d64832ebaf8397fed1527b0b48431707c' into witnesse…
MaxCarroll0 Apr 8, 2025
33d80b9
Merge commit '9e0efc7e2a32d390215628902a21db6bca58ce6f' into witnesse…
MaxCarroll0 Apr 8, 2025
d3da061
Merge commit '61de76a7fc530bc9338cf770a9dd0fc813785202' into witnesse…
MaxCarroll0 Apr 8, 2025
e70afdd
Merge commit 'd7a2b93192d809932cc9443eb32cb922c6506395' into witnesse…
MaxCarroll0 Apr 8, 2025
a8efff7
Merge commit '625d0c7e1b4ef843d47ecfe3ae2f4f2d785a4123' into witnesse…
MaxCarroll0 Apr 8, 2025
f9c989c
BFS implements Search, & Add lazy application to nondet algorithms
MaxCarroll0 Apr 8, 2025
69effec
Infix lazy application
MaxCarroll0 Apr 8, 2025
35d3a19
Fix laziness
MaxCarroll0 Apr 8, 2025
1d8a1ef
Fix list nth offset
MaxCarroll0 Apr 8, 2025
68f4487
Fix indet evaluator
MaxCarroll0 Apr 11, 2025
2f6c241
Test bounded dfs
MaxCarroll0 Apr 11, 2025
54dbf7c
Fix fn in stepper
MaxCarroll0 Apr 11, 2025
cd77d01
Disable BFS
MaxCarroll0 Apr 11, 2025
5e0c94e
Add slice for inconsistent with arrow errors
MaxCarroll0 Apr 22, 2025
66027a8
fix formatting
MaxCarroll0 Apr 23, 2025
1ce9dd1
Revert "Add slice for inconsistent with arrow errors"
MaxCarroll0 Apr 23, 2025
6f21742
Add analysis slices + error logic for expecting arrow type, and expec…
MaxCarroll0 Apr 23, 2025
cb6019b
Fix fixed points in stepper & one step evaluator
MaxCarroll0 Apr 23, 2025
b53dfa0
remove closure substitution on one step evaluators
MaxCarroll0 Apr 23, 2025
f245dd3
Implement match instantiation
MaxCarroll0 Apr 23, 2025
33d32a8
fix list instantiation; no instantiations to dyn
MaxCarroll0 Apr 23, 2025
8fa265d
Don't try instantiate inexhaustive matches
MaxCarroll0 Apr 23, 2025
f4c2bf6
Merge branch 'indet-match-eval' into witnesses-search
MaxCarroll0 Apr 23, 2025
a495b52
Remove fair non-determinism model; implement as Interleaved DFS tree …
MaxCarroll0 Apr 24, 2025
9084ae1
BFS works now!!!
MaxCarroll0 Apr 24, 2025
d5781e5
Make empty choice return fail for BFS
MaxCarroll0 Apr 24, 2025
c7164f3
Log if bound is reached in BDFS
MaxCarroll0 Apr 24, 2025
61ed908
Fix value classification in stepper & onestepevaluator
MaxCarroll0 Apr 24, 2025
ccff0c9
Ground Instantiations
MaxCarroll0 Apr 24, 2025
bcef582
Switch to `Environment
MaxCarroll0 Apr 24, 2025
cd3db8a
Full string instantiation
MaxCarroll0 Apr 25, 2025
7c1e561
Implement Sum Instantiation
MaxCarroll0 Apr 25, 2025
6e73a83
Make ground sum types include names
MaxCarroll0 Apr 25, 2025
520cc4e
fix unparens
MaxCarroll0 Apr 25, 2025
193e3ea
Normalise instantiations; rec, forall; fun wildcards
MaxCarroll0 Apr 25, 2025
ebc1f15
Fix typslice matching
MaxCarroll0 Apr 25, 2025
a17212c
Normalise constructors during elaboration
MaxCarroll0 Apr 25, 2025
6ecdbe5
fix product unboxing
MaxCarroll0 Apr 25, 2025
b5b7459
Fix getting sum ctrs from ctx
MaxCarroll0 Apr 25, 2025
96dc1eb
Remove in_closures from oneStepEvaluator
MaxCarroll0 Apr 25, 2025
800d6cc
Don't fixup casts during instantiation
MaxCarroll0 Apr 25, 2025
c04ee6f
Allow ground invalid sums
MaxCarroll0 Apr 26, 2025
1562c32
Fix sum instantiation casts
MaxCarroll0 Apr 26, 2025
0b527b0
pp fix
MaxCarroll0 Apr 26, 2025
d714685
fix stepper
MaxCarroll0 Apr 27, 2025
40c2682
Inconsistency Slices
MaxCarroll0 Apr 27, 2025
3a136f5
Error slice UI
MaxCarroll0 Apr 27, 2025
51530ee
Fix Type Var Joins
MaxCarroll0 Apr 27, 2025
c7fe792
Fix inconsistency slices (atoms)
MaxCarroll0 Apr 27, 2025
97be150
Parallel bindings in inconsistency joins
MaxCarroll0 Apr 27, 2025
0ea2505
Remove print statement
MaxCarroll0 Apr 27, 2025
cfc5ed1
Fix fold ordering in Type Joins
MaxCarroll0 Apr 27, 2025
24e58c2
Retain global slices when getting constructors
MaxCarroll0 Apr 28, 2025
09995c1
Retain slices on unrolling types
MaxCarroll0 Apr 28, 2025
df6cc38
Correct type alias slicing
MaxCarroll0 Apr 28, 2025
9752473
Highlight constructor definition names
MaxCarroll0 Apr 28, 2025
8e48e10
Fix nullary constructor slices
MaxCarroll0 Apr 28, 2025
cb59d93
Direct binding slices: omits bindings when unused
MaxCarroll0 Apr 28, 2025
2653aff
remove redundant code
MaxCarroll0 Apr 28, 2025
fe8b262
Unroll types during instantiation
MaxCarroll0 Apr 30, 2025
923a542
Don't cast from normalised type
MaxCarroll0 Apr 30, 2025
8648aad
Fix missing arg sum
MaxCarroll0 May 1, 2025
6448fcb
Fix dynamic unboxing
MaxCarroll0 May 1, 2025
ac70aed
Filter out spurious cast failures from pattern match instantiation
MaxCarroll0 May 1, 2025
fe016d7
Use BDFS in debug console
MaxCarroll0 May 1, 2025
e6adfe1
Dead code removal
MaxCarroll0 May 2, 2025
589fda1
Fix inconsistency joins, switch to minimised error slices, fix get_in…
MaxCarroll0 May 5, 2025
e5cf673
Colour error slices
MaxCarroll0 May 5, 2025
dc46cd4
Retain incr slices during type checking
MaxCarroll0 May 6, 2025
0da9e3e
split incr & global slices; factor out code
MaxCarroll0 Jul 25, 2025
0c34b55
update TODO
MaxCarroll0 Jul 25, 2025
06c740b
Remove indeteval code
MaxCarroll0 Jul 29, 2025
7684fb4
Merge commit '91758662333da2c8a9fc740c7b960bfcb5b39e7e' into type-sli…
MaxCarroll0 Aug 14, 2025
adc08a1
reinstate mode
MaxCarroll0 Aug 14, 2025
68a36a2
merge fixes: syntax fix & fmt
MaxCarroll0 Aug 14, 2025
0721159
merge fixes: atoms
MaxCarroll0 Aug 14, 2025
1810dc1
update typslice matched_args
MaxCarroll0 Aug 14, 2025
3ba30f6
fix ctr_ana_typ
MaxCarroll0 Aug 14, 2025
8cbe6f0
fix info
MaxCarroll0 Aug 14, 2025
bdf1b5e
Update mode
MaxCarroll0 Aug 14, 2025
d40c068
fix annotations
MaxCarroll0 Aug 14, 2025
ee5222b
delete metavar
MaxCarroll0 Aug 14, 2025
d49cfbc
fmt
MaxCarroll0 Aug 14, 2025
7e05474
revert statics
MaxCarroll0 Aug 15, 2025
4a652b4
combine type slices & types gramars
MaxCarroll0 Aug 15, 2025
ae79563
add pp_typslice_term
MaxCarroll0 Aug 15, 2025
8eeaf8f
fmt
MaxCarroll0 Aug 15, 2025
6d6a306
refactior TermBase
MaxCarroll0 Aug 15, 2025
909729d
ctx & ctr slices
MaxCarroll0 Aug 15, 2025
b2779e6
merge Typ.re and TypSlice.re, some fixes
MaxCarroll0 Aug 15, 2025
3a38387
Refactor unboxing
MaxCarroll0 Aug 18, 2025
5e62a68
Self
MaxCarroll0 Aug 18, 2025
00be68c
Mode
MaxCarroll0 Aug 18, 2025
e2c7149
Info
MaxCarroll0 Aug 18, 2025
5403257
Statics
MaxCarroll0 Aug 18, 2025
59bab01
Refactor transition
MaxCarroll0 Aug 18, 2025
c41b8b9
Finish refactor (compiles)
MaxCarroll0 Aug 18, 2025
01c0fc8
Delete SearchPlan.md
MaxCarroll0 Aug 18, 2025
3be3fe5
Delete src/haz3lcore/lang/term/TypSlice_DEPRECATED.re
MaxCarroll0 Aug 18, 2025
4596c57
remove unused open
MaxCarroll0 Aug 20, 2025
03530a1
match folder structure to dev
MaxCarroll0 Aug 20, 2025
7be1b0a
Revert "match folder structure to dev"
MaxCarroll0 Aug 20, 2025
59d3d47
Merge commit '6d0aa3ab5aa046b6399553974d9353458080b7ef' into type-sli…
MaxCarroll0 Aug 20, 2025
348c3bc
pre-resolve merge conflicts for #1669
MaxCarroll0 Aug 20, 2025
8012321
Merge commit 'd9bc49a2721162322e958fe5b0f5dcac732b719a' into type-sli…
MaxCarroll0 Aug 20, 2025
054ca29
Reinstate temporary files
MaxCarroll0 Aug 20, 2025
2753d47
Merge remote-tracking branch 'origin/dev' into type-slicing
MaxCarroll0 Aug 20, 2025
657d200
Delete TODO.md
MaxCarroll0 Aug 20, 2025
3342565
move joins
MaxCarroll0 Aug 20, 2025
08d0de8
fix syntax & fmt
MaxCarroll0 Aug 20, 2025
e78a872
merge fixes
MaxCarroll0 Aug 20, 2025
eafc760
no longer thread cursor through editors
MaxCarroll0 Aug 20, 2025
68cb19d
Final merge fixes
MaxCarroll0 Aug 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/haz3lcore/TyDi/ErrorPrint.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let common_error: Info.error_common => string =
| DuplicateLabel(_, _) => "Duplicate label"
| TupleLabelError(_) => "Invalid tuple label"
| NoType(BadToken(token)) => prn("\"%s\" isn't a valid token", token)
| Inconsistent(WithArrow(ty)) =>
| Inconsistent(WithArrow(ty, _slc)) =>
prn("type %s is not consistent with arrow type", Print.typ(ty))
| Inconsistent(CompareFun(ty)) =>
prn("values of type %s cannot be compared", Print.typ(ty))
Expand Down Expand Up @@ -87,7 +87,7 @@ let exp_error: Info.error_exp => string =

let pat_error: Info.error_pat => string =
fun
| ExpectedConstructor => "Expected a constructor"
| ExpectedConstructor(_slc) => "Expected a constructor"
| Redundant(_) => "Redundant" //TODO: elaborate
| Common(error) => common_error(error);

Expand Down
55 changes: 29 additions & 26 deletions src/haz3lcore/TyDi/TyDiCtx.re
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ let bound_constructors =
let bound_aps = (ty_expect: Typ.t, ctx: Ctx.t): list(TyDiSuggestion.t) =>
List.filter_map(
fun
| Ctx.VarEntry({typ: {term: Arrow(_, ty_out), _} as ty_arr, name, _})
when
Typ.is_consistent(ctx, ty_expect, ty_out)
&& !Typ.is_consistent(ctx, ty_expect, ty_arr) => {
| Ctx.VarEntry({typ: ty_arr, name, _}) =>
switch (ty_arr |> Typ.term_of) {
| Arrow(_, ty_out)
when
Typ.is_consistent(ctx, ty_expect, ty_out)
&& !Typ.is_consistent(ctx, ty_expect, ty_arr) =>
Some({
content: name ++ "(",
strategy: Exp(Common(FromCtxAp(ty_out))),
});
})
| _ => None
}
| _ => None,
ctx.entries,
Expand All @@ -88,18 +91,18 @@ let bound_constructor_aps =
(wrap, ty: Typ.t, ctx: Ctx.t): list(TyDiSuggestion.t) =>
List.filter_map(
fun
| Ctx.ConstructorEntry({
typ: {term: Arrow(_, ty_out), _} as ty_arr,
name,
_,
})
when
Typ.is_consistent(ctx, ty, ty_out)
&& !Typ.is_consistent(ctx, ty, ty_arr) =>
Some({
content: name ++ "(",
strategy: wrap(FromCtxAp(ty_out)),
})
| Ctx.ConstructorEntry({typ: ty_arr, name, _}) =>
switch (ty_arr |> Typ.term_of) {
| Arrow(_, ty_out)
when
Typ.is_consistent(ctx, ty, ty_out)
&& !Typ.is_consistent(ctx, ty, ty_arr) =>
Some({
content: name ++ "(",
strategy: wrap(FromCtxAp(ty_out)),
})
| _ => None
}
| _ => None,
ctx.entries,
);
Expand Down Expand Up @@ -165,7 +168,7 @@ let suggest_lookahead_variable = (ci: Info.t): list(TyDiSuggestion.t) => {
let ctx = Info.ctx_of(ci);
switch (ci) {
| InfoExp({ana, _}) =>
let exp_refs = ty =>
let exp_refs = (ty: Typ.t) =>
bound_variables(ty, ctx)
@ bound_constructors(x => Exp(Common(x)), ty, ctx);
let exp_aps = ty =>
Expand All @@ -182,14 +185,14 @@ let suggest_lookahead_variable = (ci: Info.t): list(TyDiSuggestion.t) => {
@ List.map(restrategize(commas), exp_refs(ty));
| Atom(Bool) =>
/* TODO: Find a UI to make these less confusing */
exp_refs(Atom(Int) |> Typ.fresh)
@ exp_refs(Atom(SInt) |> Typ.fresh)
@ exp_refs(Atom(Nat) |> Typ.fresh)
@ exp_refs(Atom(Float) |> Typ.fresh)
@ exp_refs(Atom(String) |> Typ.fresh)
@ exp_aps(Atom(Int) |> Typ.fresh)
@ exp_aps(Atom(Float) |> Typ.fresh)
@ exp_aps(Atom(String) |> Typ.fresh)
exp_refs(Atom(Int) |> Typ.fresh_empty)
@ exp_refs(Atom(SInt) |> Typ.fresh_empty)
@ exp_refs(Atom(Nat) |> Typ.fresh_empty)
@ exp_refs(Atom(Float) |> Typ.fresh_empty)
@ exp_refs(Atom(String) |> Typ.fresh_empty)
@ exp_aps(Atom(Int) |> Typ.fresh_empty)
@ exp_aps(Atom(Float) |> Typ.fresh_empty)
@ exp_aps(Atom(String) |> Typ.fresh_empty)
| _ => []
};
| InfoPat({ana, co_ctx, _}) =>
Expand Down
19 changes: 10 additions & 9 deletions src/haz3lcore/TyDi/TyDiForms.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ let leading_expander = " ";
* running Statics, but for now, new forms e.g. operators must be added
* below manually. */
module Typ = {
let unk: Typ.t = Unknown(Internal) |> Typ.fresh;
let fresh_empty = Typ.fresh_empty;
let unk: Typ.t = Unknown(Internal) |> Typ.fresh_empty;

let of_const_mono_delim: list((Token.t, Typ.t)) = [
("true", Atom(Bool) |> Typ.fresh),
("false", Atom(Bool) |> Typ.fresh),
("true", Atom(Bool) |> Typ.fresh_empty),
("false", Atom(Bool) |> Typ.fresh_empty),
//("[]", List(unk)), / *NOTE: would need to refactor buffer for this to show up */
//("()", Prod([])), /* NOTE: would need to refactor buffer for this to show up */
("\"\"", Atom(String) |> Typ.fresh), /* NOTE: Irrelevent as second quote appears automatically */
("\"\"", Atom(String) |> Typ.fresh_empty), /* NOTE: Irrelevent as second quote appears automatically */
("_", unk),
];

/* Only need to add forms here if they have a non-trivial type */
let of_leading_delim: list((Token.t, Typ.t)) = [
("fun" ++ leading_expander, Arrow(unk, unk) |> Typ.fresh),
("fun" ++ leading_expander, Arrow(unk, unk) |> Typ.fresh_empty),
(
"typfun" ++ leading_expander,
Forall(Var("") |> TPat.fresh, unk) |> Typ.fresh,
Forall(Var("") |> TPat.fresh, unk) |> Typ.fresh_empty,
),
("test" ++ leading_expander, Prod([]) |> Typ.fresh),
("test" ++ leading_expander, Prod([]) |> Typ.fresh_empty),
];

let of_infix_delim: list((Token.t, Typ.term)) = [
Expand Down Expand Up @@ -71,7 +72,7 @@ module Typ = {
fun
| InfoExp({ana, _})
| InfoPat({ana, _}) => ana
| _ => Unknown(Internal) |> Typ.fresh;
| _ => Unknown(Internal) |> Typ.fresh_empty;

let filter_by =
(
Expand Down Expand Up @@ -218,7 +219,7 @@ let suggest_operator: Info.t => list(TyDiSuggestion.t) =
[] // Stop completing (a= to (a==
| _ =>
suggest_form(
List.map(((a, b)) => (a, IdTagged.fresh(b)), Typ.of_infix_delim),
List.map(((a, b)) => (a, Typ.fresh_empty(b)), Typ.of_infix_delim),
Delims.infix,
info,
)
Expand Down
42 changes: 29 additions & 13 deletions src/haz3lcore/lang/MakeTerm.re
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,18 @@ let should_instrument = (id: Id.t): bool =>

let parse_sum_term: Typ.t => ConstructorMap.variant(Typ.t) =
fun
| {term: Var(ctr), annotation: {ids, _}} => Variant(ctr, ids, None)
| {term: {typ: Var(ctr), _}, annotation: {ids, _}} =>
Variant(ctr, ids, None)
| {
term: Ap({term: Var(ctr), annotation: {ids: ids_ctr, _}}, u),
term:
{
typ:
Ap(
{term: {typ: Var(ctr), _}, annotation: {ids: ids_ctr, _}},
u,
),
_,
},
annotation: {ids: ids_ap, _},
} =>
Variant(ctr, ids_ctr @ ids_ap, Some(u))
Expand All @@ -153,11 +162,11 @@ let mk_bad = (ctr, ids, value) => {
annotation: {
ids: ids,
},
term: Var(ctr),
term: Var(ctr) |> Typ.empty,
};
switch (value) {
| None => t
| Some(u) => Ap(t, u) |> Typ.fresh
| Some(u) => Ap(t, u) |> Typ.fresh_empty
};
};

Expand Down Expand Up @@ -581,22 +590,22 @@ and pat_term: unsorted => (Pat.term, list(Id.t)) = {
}
| tm => ret(hole(tm));
}
and typ = unsorted => {
and typ = (unsorted): Typ.t => {
let (term, inner_ids) = typ_term(unsorted);
let ids = ids(unsorted) @ inner_ids;
let t =
return(
ty => Typ(ty),
ids,
{
term,
term: Typ.empty(term),
annotation: {
ids: ids,
},
},
);
switch (term) {
| TupLabel(_) => Prod([t]) |> Typ.fresh
| TupLabel(_) => Prod([t]) |> Typ.fresh_empty
| _ => t
};
}
Expand All @@ -618,7 +627,7 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
| (["Nat"], []) => Atom(Nat)
| ([t], []) when Form.is_typ_var(t) => Var(t)
| (["(", ")"], [Typ(body)]) => Parens(body)
| (label, [Typ(body)]) when is_probe_wrap(label) => body.term
| (label, [Typ(body)]) when is_probe_wrap(label) => body.term.typ
| (["[", "]"], [Typ(body)]) => List(body)
| ([t], []) when is_hole_label(t) => hole(tm)
| ([t], []) => Unknown(Hole(Invalid(t)))
Expand All @@ -639,7 +648,7 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
ret(Forall(tpat, t))
| Pre(([(_id, (["rec", "->"], [TPat(tpat)]))], []), Typ(t)) =>
ret(Rec(tpat, t))
| Pre(tiles, Typ({term: Sum(t0), annotation: {ids, _}})) as tm =>
| Pre(tiles, Typ({term: {typ: Sum(t0), _}, annotation: {ids, _}})) as tm =>
/* Case for leading prefix + preceeding a sum */
switch (tiles) {
| ([(_, (["+"], []))], []) => (Sum(t0), ids)
Expand Down Expand Up @@ -671,7 +680,14 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
@ [r]
|> List.map((child: Typ.t) => {
switch (child) {
| {term: Prod([{term: TupLabel(_), _} as tl]), _} => tl
| {
term:
{
typ: Prod([{term: {typ: TupLabel(_), _}, _} as tl]),
_,
},
_,
} => tl
| _ => child
}
});
Expand All @@ -681,13 +697,13 @@ and typ_term: unsorted => (Typ.term, list(Id.t)) = {
switch (tiles) {
| ([(_id, (["->"], []))], []) => ret(Arrow(l, r))
| ([(_id, (["="], []))], []) =>
switch (l.term) {
switch (l.term.typ) {
| Var(name) =>
ret(
TupLabel(
{
annotation: l.annotation,
term: Label(name),
term: Typ.empty(Label(name)),
},
r,
),
Expand Down Expand Up @@ -864,7 +880,7 @@ let for_projection =
}
| Typ =>
switch (typ(unsorted)) {
| {term: Prod(_), _} => None
| {term: {typ: Prod(_), _}, _} => None
| _ => Some(Typ(typ(unsorted)))
}
| TPat =>
Expand Down
45 changes: 26 additions & 19 deletions src/haz3lcore/pretty/ExpToSegment.re
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ let external_precedence_typ = (tp: Typ.t) =>
| Unknown(Hole(MultiHole(_))) => Precedence.min
};

let external_precedence_Typ = (s: Typ.t) => {
s |> external_precedence_typ;
};

let paren_at = (internal_precedence: Precedence.t, exp: Exp.t): Exp.t =>
external_precedence(exp) >= internal_precedence
? Exp.fresh(Parens(exp)) : exp;
Expand All @@ -172,12 +176,21 @@ let paren_pat_assoc_at =

let paren_typ_at = (internal_precedence: Precedence.t, typ: Typ.t): Typ.t =>
external_precedence_typ(typ) >= internal_precedence
? Typ.fresh(Parens(typ)) : typ;
? Typ.fresh_empty(Parens(typ)) : typ;

let paren_typ_assoc_at =
(internal_precedence: Precedence.t, typ: Typ.t): Typ.t =>
external_precedence_typ(typ) > internal_precedence
? Typ.fresh(Parens(typ)) : typ;
? Typ.fresh_empty(Parens(typ)) : typ;

let paren_Typ_at = (internal_precedence: Precedence.t, typ: Typ.t): Typ.t =>
external_precedence_Typ(typ) >= internal_precedence
? Typ.fresh_empty(Parens(typ)) : typ;

let paren_Typ_assoc_at =
(internal_precedence: Precedence.t, typ: Typ.t): Typ.t =>
external_precedence_Typ(typ) > internal_precedence
? Typ.fresh_empty(Parens(typ)) : typ;

let rec parenthesize =
(~show_filters: bool, ~already_paren=false, exp: Exp.t): Exp.t => {
Expand Down Expand Up @@ -459,10 +472,13 @@ and parenthesize_pat =
}

and parenthesize_typ =
(~show_filters: bool, ~already_paren=false, typ: Typ.t): Typ.t => {
(~show_filters: bool, ~already_paren=false): (Typ.t => Typ.t) => {
Typ.map(parenthesize_typ_term(~show_filters, ~already_paren));
}
and parenthesize_typ_term =
(~show_filters: bool, ~already_paren=false, typ: Typ.term): Typ.term => {
let parenthesize_typ = parenthesize_typ(~show_filters);
let (term, rewrap) = Typ.unwrap(typ);
switch (term) {
switch (typ) {
// Indivisible forms dont' change
| Var(_)
| Unknown(Hole(Invalid(_)))
Expand All @@ -477,47 +493,40 @@ and parenthesize_typ =
parenthesize_typ(~already_paren=true, t)
|> paren_typ_at(Precedence.min),
)
|> rewrap
| List(t) =>
List(parenthesize_typ(t) |> paren_typ_at(Precedence.min)) |> rewrap

| List(t) => List(parenthesize_typ(t) |> paren_typ_at(Precedence.min))
| Prod([]) => typ
| Prod(ts) =>
let inner =
let inner: Typ.term =
Prod(
ts
|> List.map(parenthesize_typ)
|> List.map(paren_typ_at(Precedence.comma)),
)
|> rewrap;
already_paren ? inner : Parens(inner) |> Typ.fresh;
);
already_paren ? inner : Parens(inner |> Typ.fresh_empty);
| Label(_) => typ
| TupLabel(l, t) =>
TupLabel(l, parenthesize_typ(t) |> paren_typ_at(Precedence.min))
|> rewrap
| Ap(t1, t2) =>
Ap(
parenthesize_typ(t1) |> paren_typ_assoc_at(Precedence.type_sum_ap),
parenthesize_typ(t2) |> paren_typ_at(Precedence.min),
)
|> rewrap
| Rec(tp, t) =>
Rec(
tp,
parenthesize_typ(t) |> paren_typ_assoc_at(Precedence.type_binder),
)
|> rewrap
| Forall(tp, t) =>
Forall(
tp,
parenthesize_typ(t) |> paren_typ_assoc_at(Precedence.type_binder),
)
|> rewrap
| Arrow(t1, t2) =>
Arrow(
parenthesize_typ(t1) |> paren_typ_at(Precedence.type_arrow),
parenthesize_typ(t2) |> paren_typ_assoc_at(Precedence.type_arrow),
)
|> rewrap
| Sum(ts) =>
Sum(
ConstructorMap.map(
Expand All @@ -528,12 +537,10 @@ and parenthesize_typ =
ts,
),
)
|> rewrap
| Unknown(Hole(MultiHole(xs))) =>
Unknown(
Hole(MultiHole(List.map(parenthesize_any(~show_filters), xs))),
)
|> rewrap
};
}

Expand Down
Loading
Loading