Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Componentization #1297

Draft
wants to merge 119 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
4722680
Separate out adding parentheses from printing
Negabinary Apr 30, 2024
679be52
Exp to Segment
Negabinary May 1, 2024
5e5213a
Merge branch 'remove-dhexp' into editor-output
Negabinary May 2, 2024
6d5907f
Move StepperView functions
Negabinary May 3, 2024
65a2456
Add whitespaces
Negabinary May 3, 2024
796d23c
Start multi-line pretty printing
Negabinary May 3, 2024
37478ee
Separate code from cell
Negabinary May 6, 2024
2ccb05c
Delete unused lines
Negabinary May 6, 2024
7a4fa25
Get closer (I think) to being able to select steps
Negabinary May 8, 2024
2a7cf79
parenthesize types and patterns
Negabinary May 10, 2024
2e14d35
Fix map2 error
Negabinary May 10, 2024
5f51503
Select other editors
Negabinary May 15, 2024
e1c8cde
Fix evaluation
Negabinary May 15, 2024
8225be9
Rename Editors selection
Negabinary May 15, 2024
f5e7dde
Add green highlights
Negabinary May 16, 2024
1fe65b5
Fix pasting not working
Negabinary May 16, 2024
4cb66df
Fix log serialization
Negabinary May 16, 2024
eab25e9
Fix test to segment
Negabinary May 17, 2024
f810f62
Make stepper update with elaboration
Negabinary May 17, 2024
5fb83bc
Create sub-models for editors
Negabinary May 21, 2024
da63054
Get stepper almost working again
Negabinary May 21, 2024
7b6855f
Fix stepper pointer events
Negabinary May 21, 2024
5a482b3
Delete DHDoc_Exp
Negabinary May 21, 2024
60df359
Moving and renaming
Negabinary May 21, 2024
7d3ff12
Factor out globals
Negabinary May 22, 2024
f99a8cb
Update style.css
Negabinary May 22, 2024
6774325
Fix selection of result
Negabinary May 22, 2024
bf5e3c8
Split up model, view, action
Negabinary Jun 4, 2024
f7e0929
Fixup
Negabinary Jun 6, 2024
798c3f5
Delete old web files
Negabinary Jun 6, 2024
1db9418
Move and tidy files
Negabinary Jun 6, 2024
56d2523
Update Makefile
Negabinary Jun 7, 2024
04bfefd
Fix copy/paste
Negabinary Jun 7, 2024
2ea39d9
Fix exercise cells resetting
Negabinary Jun 7, 2024
87f877d
Tidy up, add comments
Negabinary Jun 12, 2024
7a8b3ce
Fix evaluation of school mode
Negabinary Jun 12, 2024
ca73929
Merge branch 'remove-dhexp' into editor-output-submodel
Negabinary Jun 12, 2024
67b3b9b
Update EvaluatorStep.re
Negabinary Jun 12, 2024
d5f4b31
Bring back elaboration
Negabinary Jun 13, 2024
a1525ec
Fix linebreaks in pretty printer
Negabinary Jun 13, 2024
799a63d
Bring back stepper
Negabinary Jun 13, 2024
e56ac11
Substitute through closures before printing
Negabinary Jun 13, 2024
62c9fd5
Add Updated.t to Stepper
Negabinary Jun 13, 2024
3283c45
Stepper updates when elaboration changes
Negabinary Jun 13, 2024
0b7dc7d
Remove slow print statement
Negabinary Jun 13, 2024
2f5f743
Re-use pretty printing code to display types
Negabinary Jun 17, 2024
5155a74
Add ranges to stepper highlights
Negabinary Jul 1, 2024
f17cee7
Pre-substitute expressions before printing them
Negabinary Jul 1, 2024
1330482
Merge branch 'remove-dhexp' into editor-output
Negabinary Jul 9, 2024
2cc8e30
Prevent unbound variable capture when printing without closures
Negabinary Jul 9, 2024
fd092db
Fix variables that shouldn't be unbound becoming unbound
Negabinary Jul 9, 2024
ad48b8a
Update Term.re
Negabinary Jul 9, 2024
f2dda97
fix ExplainThis dropdown
Negabinary Jul 9, 2024
06a54ea
Bring back exercises mode
Negabinary Jul 9, 2024
05a9f2f
ctx display perf
Negabinary Jul 10, 2024
0eaf48a
Merge branch 'remove-dhexp' into editor-output
Negabinary Jul 31, 2024
02d822d
Merge Haz3lschool into Haz3lweb 1
Negabinary Aug 1, 2024
be680b5
Merge Haz3lschool into Haz3lweb 2
Negabinary Aug 1, 2024
c3b8d80
Uncomment Gradescope
Negabinary Aug 1, 2024
7a17fd1
Fix YourTestsTesting
Negabinary Aug 1, 2024
56a64dc
Fix school mode evaluation
Negabinary Aug 2, 2024
3aa8c12
Fix reverse application in MakeTerm
Negabinary Aug 2, 2024
d11fe19
Fix reverse application in ExpToSegment
Negabinary Aug 2, 2024
b4a6bf5
Fix MultiHole printing
Negabinary Aug 2, 2024
0de7214
Merge remote-tracking branch 'origin/dev' into editor-output
Negabinary Aug 2, 2024
5b44f3d
Begin trying to get source maps working
7h3kk1d Aug 4, 2024
73df3a6
revert diag
7h3kk1d Aug 4, 2024
ecf27fc
Add type annotations to expressions
Negabinary Aug 5, 2024
c119bb2
Fix type id duplication
Negabinary Aug 5, 2024
b4f87cb
re-enable clicking on steps
Negabinary Aug 5, 2024
c4a6759
Change type assignment precedence
Negabinary Aug 5, 2024
a7eb074
Merge remote-tracking branch 'origin/ab-source-maps' into editor-output
Negabinary Aug 5, 2024
5d188e3
Fix exceptions
Negabinary Aug 5, 2024
21f66be
Fix typing of constructors in casts
Negabinary Aug 6, 2024
0f2af3d
Make sure type ids are unique in elaboration
Negabinary Aug 6, 2024
c5e01f9
Make cast id allocation deterministic
Negabinary Aug 6, 2024
2516892
closure substitution perf
Negabinary Aug 6, 2024
ef2ad69
Make holes appear in cursor inspector types
Negabinary Aug 6, 2024
2f162c4
Speed up elaborator
Negabinary Aug 7, 2024
fcce6d8
Stop pretending to pretty-print
Negabinary Aug 7, 2024
b01ca16
Stop pretending to pretty-print
Negabinary Aug 7, 2024
9d9e941
Merge branch 'editor-output' of https://github.com/hazelgrove/hazel i…
Negabinary Aug 7, 2024
208a146
Update precedences
Negabinary Aug 8, 2024
a9fbdec
Lazy recalculation for stepper
Negabinary Aug 8, 2024
9c1aa0b
Merge branch 'dev' into editor-output
Negabinary Aug 8, 2024
ddfcf50
Merge Fixup
Negabinary Aug 13, 2024
b0f19a6
Fix projectors not taking mouse events
Negabinary Aug 15, 2024
1da256f
re-separate statics
Negabinary Aug 15, 2024
cae69d0
Move elaborator into statics
Negabinary Aug 15, 2024
0212cf7
Hide function bodies, case clauses, etc
Negabinary Aug 16, 2024
3280b0d
folding for casts
Negabinary Aug 16, 2024
c11fc49
Merge branch 'dev' into editor-output
Negabinary Aug 17, 2024
d727d4d
Merge fixup
Negabinary Aug 20, 2024
7a01236
css fixup
Negabinary Aug 20, 2024
13e456c
Merge branch 'dev' into editor-output
Negabinary Aug 20, 2024
7b39c43
Fix selections printing as buffer
Negabinary Aug 21, 2024
5249dc3
Fix precedences of type +
Negabinary Aug 21, 2024
2da492e
Remove cursor from hidden things in results
Negabinary Aug 21, 2024
92b9c7b
Run statics on results again
Negabinary Aug 21, 2024
c05ab52
Fix stepper tile css
Negabinary Aug 21, 2024
ff63f38
Move stepper buttons back to the right
Negabinary Aug 22, 2024
64eaf14
Remove left border from text cells
Negabinary Aug 22, 2024
f586773
Fix exercises caption formatting
Negabinary Aug 22, 2024
11a05de
make prelude selectable
Negabinary Aug 22, 2024
b1d528f
Fix test validation feedback
Negabinary Aug 22, 2024
c9c2644
Make result printing update with settings
Negabinary Aug 23, 2024
ec8305f
Fix exercise mode editor crashes
Negabinary Aug 28, 2024
2f6b06d
Make plus signs in types escape sort
Negabinary Sep 4, 2024
55401fe
Selection in steppers
Negabinary Sep 6, 2024
c073cc7
Bring back tab
Negabinary Sep 6, 2024
4c67b01
Merge branch 'editor-output' of https://github.com/hazelgrove/hazel i…
Negabinary Sep 6, 2024
bea61b7
Merge branch 'dev' into editor-output
Negabinary Sep 6, 2024
39d0fa8
Selection of results
Negabinary Sep 6, 2024
756930f
Remove space between partheneses
Negabinary Sep 17, 2024
c4fde71
Bring back function names
Negabinary Sep 18, 2024
d78ebc6
"Fix" export (to parity with dev)
Negabinary Sep 18, 2024
d69d4d0
Fix autocomplete weirdness
Negabinary Sep 27, 2024
0d6d6c3
Fix selection in steps
Negabinary Oct 11, 2024
6539f35
Make test results less jumpy
Negabinary Oct 11, 2024
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ change-deps:
sed -i'.old' '/host-/d' hazel.opam.locked # remove host- lines which are arch-specific. Not using -i '' because of portability issues https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux

