Skip to content
Merged
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
9 changes: 5 additions & 4 deletions typed-racket-lib/typed-racket/env/signature-env.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
signature-env-map
signature-env-for-each)

(require syntax/private/id-table
(require (for-syntax racket/base
syntax/parse)
racket/promise
(for-syntax syntax/parse racket/base)
"env-utils.rkt"
syntax/private/id-table
"../rep/type-rep.rkt"
"../utils/tc-utils.rkt"
"../rep/type-rep.rkt")
"env-utils.rkt")

;; initial signature environment
(define signature-env (make-free-id-table))
Expand Down
44 changes: 21 additions & 23 deletions typed-racket-lib/typed-racket/env/type-alias-helper.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@

;; This module provides helper functions for type aliases

(require "../utils/utils.rkt"
"../utils/tarjan.rkt"
"../utils/tc-utils.rkt"
"type-alias-env.rkt"
"type-name-env.rkt"
"../rep/type-rep.rkt"
"../rep/free-variance.rkt"
"../rep/type-constr.rkt"
"tvar-env.rkt"
"type-constr-env.rkt"
"../private/parse-type.rkt"
"../private/user-defined-type-constr.rkt"
"../typecheck/internal-forms.rkt"
"../types/resolve.rkt"
"../types/base-abbrev.rkt"
"../types/substitute.rkt"
(require (for-template racket/base
"../typecheck/internal-forms.rkt")
racket/dict
racket/function
racket/list
racket/match
racket/set
racket/dict
racket/function
syntax/id-table
syntax/parse
(for-template
"../typecheck/internal-forms.rkt"
racket/base))
"../private/parse-type.rkt"
"../private/user-defined-type-constr.rkt"
"../rep/free-variance.rkt"
"../rep/type-constr.rkt"
"../rep/type-rep.rkt"
"../typecheck/internal-forms.rkt"
"../types/base-abbrev.rkt"
"../types/resolve.rkt"
"../types/substitute.rkt"
"../utils/tarjan.rkt"
"../utils/tc-utils.rkt"
"../utils/utils.rkt"
"tvar-env.rkt"
"type-alias-env.rkt"
"type-constr-env.rkt"
"type-name-env.rkt")

(provide find-strongly-connected-type-aliases
register-all-type-aliases
Expand Down Expand Up @@ -304,8 +303,7 @@
(match-define (list id type-stx args) record)
(define ty-op (parse-type-operator-abstraction id args type-stx
(lambda (x)
(define res (in-same-component? id x))
res)
(in-same-component? id x))
type-alias-productivity-map
#:delay-variances? #t
#:recursive? #t))
Expand Down
107 changes: 54 additions & 53 deletions typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
;; - fix datum-literals ?
;; - enable type-annotation test by upgrading user's annotations to trust codomain

(require
"../test-utils.rkt"
rackunit
racket/pretty
racket/list
racket/set
syntax/parse
(only-in racket/format ~a)
(only-in syntax/modread with-module-reading-parameterization))
(require racket/list
racket/pretty
racket/set
rackunit
syntax/parse
(only-in racket/format ~a)
(only-in syntax/modread with-module-reading-parameterization)
"../test-utils.rkt")
Comment on lines +7 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This require form seemed to trip up Resyntax for some reason. The output looks nice, but Resyntax ran 10 passes and kept repeatedly trying to tidy these requires. Not sure what's up with that.


(provide tests)
(gen-test-main)
Expand All @@ -29,10 +28,8 @@
(with-module-reading-parameterization
(lambda ()
(read-syntax (object-name in-port) in-port))))))
(define stx
(parameterize ((current-namespace (make-base-namespace)))
(expand mod-stx)))
stx)
(parameterize ([current-namespace (make-base-namespace)])
(expand mod-stx)))

;; ---

Expand All @@ -49,20 +46,25 @@

(define (stx-find orig-stx p?)
(define stx* (stx-find* orig-stx p?))
(if (or (null? stx*)
(not (null? (cdr stx*))))
(raise-arguments-error 'stx-find "non-unique results" "num matches" (length stx*) "orig-stx" orig-stx "predicate" p? "matches" stx*)
(car stx*)))
(when (or (null? stx*) (not (null? (cdr stx*))))
(raise-arguments-error 'stx-find
"non-unique results"
"num matches"
(length stx*)
"orig-stx"
orig-stx
"predicate"
p?
"matches"
stx*))
(car stx*))

(define (stx-find* orig-stx p?)
(let loop ((stx orig-stx))
(cond
[(syntax? stx)
(let ((v (p? stx)))
(if v
(list
(if (eq? #true v) stx v))
(loop (syntax-e stx))))]
(define v (p? stx))
(if v (list (if (eq? #true v) stx v)) (loop (syntax-e stx)))]
[(pair? stx)
(append (loop (car stx)) (loop (cdr stx)))]
[else
Expand All @@ -79,37 +81,36 @@
((~literal #%plain-app) (~datum shallow-shape-check) . _)))

(define (stx-find-define-predicate-ctc stx pred-name)
(let* ((lift-id
(stx-find stx
(syntax-parser
#:datum-literals (define-values let-values #%app)
((define-values (name:id) (let-values (((:id) (#%app fcp:id lift:id))) _))
#:when (eq? (syntax-e #'name) pred-name)
#'lift)
(_ #f))
))
(lift-ctc
(stx-find stx
(syntax-parser
(((~datum define-values) (lt:id) ctc:id)
#:when (eq? (syntax-e #'lt) (syntax-e lift-id))
#'ctc)
(_ #f))))
(ctc*
(stx-find* stx
(syntax-parser
#:datum-literals (define-values lambda)
((define-values (g:id) (lambda (_) body))
#:when (eq? (syntax-e #'g) (syntax-e lift-ctc))
#'body)
(_ #f)))))
(cond
[(null? ctc*)
lift-ctc]
[(null? (cdr ctc*))
(car ctc*)]
[else
(raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)])))
(define lift-id
(stx-find stx
(syntax-parser
#:datum-literals (define-values let-values #%app)
[(define-values (name:id)
(let-values ([(:id) (#%app fcp:id lift:id)])
_))
#:when (eq? (syntax-e #'name) pred-name)
#'lift]
[_ #f])))
(define lift-ctc
(stx-find stx
(syntax-parser
[((~datum define-values) (lt:id) ctc:id)
#:when (eq? (syntax-e #'lt) (syntax-e lift-id))
#'ctc]
[_ #f])))
(define ctc*
(stx-find* stx
(syntax-parser
#:datum-literals (define-values lambda)
[(define-values (g:id) (lambda (_) body))
#:when (eq? (syntax-e #'g) (syntax-e lift-ctc))
#'body]
[_ #f])))
(cond
[(null? ctc*) lift-ctc]
[(null? (cdr ctc*)) (car ctc*)]
[else
(raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)]))

(define (split-shape-check stx)
(define expr (->datum stx))
Expand Down