Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/CLI/Print.re
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let exp_to_segment_settings: ExpToSegment.Settings.t = {
fold_case_clauses: false,
fold_fn_bodies: `NoFold,
hide_fixpoints: false,
show_ascriptions: true,
show_filters: true,
show_unknown_as_hole: true,
};
Expand Down
130 changes: 108 additions & 22 deletions src/haz3lcore/pretty/ExpToSegment.re
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Settings = {
],
hide_fixpoints: bool,
show_filters: bool,
show_ascriptions: bool,
show_unknown_as_hole: bool,
};

Expand All @@ -50,6 +51,7 @@ module Settings = {
parenthesization: Defensive,
label_format: QuoteWhenNecessary,
inline,
show_ascriptions: settings.evaluation.show_ascriptions,
fold_case_clauses: !settings.evaluation.show_case_clauses,
fold_fn_bodies:
fold_fn_bodies
Expand All @@ -69,6 +71,7 @@ module Settings = {
inline,
fold_case_clauses: false,
fold_fn_bodies: `NoFold,
show_ascriptions: true,
hide_fixpoints: false,
show_filters: true,
show_unknown_as_hole: true,
Expand Down Expand Up @@ -311,13 +314,17 @@ let rec parenthesize =
(
~parenthesization: Settings.parenthesization,
~show_filters: bool,
~show_ascriptions: bool,
~already_paren=false,
exp: Exp.t,
)
: Exp.t => {
let parenthesize = parenthesize(~parenthesization, ~show_filters);
let parenthesize_pat = parenthesize_pat(~parenthesization, ~show_filters);
let parenthesize_typ = parenthesize_typ(~parenthesization, ~show_filters);
let parenthesize =
parenthesize(~parenthesization, ~show_filters, ~show_ascriptions);
let parenthesize_pat =
parenthesize_pat(~parenthesization, ~show_filters, ~show_ascriptions);
let parenthesize_typ =
parenthesize_typ(~parenthesization, ~show_filters, ~show_ascriptions);
let paren_at = paren_at(~parenthesization);
let paren_assoc_at = paren_assoc_at(~parenthesization);
let paren_pat_at = paren_pat_at(~parenthesization);
Expand Down Expand Up @@ -499,12 +506,13 @@ let rec parenthesize =
parenthesize(e2) |> paren_assoc_at(Precedence.semi),
)
|> rewrap
| Asc(e, t) =>
| Asc(e, t) when show_ascriptions =>
Asc(
parenthesize(e) |> paren_assoc_at(Precedence.asc),
parenthesize_typ(t) |> paren_typ_at(Precedence.asc),
)
|> rewrap
| Asc(e, _) => parenthesize(e) // skip ascription if not showing
| Test(e) => Test(parenthesize(e) |> paren_at(Precedence.min)) |> rewrap
| HintedTest(e, hint) =>
HintedTest(parenthesize(e) |> paren_at(Precedence.min), hint) |> rewrap
Expand Down Expand Up @@ -565,7 +573,10 @@ let rec parenthesize =
|> rewrap
| MultiHole(xs) =>
MultiHole(
List.map(parenthesize_any(~parenthesization, ~show_filters), xs),
List.map(
parenthesize_any(~parenthesization, ~show_ascriptions, ~show_filters),
xs,
),
)
|> rewrap
};
Expand All @@ -574,12 +585,15 @@ and parenthesize_pat =
(
~parenthesization: Settings.parenthesization,
~show_filters: bool,
~show_ascriptions: bool,
~already_paren=false,
pat: Pat.t,
)
: Pat.t => {
let parenthesize_pat = parenthesize_pat(~parenthesization, ~show_filters);
let parenthesize_typ = parenthesize_typ(~parenthesization, ~show_filters);
let parenthesize_pat =
parenthesize_pat(~parenthesization, ~show_filters, ~show_ascriptions);
let parenthesize_typ =
parenthesize_typ(~parenthesization, ~show_filters, ~show_ascriptions);
let paren_pat_at = paren_pat_at(~parenthesization);
let paren_pat_assoc_at = paren_pat_assoc_at(~parenthesization);
let paren_typ_at = paren_typ_at(~parenthesization);
Expand Down Expand Up @@ -641,27 +655,33 @@ and parenthesize_pat =
|> rewrap
| MultiHole(xs) =>
MultiHole(
List.map(parenthesize_any(~parenthesization, ~show_filters), xs),
List.map(
parenthesize_any(~parenthesization, ~show_ascriptions, ~show_filters),
xs,
),
)
|> rewrap
| Asc(p, t) =>
| Asc(p, t) when show_ascriptions =>
Asc(
parenthesize_pat(p) |> paren_pat_assoc_at(Precedence.asc),
parenthesize_typ(t) |> paren_typ_at(Precedence.max) // Hack[Matt]: always add parens to get the arrows right
)
|> rewrap
| Asc(p, _) => parenthesize_pat(p) // skip ascription if not showing
};
}

