Skip to content

Commit

Permalink
raco fmt + removed useless function
Browse files Browse the repository at this point in the history
  • Loading branch information
AYadrov committed Jan 20, 2025
1 parent b4cbf28 commit d49a1a6
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 62 deletions.
3 changes: 2 additions & 1 deletion src/core/programs.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
(define/contract (location-get loc prog)
(-> location? expr? expr?)
; Clever continuation usage to early-return
(let/ec return (location-do loc prog return)))
(let/ec return
(location-do loc prog return)))

(define/contract (replace-expression expr from to)
(-> expr? expr? expr? expr?)
Expand Down
11 changes: 0 additions & 11 deletions src/core/sampling.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@
(map (lambda (interval) (fpbench-ival->ival var-repr interval))
(range-table-ref range-table var-name)))))

(define (subsplit-hyperrects hyperrects var-reprs)
(for/fold ([storage '()]) ([hyperrect (in-list hyperrects)])
(append storage
(apply cartesian-product
(for/list ([range (in-list hyperrect)]
[repr (in-list var-reprs)])
(match (two-midpoints repr (ival-lo range) (ival-hi range))
[(cons midleft midright)
(list (ival (ival-lo range) midleft) (ival midright (ival-hi range)))]
[#f (list range)]))))))

(define (fpbench-ival->ival repr fpbench-interval)
(match-define (interval lo hi lo? hi?) fpbench-interval)
(match (representation-type repr)
Expand Down
30 changes: 15 additions & 15 deletions src/reports/history.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@

(define (splice-proof-step step)
(let/ec k
(let loop ([expr step]
[loc '()])
(match expr
[(list 'Rewrite=> rule sub)
(define loc* (reverse loc))
(k 'Rewrite=> rule loc* (location-do loc* step (λ _ sub)))]
[(list 'Rewrite<= rule sub)
(define loc* (reverse loc))
(k 'Rewrite<= rule loc* (location-do loc* step (λ _ sub)))]
[(list op args ...)
(for ([arg (in-list args)]
[i (in-naturals 1)])
(loop arg (cons i loc)))]
[_ (void)]))
(k 'Goal #f '() step)))
(let loop ([expr step]
[loc '()])
(match expr
[(list 'Rewrite=> rule sub)
(define loc* (reverse loc))
(k 'Rewrite=> rule loc* (location-do loc* step (λ _ sub)))]
[(list 'Rewrite<= rule sub)
(define loc* (reverse loc))
(k 'Rewrite<= rule loc* (location-do loc* step (λ _ sub)))]
[(list op args ...)
(for ([arg (in-list args)]
[i (in-naturals 1)])
(loop arg (cons i loc)))]
[_ (void)]))
(k 'Goal #f '() step)))

(define (altn-errors altn pcontext pcontext2 ctx)
(define repr (context-repr ctx))
Expand Down
16 changes: 8 additions & 8 deletions src/syntax/matcher.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
(and binding1
binding2
(let/ec quit
(for/fold ([binding binding1]) ([(k v) (in-dict binding2)])
(dict-update binding
k
(λ (x)
(if (equal? x v)
v
(quit #f)))
v)))))
(for/fold ([binding binding1]) ([(k v) (in-dict binding2)])
(dict-update binding
k
(λ (x)
(if (equal? x v)
v
(quit #f)))
v)))))

;; Pattern matcher that returns a substitution or #f.
;; A substitution is an association list of symbols and expressions.
Expand Down
54 changes: 27 additions & 27 deletions src/syntax/platform.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -472,38 +472,38 @@
;; Fails if the result is not well-typed.
(define (try-lower expr repr op->impl)
(let/ec k
(define env '())
(define expr*
(let loop ([expr expr]
[repr repr])
(match expr
[(? symbol? x) ; variable
(match (dict-ref env x #f)
[#f (set! env (cons (cons x repr) env))]
[(? (curry equal? repr)) (k #f env)]
[_ (void)])
x]
; number
[(? number? n) (literal n (representation-name repr))]
[(list 'if cond ift iff) ; if expression
(list 'if (loop cond (get-representation 'bool)) (loop ift repr) (loop iff repr))]
[(list op args ...) ; application
(define impl (dict-ref op->impl op))
(unless (equal? (impl-info impl 'otype) repr)
(k #f env))
(cons impl (map loop args (impl-info impl 'itype)))])))
(define ctx (context (map car env) repr (map cdr env)))
(values (and (equal? (repr-of expr* ctx) repr) expr*) env)))
(define env '())
(define expr*
(let loop ([expr expr]
[repr repr])
(match expr
[(? symbol? x) ; variable
(match (dict-ref env x #f)
[#f (set! env (cons (cons x repr) env))]
[(? (curry equal? repr)) (k #f env)]
[_ (void)])
x]
; number
[(? number? n) (literal n (representation-name repr))]
[(list 'if cond ift iff) ; if expression
(list 'if (loop cond (get-representation 'bool)) (loop ift repr) (loop iff repr))]
[(list op args ...) ; application
(define impl (dict-ref op->impl op))
(unless (equal? (impl-info impl 'otype) repr)
(k #f env))
(cons impl (map loop args (impl-info impl 'itype)))])))
(define ctx (context (map car env) repr (map cdr env)))
(values (and (equal? (repr-of expr* ctx) repr) expr*) env)))

;; Merges two variable -> value mappings.
;; If any mapping disagrees, the result is `#f`.
(define (merge-envs env1 env2)
(let/ec k
(for/fold ([env env1]) ([(x ty) (in-dict env2)])
(match (dict-ref env x #f)
[#f (cons (cons x ty) env)]
[(? (curry equal? ty)) env]
[_ (k #f)]))))
(for/fold ([env env1]) ([(x ty) (in-dict env2)])
(match (dict-ref env x #f)
[#f (cons (cons x ty) env)]
[(? (curry equal? ty)) env]
[_ (k #f)]))))

;; Synthesizes impl-to-impl rules for a given platform.
;; If a rule is over implementations, filters by supported implementations.
Expand Down

0 comments on commit d49a1a6

Please sign in to comment.