From e32cf1d7dd1d096ef2727e3ad803dd4227961d09 Mon Sep 17 00:00:00 2001 From: Nathan Fritzler Date: Fri, 27 Jan 2023 22:29:32 -0700 Subject: [PATCH 1/2] Start basic work --- typed-racket-more/typed/racket/stream.rkt | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 typed-racket-more/typed/racket/stream.rkt diff --git a/typed-racket-more/typed/racket/stream.rkt b/typed-racket-more/typed/racket/stream.rkt new file mode 100644 index 000000000..13af4e3f7 --- /dev/null +++ b/typed-racket-more/typed/racket/stream.rkt @@ -0,0 +1,43 @@ +#lang typed/racket/base + +;; Provides type bindings for racket/stream. + +(require/typed/provide + racket/stream + [#:opaque StreamOf stream/c] ; TODO is this how this works? + [#:opaque Stream stream?] + [#:opaque StreamEmpty stream-empty?] + [stream-first ((∩ Stream StreamEmpty) -> Any)] + [stream-rest ((∩ Stream StreamEmpty) -> Stream)] + ; TODO macros? + ;[stream-cons ...] + ;[stream-lazy ...] + [stream-force (Stream -> Stream)] + ; TODO macros? + ;[stream ...] + ;[stream* ...] + [in-stream (Stream -> Stream)] + ; TODO causes a contract violation + ;[empty-stream Stream] + [stream->list (Stream -> (Listof Any))] + ; TODO causes a contract violation + [stream-length (Stream -> Exact-Nonnegative-Integer)] + [stream-ref (Stream Exact-Nonnegative-Integer -> Any)] + [stream-tail (Stream Exact-Nonnegative-Integer -> Any)] + [stream-take (Stream Exact-Nonnegative-Integer -> Any)] + ; TODO macros? + ;[stream-append (Stream ... -> Any)] + [stream-map ((Any -> Any) Stream -> Stream)] + ; TODO macros? + ;[stream-andmap ((Any ... -> Boolean) Stream -> Stream)] + ;[stream-ormap ((Any ... -> Boolean) Stream -> Stream)] + ;[stream-for-each ((Any ... -> Any) Stream -> Void)] + ;[stream-fold ((Any Any ... -> Any) Any Stream -> Any)] + [stream-count ((Any -> Any) Stream -> Exact-Nonnegative-Integer)] + ;[stream-filter ((Any ... -> Boolean) Stream -> Stream)] + [stream-add-between (Stream Any -> Stream)] + ; TODO for/stream is a a macro + ; TODO + ; - gen:stream + ; - prop:stream + ) From e2b143462ae1a67b7e103bab0a9835698a44e3c4 Mon Sep 17 00:00:00 2001 From: Nathan Fritzler Date: Sun, 29 Jan 2023 19:15:21 -0700 Subject: [PATCH 2/2] Add the rest-star types --- typed-racket-more/typed/racket/stream.rkt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/typed-racket-more/typed/racket/stream.rkt b/typed-racket-more/typed/racket/stream.rkt index 13af4e3f7..ebe8fba52 100644 --- a/typed-racket-more/typed/racket/stream.rkt +++ b/typed-racket-more/typed/racket/stream.rkt @@ -9,32 +9,29 @@ [#:opaque StreamEmpty stream-empty?] [stream-first ((∩ Stream StreamEmpty) -> Any)] [stream-rest ((∩ Stream StreamEmpty) -> Stream)] - ; TODO macros? + ; TODO macros ;[stream-cons ...] ;[stream-lazy ...] [stream-force (Stream -> Stream)] - ; TODO macros? + ; TODO macros ;[stream ...] ;[stream* ...] [in-stream (Stream -> Stream)] ; TODO causes a contract violation ;[empty-stream Stream] [stream->list (Stream -> (Listof Any))] - ; TODO causes a contract violation [stream-length (Stream -> Exact-Nonnegative-Integer)] [stream-ref (Stream Exact-Nonnegative-Integer -> Any)] [stream-tail (Stream Exact-Nonnegative-Integer -> Any)] [stream-take (Stream Exact-Nonnegative-Integer -> Any)] - ; TODO macros? - ;[stream-append (Stream ... -> Any)] + [stream-append (->* () #:rest-star (Stream) Any)] [stream-map ((Any -> Any) Stream -> Stream)] - ; TODO macros? - ;[stream-andmap ((Any ... -> Boolean) Stream -> Stream)] - ;[stream-ormap ((Any ... -> Boolean) Stream -> Stream)] - ;[stream-for-each ((Any ... -> Any) Stream -> Void)] - ;[stream-fold ((Any Any ... -> Any) Any Stream -> Any)] + [stream-andmap ((->* () #:rest-star (Any) Boolean) Stream -> Stream)] + [stream-ormap ((->* () #:rest-star (Any) Boolean) Stream -> Stream)] + [stream-for-each ((->* () #:rest-star (Any) Any) Stream -> Void)] + [stream-fold ((->* (Any) #:rest-star (Any) Any) Any Stream -> Any)] [stream-count ((Any -> Any) Stream -> Exact-Nonnegative-Integer)] - ;[stream-filter ((Any ... -> Boolean) Stream -> Stream)] + [stream-filter ((->* () #:rest-star (Any) Boolean) Stream -> Stream)] [stream-add-between (Stream Any -> Stream)] ; TODO for/stream is a a macro ; TODO