setup-instructor:
cp src/haz3lweb/ExerciseSettings_instructor.re src/haz3lweb/ExerciseSettings.re
cp src/haz3lweb/exercises/settings/ExerciseSettings_instructor.re src/haz3lweb/exercises/settings/ExerciseSettings.re

setup-student:
cp src/haz3lweb/ExerciseSettings_student.re src/haz3lweb/ExerciseSettings.re
cp src/haz3lweb/exercises/settings/ExerciseSettings_student.re src/haz3lweb/exercises/settings/ExerciseSettings.re

dev-helper:
dune fmt --auto-promote || true
Expand Down
15 changes: 12 additions & 3 deletions src/haz3lcore/dynamics/Casts.re
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,28 @@ let rec transition = (~recursive=false, d: DHExp.t): option(DHExp.t) => {

| (Hole, NotGroundOrHole(t2_grounded)) =>
/* ITExpand rule */
let inner_cast = Cast(d1, t1, t2_grounded) |> DHExp.fresh;
let inner_cast =
Cast(d1, t1, t2_grounded |> DHExp.replace_all_ids_typ) |> DHExp.fresh;
// HACK: we need to check the inner cast here
let inner_cast =
switch (transition(~recursive, inner_cast)) {
| Some(d1) => d1
| None => inner_cast
};
Some(DHExp.Cast(inner_cast, t2_grounded, t2) |> DHExp.fresh);
Some(
DHExp.Cast(inner_cast, t2_grounded |> DHExp.replace_all_ids_typ, t2)
|> DHExp.fresh,
);

| (NotGroundOrHole(t1_grounded), Hole) =>
/* ITGround rule */
Some(
DHExp.Cast(Cast(d1, t1, t1_grounded) |> DHExp.fresh, t1_grounded, t2)
DHExp.Cast(
Cast(d1, t1, t1_grounded |> DHExp.replace_all_ids_typ)
|> DHExp.fresh,
t1_grounded |> DHExp.replace_all_ids_typ,
t2,
)
|> DHExp.fresh,
)

Expand Down
44 changes: 36 additions & 8 deletions src/haz3lcore/dynamics/DHExp.re
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ let mk = (ids, term): t => {
{ids, copied: true, term};
};

// TODO: make this function emit a map of changes
let replace_all_ids =
map_term(
~f_exp=(continue, exp) => {...exp, ids: [Id.mk()]} |> continue,
~f_pat=(continue, exp) => {...exp, ids: [Id.mk()]} |> continue,
~f_typ=(continue, exp) => {...exp, ids: [Id.mk()]} |> continue,
~f_tpat=(continue, exp) => {...exp, ids: [Id.mk()]} |> continue,
~f_rul=(continue, exp) => {...exp, ids: [Id.mk()]} |> continue,
let (replace_all_ids, replace_all_ids_typ) = {
let f:
'a.
(IdTagged.t('a) => IdTagged.t('a), IdTagged.t('a)) => IdTagged.t('a)
=
(continue, exp) => {...exp, ids: [Id.mk()]} |> continue;
(
map_term(~f_exp=f, ~f_pat=f, ~f_typ=f, ~f_tpat=f, ~f_rul=f),
Typ.map_term(~f_exp=f, ~f_pat=f, ~f_typ=f, ~f_tpat=f, ~f_rul=f),
);
};

// TODO: make this function emit a map of changes
let repair_ids =
Expand All @@ -34,6 +36,32 @@ let repair_ids =
} else {
continue(exp);
},
~f_typ=
(continue, typ) =>
if (Typ.rep_id(typ) == Id.invalid) {
replace_all_ids_typ(typ);
} else {
continue(typ);
},
_,
);

let repair_ids_typ =
Typ.map_term(
~f_exp=
(continue, exp) =>
if (Exp.rep_id(exp) == Id.invalid) {
replace_all_ids(exp);
} else {
continue(exp);
},
~f_typ=
(continue, typ) =>
if (typ.copied) {
replace_all_ids_typ(typ);
} else {
continue(typ);
},
_,
);

Expand Down
20 changes: 0 additions & 20 deletions src/haz3lcore/dynamics/DHPat.re
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,3 @@ let rec binds_var = (m: Statics.Map.t, x: Var.t, dp: t): bool =>
| Ap(_, _) => false
}
};

