Skip to content

Commit

Permalink
Finish converting gen_exp to let notation
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Dec 22, 2024
1 parent d220808 commit 423d874
Showing 1 changed file with 12 additions and 35 deletions.
47 changes: 12 additions & 35 deletions src/haz3lmenhir/AST.re
Original file line number Diff line number Diff line change
Expand Up @@ -366,42 +366,19 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
CaseExp(e, Array.to_list(cases));
},
{
let e = self(n - 1 / 2);
let case = n => {
let p = gen_pat_sized(n / 2);
let e = self(n / 2);
tup2(p, e);
};

let cases =
sized_arr(n - 1 / 2)
>>= (
sizes => {
let cases: t(array((pat, exp))) =
flatten_a(Array.map(case, sizes));
cases;
}
);
tup2(e, cases)
>|= (
((e, cases)) => {
CaseExp(e, Array.to_list(cases));
}
);
let* e1 = self((n - 1) / 2);
let+ e2 =
frequency([
(5, self((n - 1) / 2)),
(1, return(Deferral)),
]);
ApExp(e1, e2);
},
{
let* p = gen_pat_sized((n - 1) / 2);
let+ e = self((n - 1) / 2);
FixF(p, e);
},
map2(
(e1, e2) => ApExp(e1, e2),
self((n - 1) / 2),
frequency([
(5, self((n - 1) / 2)),
(1, return(Deferral)),
]),
),
map2(
(p, e) => FixF(p, e),
gen_pat_sized((n - 1) / 2),
self((n - 1) / 2),
),
{
let* fa = gen_filter_action;
let* e1 = self(n - 1);
Expand Down

0 comments on commit 423d874

Please sign in to comment.