Fix promise printing, add docs. Closes PR 10968.
original commit: 0149a05719fdb1fbab56d231905f088bb13b4252
This commit is contained in:
parent
5b0fec235c
commit
9aef73b980
|
@ -167,8 +167,12 @@ The following base types are parameteric in their type arguments.
|
|||
@defform*[[(Parameterof t)
|
||||
(Parameterof s t)]]{A @rtech{parameter} of @racket[t]. If two type arguments are supplied,
|
||||
the first is the type the parameter accepts, and the second is the type returned.
|
||||
@ex[current-input-port]
|
||||
@ex[current-input-port
|
||||
current-directory]
|
||||
}
|
||||
|
||||
@defform[(Promise t)]{A @rtech{promise} of @racket[t].
|
||||
@ex[(delay 3)]}
|
||||
|
||||
@subsection{Other Type Constructors}
|
||||
|
||||
|
@ -184,8 +188,14 @@ The following base types are parameteric in their type arguments.
|
|||
second occurrence of @racket[...] is literal, and @racket[bound]
|
||||
must be an identifier denoting a type variable. In the fourth form,
|
||||
there must be only one @racket[dom] and @racket[pred] is the type
|
||||
checked by the predicate.}
|
||||
@defform[(U t ...)]{is the union of the types @racket[t ...]}
|
||||
checked by the predicate.
|
||||
|
||||
@ex[(λ: ([x : Number]) x)
|
||||
(λ: ([x : Number] . [y : String *]) (length y))
|
||||
ormap
|
||||
string?]}
|
||||
@defform[(U t ...)]{is the union of the types @racket[t ...].
|
||||
@ex[(λ: ([x : Real])(if (> 0 x) "yes" 'no))]}
|
||||
@defform[(case-lambda fun-ty ...)]{is a function that behaves like all of
|
||||
the @racket[fun-ty]s. The @racket[fun-ty]s must all be function
|
||||
types constructed with @racket[->].}
|
||||
|
@ -195,7 +205,8 @@ The following base types are parameteric in their type arguments.
|
|||
type variables @racket[v ...]}
|
||||
@defform[(values t ...)]{is the type of a sequence of multiple values, with
|
||||
types @racket[t ...]. This can only appear as the return type of a
|
||||
function.}
|
||||
function.
|
||||
@ex[(values 1 2 3)]}
|
||||
@defform/none[v]{where @racket[v] is a number, boolean or string, is the singleton type containing only that value}
|
||||
@defform/none[(quote val)]{where @racket[val] is a Racket value, is the singleton type containing only that value}
|
||||
@defform/none[i]{where @racket[i] is an identifier can be a reference to a type
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(require "../utils/utils.rkt")
|
||||
|
||||
(require (rep type-rep object-rep filter-rep rep-utils)
|
||||
"printer.rkt" "utils.rkt" "resolve.rkt"
|
||||
#;"printer.rkt" "utils.rkt" "resolve.rkt"
|
||||
(utils tc-utils)
|
||||
scheme/list
|
||||
scheme/match
|
||||
|
@ -75,8 +75,10 @@
|
|||
|
||||
;; basic types
|
||||
|
||||
(define promise-str (string->uninterned-symbol "Promise"))
|
||||
|
||||
(define make-promise-ty
|
||||
(let ([s (string->uninterned-symbol "Promise")])
|
||||
(let ([s promise-str])
|
||||
(lambda (t)
|
||||
(make-Struct s #f (list t) #f #f #'promise? values (list #'values) #'values))))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require unstable/sequence racket/require racket/match
|
||||
(path-up "rep/type-rep.rkt" "rep/filter-rep.rkt" "rep/object-rep.rkt"
|
||||
(path-up "rep/type-rep.rkt" "rep/filter-rep.rkt" "rep/object-rep.rkt" "types/abbrev.rkt"
|
||||
"rep/rep-utils.rkt" "utils/utils.rkt" "utils/tc-utils.rkt"))
|
||||
|
||||
;; do we attempt to find instantiations of polymorphic types to print?
|
||||
|
@ -142,8 +142,8 @@
|
|||
(fp "~a" (cons 'List (tuple-elems t)))]
|
||||
[(Base: n cnt) (fp "~a" n)]
|
||||
[(Opaque: pred _) (fp "(Opaque ~a)" (syntax->datum pred))]
|
||||
[(Struct: 'Promise par (list fld) proc _ _ _ _ _) (fp "(Promise ~a)" fld)]
|
||||
[(Struct: nm par flds proc _ _ _ _ _)
|
||||
[(Struct: (== promise-str eq?) #f (list fld) _ _ _ _ _ _) (fp "(Promise ~a)" fld)]
|
||||
[(Struct: nm par flds proc _ _ _ _ _)
|
||||
(fp "#(struct:~a ~a" nm flds)
|
||||
(when proc
|
||||
(fp " ~a" proc))
|
||||
|
|
Loading…
Reference in New Issue
Block a user