let rec bound_vars = (dp: t): list(Var.t) =>
switch (dp |> term_of) {
| EmptyHole
| MultiHole(_)
| Wild
| Invalid(_)
| Int(_)
| Float(_)
| Bool(_)
| String(_)
| Constructor(_) => []
| Cast(y, _, _)
| Parens(y) => bound_vars(y)
| Var(y) => [y]
| Tuple(dps) => List.flatten(List.map(bound_vars, dps))
| Cons(dp1, dp2) => bound_vars(dp1) @ bound_vars(dp2)
| ListLit(dps) => List.flatten(List.map(bound_vars, dps))
| Ap(_, dp1) => bound_vars(dp1)
};
40 changes: 19 additions & 21 deletions src/haz3lcore/dynamics/Evaluator.re
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
open Transition;

module Result = {
[@deriving (show({with_path: false}), sexp, yojson)]
type t =
| BoxedValue(DHExp.t)
| Indet(DHExp.t);

let unbox =
fun
| BoxedValue(d)
| Indet(d) => d;

let fast_equal = (r1, r2) =>
switch (r1, r2) {
| (BoxedValue(d1), BoxedValue(d2))
| (Indet(d1), Indet(d2)) => DHExp.fast_equal(d1, d2)
| _ => false
};
};

open Result;
open ProgramResult.Result;

