Skip to content

Commit db3322d

Browse files
committed
Merge branch 'master' of github.com:joergen7/typed-racket
2 parents 6e4e61b + 87fb4d5 commit db3322d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+933
-678
lines changed

typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,15 @@ To see how to declare a type for @racket[add-map], see the
225225
[for-clause [id : t seq-expr]
226226
[(binding ...) seq-expr]
227227
[id seq-expr]
228-
@code:line[#:when guard]]
228+
@code:line[#:when guard]
229+
@code:line[#:unless guard]
230+
@code:line[#:do [do-body ...]]
231+
break-clause
232+
@code:line[#:splice (splicing-id . form)]]
229233
[binding id
230-
[id : t]])]{
234+
[id : t]]
235+
[break-clause @code:line[#:break guard]
236+
@code:line[#:final guard]])]{
231237
Like @|for-id| from @racketmodname[racket/base], but each @racket[id] has the associated type
232238
@racket[t]. The latter @racket[_ann-maybe] will be used first, and then the previous one.
233239
Since the return type is always @racket[Void],

typed-racket-doc/typed-racket/scribblings/reference/types.scrbl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ corresponding to @racket[trest], where @racket[bound]
352352
@deftypeconstr[(MListof t)]{Returns the type of a homogeneous @rtech{mutable list} of @racket[t].}
353353
@deftypeconstr[(MPairof t u)]{Returns the type of a @rtech{Mutable pair} of @racket[t] and @racket[u].}
354354

355+
@deftypeconstr[(TreeListof t)]{Returns the type of @rtech{treelist} of @racket[t]}
356+
355357
@deftype[MPairTop]{Is the type of a @rtech{mutable pair} with unknown
356358
element types and is the supertype of all mutable pair types.
357359
This type typically appears in programs via the combination of

typed-racket-lib/typed-racket/HISTORY.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
8.16
2+
- Add `case-λ` as an alias for `case-lambda`
3+
- Bug fixes and type updates.
4+
8.15
5+
- Bug fixes and type updates.
16
8.14
27
- Bug fixes and type updates.
38
8.13

typed-racket-lib/typed-racket/base-env/annotate-classes.rkt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
#:with ty #'t))
170170
(define-splicing-syntax-class optional-standalone-annotation
171171
(pattern (~optional a:standalone-annotation)
172-
#:attr ty (if (attribute a) #'a.ty #f)))
172+
#:attr ty (and (attribute a) #'a.ty)))
173173

174174
(define-syntax-class type-variables
175175
#:attributes ((vars 1))
@@ -330,10 +330,8 @@
330330
(define-values (all-mand-tys all-opt-tys)
331331
(cond
332332
[kw-property
333-
(define-values (mand-kw-set opt-kw-set)
334-
(values
335-
(list->set (lambda-kws-mand kw-property))
336-
(list->set (lambda-kws-opt kw-property))))
333+
(define mand-kw-set (list->set (lambda-kws-mand kw-property)))
334+
(define opt-kw-set (list->set (lambda-kws-opt kw-property)))
337335

338336
(define-values (mand-tys^ opt-kw^)
339337
(partition (part-pred opt-kw-set)

typed-racket-lib/typed-racket/base-env/base-env.rkt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
racket/unsafe/ops
99
racket/unsafe/undefined
1010
racket/hash
11+
racket/treelist
1112
(only-in racket/extflonum floating-point-bytes->extfl extfl->floating-point-bytes)
1213
;(only-in rnrs/lists-6 fold-left)
1314
'#%paramz
@@ -1294,6 +1295,56 @@
12941295

12951296
[unsafe-undefined -Unsafe-Undefined]
12961297

1298+
;; Section 4.21 (TreeLists)
1299+
1300+
[treelist (-poly (a) (->* (list) a (-treelist a)))]
1301+
[treelist-empty? (-> (-treelist Univ) B)]
1302+
[treelist-length (-> (-treelist Univ) -Index)]
1303+
[treelist-member?
1304+
(-poly (a)
1305+
(cl->* ((-treelist a) a . -> . Univ)
1306+
((-treelist a) a (-> a a Univ) . -> . B)))]
1307+
[treelist-first (-poly (a) (-> (-treelist a) a :T+ #f))]
1308+
[treelist-last (-poly (a) (-> (-treelist a) a :T+ #f))]
1309+
[treelist-rest (-poly (a) (-> (-treelist a) (-treelist a)))]
1310+
[treelist-add (-poly (a) (-> (-treelist a) a (-treelist a)))]
1311+
[treelist-cons (-poly (a) (-> (-treelist a) a (-treelist a)))]
1312+
[treelist-delete (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
1313+
[make-treelist (-poly (a) (-> -Nat a (-treelist a)))]
1314+
[treelist-ref (-poly (a) (-> (-treelist a) -Index a :T+ #f))]
1315+
[treelist-insert (-poly (a) (-> (-treelist a) -Index a (-treelist a)))]
1316+
[treelist-set (-poly (a) (-> (-treelist a) -Index a (-treelist a)))]
1317+
[treelist-take (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
1318+
[treelist-drop (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
1319+
[treelist-take-right (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
1320+
[treelist-drop-right (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
1321+
[treelist-sublist (-poly (a) (-> (-treelist a) -Index -Index (-treelist a)))]
1322+
[treelist-reverse (-poly (a) (-> (-treelist a) (-treelist a)))]
1323+
[treelist->list (-poly (a) (-> (-treelist a) (-lst a)))]
1324+
[list->treelist (-poly (a) (-> (-lst a) (-treelist a)))]
1325+
[treelist->vector (-poly (a) (-> (-treelist a) (-vec a)))]
1326+
[vector->treelist (-poly (a) (-> (-vec a) (-treelist a)))]
1327+
[in-treelist (-poly (a) (-> (-treelist a) (-seq a)))]
1328+
[treelist? (unsafe-shallow:make-pred-ty (-treelist Univ))]
1329+
[treelist-append (-poly (a) (->* (list) (-treelist a) (-treelist a)))]
1330+
[treelist-map (-poly (a b) (-> (-treelist a) (-> a b) (-treelist b)))]
1331+
[treelist-for-each (-poly (a b) (-> (-treelist a) (-> a b) -Void))]
1332+
[treelist-filter (-poly (a) (-> (-> a Univ) (-treelist a) (-treelist a)))]
1333+
[treelist-find (-poly (a) (-> (-treelist a) (-> a Univ) a :T+ #f))]
1334+
[treelist-index-of
1335+
(-poly (a)
1336+
(cl->* ((-treelist a) a . -> . -Index)
1337+
((-treelist a) a (-> a a Univ) . -> . -Index)))]
1338+
[treelist-flatten (Univ . -> . (-treelist Univ))]
1339+
[treelist-append* (-poly (a) (-> (-treelist (-treelist a)) (-treelist a)))]
1340+
[treelist-sort
1341+
(-poly
1342+
(a b)
1343+
(cl->*
1344+
(->key (-treelist a) (-> a a -Boolean) #:key (-opt (-> a a :T+ #f)) #f #:cache-keys? -Boolean #f (-treelist a))
1345+
(->key (-treelist a) (-> b b -Boolean) #:key (-> a b :T+ #f) #t #:cache-keys? -Boolean #f (-treelist a))))]
1346+
1347+
12971348
;; Section 5.2 (Structure Types)
12981349
[make-struct-type
12991350
(->opt -Symbol

typed-racket-lib/typed-racket/base-env/base-structs.rkt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
(require (for-template racket/base (prefix-in k: '#%kernel)))
1313

14-
(provide initialize-structs -Date -Srcloc -Date -Arity-At-Least -Exn)
14+
(provide initialize-structs
15+
-Date
16+
-Srcloc
17+
-Arity-At-Least
18+
-Exn)
1519

1620
(define-syntax define-hierarchy
1721
(syntax-rules (define-hierarchy)

typed-racket-lib/typed-racket/base-env/base-types.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
[Async-Channelof -async-channel]
198198
[Ephemeronof -Ephemeron]
199199
[Setof -set]
200+
[TreeListof -treelist]
200201
[Evtof -evt]
201202
[Continuation-Mark-Set -Cont-Mark-Set]
202203
[False -False]

typed-racket-lib/typed-racket/base-env/for-clauses.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#:with (expand* ...) (list (quasisyntax/loc #'c
2626
((v.ann-name ...) seq-expr.e))
2727
#'#:when #''#t))
28-
(pattern (~seq (~and kw (~or #:when #:unless #:break #:final)) guard:expr)
29-
#:with (expand ...) (list #'kw #'guard)
28+
(pattern (~seq (~and kw (~or #:when #:unless #:break #:final #:do #:splice)) expr:expr)
29+
#:with (expand ...) (list #'kw #'expr)
3030
#:with (expand* ...) #'(expand ...)))
3131

3232
(define-syntax-class for-clauses

typed-racket-lib/typed-racket/base-env/prims.rkt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,29 @@ the typed racket language.
308308
(pattern (~seq (~and kw (~or #:break #:final)) guard-expr:expr)
309309
#:with (expand ...) #'(kw guard-expr)))
310310
(define-syntax-class for-kw
311+
(pattern #:when)
312+
(pattern #:unless)
313+
(pattern #:do)
314+
(pattern #:splice))
315+
(define-syntax-class for-when
311316
(pattern #:when
312317
#:with replace-with #'when)
313318
(pattern #:unless
314319
#:with replace-with #'unless))
315320
(syntax-parse clauses
316-
[(head:for-clause next:for-clause ... kw:for-kw guard b:break-clause ... rest ...)
321+
[(when:for-when guard) ; we end on a keyword clause
322+
(quasisyntax/loc stx
323+
(when.replace-with guard
324+
#,@body))]
325+
[(when:for-when guard rest ...)
326+
(quasisyntax/loc stx
327+
(when.replace-with guard
328+
#,(loop #'(rest ...))))]
329+
[(head:for-clause ... kw:for-kw expr b:break-clause ... rest ...)
317330
(add-ann
318331
(quasisyntax/loc stx
319332
(for
320-
(head.expand ... next.expand ... ... kw guard b.expand ... ...)
333+
(head.expand ... ... kw expr b.expand ... ...)
321334
#,(loop #'(rest ...))))
322335
#'Void)]
323336
[(head:for-clause ...) ; we reached the end
@@ -326,15 +339,7 @@ the typed racket language.
326339
(for
327340
(head.expand ... ...)
328341
#,@body))
329-
#'Void)]
330-
[(kw:for-kw guard) ; we end on a keyword clause
331-
(quasisyntax/loc stx
332-
(kw.replace-with guard
333-
#,@body))]
334-
[(kw:for-kw guard rest ...)
335-
(quasisyntax/loc stx
336-
(kw.replace-with guard
337-
#,(loop #'(rest ...))))])))]))
342+
#'Void)])))]))
338343

339344
(begin-for-syntax
340345
(define-splicing-syntax-class optional-standalone-annotation*

typed-racket-lib/typed-racket/base-env/unit-prims.rkt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,8 @@
133133
;; in the signature, this is needed to typecheck define-values/invoke-unit forms
134134
(define-for-syntax (imports/members sig-id)
135135
(define-values (_1 imp-mem _2 _3) (signature-members sig-id sig-id))
136-
#`(#,sig-id #,@(map (lambda (id)
137-
(local-expand
138-
id
139-
(syntax-local-context)
140-
(kernel-form-identifier-list)))
141-
imp-mem)))
136+
#`(#,sig-id #,@(for/list ([id (in-list imp-mem)])
137+
(local-expand id (syntax-local-context) (kernel-form-identifier-list)))))
142138

143139
;; Given a list of signature specs
144140
;; Processes each signature spec to determine the variables exported

0 commit comments

Comments
 (0)