Make promises like every other TR container.

This commit is contained in:
Eric Dobson 2012-08-11 21:05:53 -07:00 committed by Sam Tobin-Hochstadt
parent ac493a6f44
commit df6562c1de
6 changed files with 12 additions and 17 deletions

View File

@ -529,6 +529,8 @@
(cset-meet (cg e e*) (cg e* e))] (cset-meet (cg e e*) (cg e* e))]
[((ThreadCell: e) (ThreadCell: e*)) [((ThreadCell: e) (ThreadCell: e*))
(cset-meet (cg e e*) (cg e* e))] (cset-meet (cg e e*) (cg e* e))]
[((Promise: e) (Promise: e*))
(cg e e*)]
[((Ephemeron: e) (Ephemeron: e*)) [((Ephemeron: e) (Ephemeron: e*))
(cg e e*)] (cg e e*)]
[((CustodianBox: e) (CustodianBox: e*)) [((CustodianBox: e) (CustodianBox: e*))

View File

@ -139,6 +139,9 @@
[#:frees (λ (f) (make-invariant (f elem)))] [#:frees (λ (f) (make-invariant (f elem)))]
[#:key 'thread-cell]) [#:key 'thread-cell])
;; elem is a Type
(def-type Promise ([elem Type/c])
[#:key 'promise])
;; elem is a Type ;; elem is a Type
(def-type Ephemeron ([elem Type/c]) (def-type Ephemeron ([elem Type/c])

View File

@ -43,6 +43,7 @@
(define -box make-Box) (define -box make-Box)
(define -channel make-Channel) (define -channel make-Channel)
(define -thread-cell make-ThreadCell) (define -thread-cell make-ThreadCell)
(define -Promise make-Promise)
(define -set make-Set) (define -set make-Set)
(define -vec make-Vector) (define -vec make-Vector)
(define -future make-Future) (define -future make-Future)

View File

@ -9,7 +9,7 @@
(for-template racket/base) (for-template racket/base)
(for-syntax racket/base syntax/parse racket/list)) (for-syntax racket/base syntax/parse racket/list))
(provide (except-out (all-defined-out) Promise)) (provide (all-defined-out))
;Top and error types ;Top and error types
(define Univ (make-Univ)) (define Univ (make-Univ))
@ -22,13 +22,6 @@
(define ManyUniv Univ) (define ManyUniv Univ)
; Promise type
; TODO make this not a struct type, but the same as all other container types
(define Promise #f)
(define promise-id #'Promise)
(define -Promise
(lambda (t)
(make-Struct promise-id #f (list (make-fld t #'values #f)) #f #f #'promise? values #'values)))
;; Char type (needed because of how sequences are checked in subtype) ;; Char type (needed because of how sequences are checked in subtype)

View File

@ -3,7 +3,7 @@
(require racket/require racket/match unstable/sequence racket/string racket/promise (require racket/require racket/match unstable/sequence racket/string racket/promise
(prefix-in s: srfi/1) (prefix-in s: srfi/1)
(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"
"rep/rep-utils.rkt" "types/abbrev.rkt" "types/subtype.rkt" "rep/rep-utils.rkt" "types/subtype.rkt"
"utils/utils.rkt" "utils/utils.rkt"
"utils/tc-utils.rkt") "utils/tc-utils.rkt")
(for-syntax racket/base syntax/parse)) (for-syntax racket/base syntax/parse))
@ -22,7 +22,6 @@
(provide print-multi-line-case-> special-dots-printing? print-complex-filters?) (provide print-multi-line-case-> special-dots-printing? print-complex-filters?)
;;TODO try to remove requirement on abbrev once promise is fixed
;; do we attempt to find instantiations of polymorphic types to print? ;; do we attempt to find instantiations of polymorphic types to print?
;; FIXME - currently broken ;; FIXME - currently broken
@ -238,9 +237,6 @@
(fp "~a" (cons 'List (tuple-elems t)))] (fp "~a" (cons 'List (tuple-elems t)))]
[(Base: n cnt _ _ _) (fp "~s" n)] [(Base: n cnt _ _ _) (fp "~s" n)]
[(Opaque: pred _) (fp "(Opaque ~a)" (syntax->datum pred))] [(Opaque: pred _) (fp "(Opaque ~a)" (syntax->datum pred))]
[(Struct: (? (lambda (nm) (free-identifier=? promise-id nm)))
#f (list (fld: t _ _)) _ _ _ _ _)
(fp "(Promise ~a)" t)]
[(Struct: nm par (list (fld: t _ _) ...) proc _ _ _ _) [(Struct: nm par (list (fld: t _ _) ...) proc _ _ _ _)
(fp "#(struct:~a ~a" nm t) (fp "#(struct:~a ~a" nm t)
(when proc (when proc
@ -257,6 +253,7 @@
[(Future: e) (fp "(Futureof ~a)" e)] [(Future: e) (fp "(Futureof ~a)" e)]
[(Channel: e) (fp "(Channelof ~a)" e)] [(Channel: e) (fp "(Channelof ~a)" e)]
[(ThreadCell: e) (fp "(ThreadCellof ~a)" e)] [(ThreadCell: e) (fp "(ThreadCellof ~a)" e)]
[(Promise: e) (fp "(Promise ~a)" e)]
[(Ephemeron: e) (fp "(Ephemeronof ~a)" e)] [(Ephemeron: e) (fp "(Ephemeronof ~a)" e)]
[(CustodianBox: e) (fp "(CustodianBoxof ~a)" e)] [(CustodianBox: e) (fp "(CustodianBoxof ~a)" e)]
[(Set: e) (fp "(Setof ~a)" e)] [(Set: e) (fp "(Setof ~a)" e)]

View File

@ -413,6 +413,9 @@
[((Struct: nm _ _ _ _ _ _ _) (StructTop: (Struct: nm* _ _ _ _ _ _ _))) (=> nevermind) [((Struct: nm _ _ _ _ _ _ _) (StructTop: (Struct: nm* _ _ _ _ _ _ _))) (=> nevermind)
(unless (free-identifier=? nm nm*) (nevermind)) (unless (free-identifier=? nm nm*) (nevermind))
A0] A0]
;; Promises are covariant
[((Promise: s) (Promise: t))
(subtype* A0 s t)]
;ephemerons are covariant ;ephemerons are covariant
[((Ephemeron: s) (Ephemeron: t)) [((Ephemeron: s) (Ephemeron: t))
(subtype* A0 s t)] (subtype* A0 s t)]
@ -432,10 +435,6 @@
[((Struct: nm (? Type? parent) flds proc _ _ _ _) other) [((Struct: nm (? Type? parent) flds proc _ _ _ _) other)
;(dprintf "subtype - hierarchy : ~a ~a ~a\n" nm parent other) ;(dprintf "subtype - hierarchy : ~a ~a ~a\n" nm parent other)
(subtype* A0 parent other)] (subtype* A0 parent other)]
;; Promises are covariant
[((Struct: (? (lambda (n) (free-identifier=? n promise-id))) _ (list t) _ _ _ _ _)
(Struct: (? (lambda (n) (free-identifier=? n promise-id))) _ (list t*) _ _ _ _ _))
(subtype* A0 t t*)]
;; subtyping on values is pointwise ;; subtyping on values is pointwise
[((Values: vals1) (Values: vals2)) (subtypes* A0 vals1 vals2)] [((Values: vals1) (Values: vals2)) (subtypes* A0 vals1 vals2)]
;; trivial case for Result ;; trivial case for Result