Skip to content

Commit 1a2a641

Browse files
committed
a nice rewrite
1 parent b5f7f5d commit 1a2a641

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/core/mainloop.rkt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221

222222
;; Converts a patch to full alt with valid history
223223
(define (reconstruct! alts)
224+
224225
;; extracts the base expression of a patch
225226
(define (get-starting-expr altn)
226227
(match* ((alt-event altn) (alt-prevs altn))
@@ -240,19 +241,16 @@
240241
[(list 'taylor name var) (list 'taylor loc0 name var)]
241242
[(list 'rr input proof soundiness) (list 'rr loc0 input proof soundiness)]
242243
[(list 'simplify input proof soundiness) (list 'simplify loc0 input proof soundiness)]))
243-
(define expr* (location-do loc0 (alt-expr orig) (const (alt-expr altn))))
244+
(define expr* (location-do loc0 (alt-expr orig) (const (batchref->expr (alt-expr altn)))))
244245
(alt expr* event* (list (loop (first prevs))) (alt-preprocessing orig))])))
245246

246247
(^patched^ (reap [sow]
247248
(for ([altn (in-list alts)]) ;; does not have preproc
248249
(define start-expr (get-starting-expr altn))
249-
(if start-expr
250-
(for ([full-altn (in-list (^next-alts^))])
251-
(define expr (alt-expr full-altn))
252-
(for ([loc (in-list (get-locations expr start-expr))])
253-
(sow (reconstruct-alt altn loc full-altn))))
254-
; altn is a full alt (probably iter 0 simplify)
255-
(sow altn)))))
250+
(for ([full-altn (in-list (^next-alts^))])
251+
(define expr (alt-expr full-altn))
252+
(for ([loc (in-list (get-locations expr start-expr))])
253+
(sow (reconstruct-alt altn loc full-altn)))))))
256254

257255
(void))
258256

src/core/patch.rkt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,4 @@
203203

204204
(define out (append approximations rewritten))
205205

206-
(define (rebuild-alts x)
207-
(match-define (alt expr event prevs preprocessing) x)
208-
(alt (batchref->expr expr) event (map rebuild-alts prevs) preprocessing))
209-
210-
(map rebuild-alts out))
206+
out)

0 commit comments

Comments
 (0)