module EvaluatorEVMode: {
type status =
Expand Down Expand Up @@ -132,7 +113,7 @@ let rec evaluate = (state, env, d) => {
};
};

let evaluate = (env, {d}: Elaborator.Elaboration.t) => {
let evaluate' = (env, {d, _}: Elaborator.Elaboration.t) => {
let state = ref(EvaluatorState.init);
let env = ClosureEnvironment.of_environment(env);
let result = evaluate(state, env, d);
Expand All @@ -144,3 +125,20 @@ let evaluate = (env, {d}: Elaborator.Elaboration.t) => {
};
(state^, result);
};

let evaluate =
(~settings: CoreSettings.t, ~env=Builtins.env_init, elab: DHExp.t)
: ProgramResult.t(ProgramResult.inner) =>
switch () {
| _ when !settings.dynamics => Off({d: elab})
| _ =>
switch (evaluate'(env, {d: elab})) {
| exception (EvaluatorError.Exception(reason)) =>
print_endline("EvaluatorError:" ++ EvaluatorError.show(reason));
ResultFail(EvaulatorError(reason));
| exception exn =>
print_endline("EXN:" ++ Printexc.to_string(exn));
ResultFail(UnknownException(Printexc.to_string(exn)));
| (state, result) => ResultOk({result, state})
}
};
Loading
Loading