Skip to content

Commit 2fe2ef7

Browse files
committed
Refactor transition_multiple to return samples and update usage in PatternMatch and Unboxing
1 parent 4e8afeb commit 2fe2ef7

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

src/language/dynamics/transition/Ascriptions.re

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,4 @@ let rec transition_multiple =
302302
| Some(d'') => transition_multiple(~targets, d'')
303303
| None => SampleWriter.return(d)
304304
};
305-
};
306-
307-
// TODO return samples
308-
let transition_multiple = (~targets: Sample.targets, d: DHExp.t): DHExp.t =>
309-
snd(transition_multiple(~targets, d));
305+
};

src/language/dynamics/transition/PatternMatch.re

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ let match_pattern =
7474
| Parens(p)
7575
| Projector(_, p) => recur(p, d)
7676
| Asc(p, t1) =>
77-
recur(
78-
p,
79-
Ascriptions.transition_multiple(~targets, Asc(d, t1) |> DHExp.fresh),
80-
)
77+
let (_samples, d') =
78+
Ascriptions.transition_multiple(~targets, Asc(d, t1) |> DHExp.fresh);
79+
recur(p, d');
8180
};
8281

8382
/* Record a sample closure if this pattern is targeted and matched */
@@ -118,7 +117,7 @@ let rec matches_inner =
118117
d: DHExp.t,
119118
)
120119
: match_result => {
121-
let d = Ascriptions.transition_multiple(~targets, d);
120+
let (_samples, d) = Ascriptions.transition_multiple(~targets, d);
122121
let pat_id = Pat.rep_id(dp);
123122
let maybe_spec = Id.Map.find_opt(pat_id, targets);
124123
let recur = matches_inner(targets, sample_closures);

src/language/dynamics/transition/Unboxing.re

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ let rec unbox: type a. (unbox_request(a), DHExp.t) => unboxed(a) =
131131
| (LabeledTupleEntries, Tuple(ds)) =>
132132
let unbox_tup_label =
133133
(d: Exp.t): option((option(LabeledTuple.label), Exp.t)) => {
134+
// TODO Samples
134135
switch (
135-
Ascriptions.transition_multiple(~targets=Sample.no_targets, d).term
136+
snd(Ascriptions.transition_multiple(~targets=Sample.no_targets, d)).
137+
term
136138
) {
137139
// TODO Think about whether we should transition here
138140
| TupLabel({term: Label(l), _}, e) => Some((Some(l), e))

0 commit comments

Comments
 (0)