and parenthesize_typ =
(
~parenthesization: Settings.parenthesization,
~show_filters: bool,
~show_ascriptions: bool,
~already_paren=false,
typ: Typ.t,
)
: Typ.t => {
let parenthesize_typ = parenthesize_typ(~parenthesization, ~show_filters);
let parenthesize_typ =
parenthesize_typ(~parenthesization, ~show_filters, ~show_ascriptions);
let paren_typ_at = paren_typ_at(~parenthesization);
let paren_typ_assoc_at = paren_typ_assoc_at(~parenthesization);
let paren_at = paren_at(~parenthesization);
Expand Down Expand Up @@ -749,7 +769,7 @@ and parenthesize_typ =
|> rewrap
| ProofOf(e) =>
ProofOf(
parenthesize(~parenthesization, ~show_filters, e)
parenthesize(~parenthesization, ~show_ascriptions, ~show_filters, e)
|> paren_at(Precedence.min),
)
|> rewrap
Expand All @@ -774,7 +794,14 @@ and parenthesize_typ =
Unknown(
Hole(
MultiHole(
List.map(parenthesize_any(~parenthesization, ~show_filters), xs),
List.map(
parenthesize_any(
~parenthesization,
~show_ascriptions,
~show_filters,
),
xs,
),
),
),
)
Expand All @@ -786,6 +813,7 @@ and parenthesize_tpat =
(
~parenthesization: Settings.parenthesization,
~show_filters: bool,
~show_ascriptions: bool,
tpat: TPat.t,
)
: TPat.t => {
Expand All @@ -799,7 +827,10 @@ and parenthesize_tpat =
// Other forms
| MultiHole(xs) =>
MultiHole(
List.map(parenthesize_any(~parenthesization, ~show_filters), xs),
List.map(
parenthesize_any(~parenthesization, ~show_ascriptions, ~show_filters),
xs,
),
)
|> rewrap
};
Expand All @@ -808,6 +839,7 @@ and parenthesize_tpat =
and parenthesize_rul =
(
~parenthesization: Settings.parenthesization,
~show_ascriptions: bool,
~show_filters: bool,
rul: Rul.t,
)
Expand All @@ -820,20 +852,33 @@ and parenthesize_rul =
// Other forms
| Rules(e, ps) =>
Rules(
parenthesize(~parenthesization, ~show_filters, e),
parenthesize(~parenthesization, ~show_ascriptions, ~show_filters, e),
List.map(
((p, e)) =>
(
parenthesize_pat(~parenthesization, ~show_filters, p),
parenthesize(~parenthesization, ~show_filters, e),
parenthesize_pat(
~parenthesization,
~show_ascriptions,
~show_filters,
p,
),
parenthesize(
~parenthesization,
~show_ascriptions,
~show_filters,
e,
),
),
ps,
),
)
|> rewrap
| MultiHole(xs) =>
MultiHole(
List.map(parenthesize_any(~parenthesization, ~show_filters), xs),
List.map(
parenthesize_any(~parenthesization, ~show_ascriptions, ~show_filters),
xs,
),
)
|> rewrap
};
Expand All @@ -844,22 +889,59 @@ and parenthesize_any =
~parenthesization: Settings.parenthesization,
~already_paren=false,
~show_filters: bool,
~show_ascriptions: bool,
any: Any.t,
)
: Any.t =>
switch (any) {
| Exp(e) =>
Exp(parenthesize(~parenthesization, ~already_paren, ~show_filters, e))
Exp(
parenthesize(
~parenthesization,
~already_paren,
~show_ascriptions,
~show_filters,
e,
),
)
| Pat(p) =>
Pat(
parenthesize_pat(~parenthesization, ~already_paren, ~show_filters, p),
parenthesize_pat(
~parenthesization,
~already_paren,
~show_ascriptions,
~show_filters,
p,
),
)
| Typ(t) =>
Typ(
parenthesize_typ(~parenthesization, ~already_paren, ~show_filters, t),
parenthesize_typ(
~parenthesization,
~already_paren,
~show_ascriptions,
~show_filters,
t,
),
)
| TPat(tp) =>
TPat(
parenthesize_tpat(
~parenthesization,
~show_ascriptions,
~show_filters,
tp,
),
)
| Rul(r) =>
Rul(
parenthesize_rul(
~parenthesization,
~show_ascriptions,
~show_filters,
r,
),
)
| TPat(tp) => TPat(parenthesize_tpat(~parenthesization, ~show_filters, tp))
| Rul(r) => Rul(parenthesize_rul(~parenthesization, ~show_filters, r))
| Any(_) => any
};

Expand Down Expand Up @@ -1258,6 +1340,7 @@ let rec exp_to_pretty = (~settings: Settings.t, exp: Exp.t): pretty => {
Pat.fresh(Asc(p, t))
|> parenthesize_pat(
~parenthesization=settings.parenthesization,
~show_ascriptions=settings.show_ascriptions,
~show_filters=settings.show_filters,
);
};
Expand Down Expand Up @@ -2114,6 +2197,7 @@ let exp_to_segment =
~parenthesization=settings.parenthesization,
~already_paren,
~show_filters=settings.show_filters,
~show_ascriptions=settings.show_ascriptions,
);
let p = exp_to_pretty(~settings, exp);
p |> PrettySegment.select;
Expand All @@ -2125,6 +2209,7 @@ let typ_to_segment = (~settings: Settings.t, typ: Typ.t): Segment.t => {
|> parenthesize_typ(
~parenthesization=settings.parenthesization,
~show_filters=settings.show_filters,
~show_ascriptions=settings.show_ascriptions,
);
let p = typ_to_pretty(~settings, typ);
p |> PrettySegment.select;
Expand All @@ -2138,6 +2223,7 @@ let any_to_segment =
~parenthesization=settings.parenthesization,
~already_paren,
~show_filters=settings.show_filters,
~show_ascriptions=settings.show_ascriptions,
);
let p = any_to_pretty(~settings, any);
p |> PrettySegment.select;
Expand Down
1 change: 1 addition & 0 deletions src/haz3lcore/zipper/action/Introduce.re
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ module Make =
label_format: QuoteWhenNecessary,
inline: true,
fold_case_clauses: false,
show_ascriptions: true,
fold_fn_bodies: `NoFold,
hide_fixpoints: false,
show_filters: true,
Expand Down
2 changes: 2 additions & 0 deletions src/language/CoreSettings.re
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Evaluation = {
show_fn_bodies: bool,
show_fixpoints: bool,
show_ascription_steps: bool,
show_ascriptions: bool,
show_case_steps: bool,
show_lookup_steps: bool,
show_stepper_filters: bool,
Expand All @@ -22,6 +23,7 @@ module Evaluation = {
show_fn_bodies: false,
show_fixpoints: false,
show_ascription_steps: false,
show_ascriptions: false,
show_case_steps: false,
show_lookup_steps: false,
show_stepper_filters: false,
Expand Down
6 changes: 6 additions & 0 deletions src/web/Settings.re
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Model = {
show_fn_bodies: false,
show_fixpoints: false,
show_ascription_steps: false,
show_ascriptions: false,
show_case_steps: false,
show_lookup_steps: false,
show_stepper_filters: false,
Expand Down Expand Up @@ -96,6 +97,7 @@ module Update = {
| ShowCaseClauses
| ShowFnBodies
| ShowAscriptionSteps
| ShowAscriptions
| ShowCaseSteps
| ShowFixpoints
| ShowLookups
Expand Down Expand Up @@ -210,6 +212,10 @@ module Update = {
...evaluation,
show_ascription_steps: !evaluation.show_ascription_steps,
}
| ShowAscriptions => {
...evaluation,
show_ascriptions: !evaluation.show_ascriptions,
}
| ShowCaseSteps => {
...evaluation,
show_case_steps: !evaluation.show_case_steps,
Expand Down
12 changes: 12 additions & 0 deletions src/web/app/editors/SettingsModal.re
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ let view =
settings.show_case_clauses,
Evaluation(ShowCaseClauses),
),
setting(
"⇨",
"show case steps",
settings.show_case_steps,
Evaluation(ShowCaseSteps),
),
setting(
"λ",
"show function bodies",
Expand All @@ -53,6 +59,12 @@ let view =
settings.show_fixpoints,
Evaluation(ShowFixpoints),
),
setting(
":",
"show ascriptions",
settings.show_ascriptions,
Evaluation(ShowAscriptions),
),
setting(
"⇨",
"show ascription steps",
Expand Down
Loading