> On Sep 6, 2019, at 1:04 PM, 'John Clements' via Racket Users > <firstname.lastname@example.org> wrote: > > Perhaps I just don’t know how to search the racket docs correctly, but IIUC > there’s no support for Streams in the current TR implementation? I just want > to use stream-cons, empty-stream, stream-first, and stream-rest. I guess the > easy workaround is just to use thunks to roll my own stream, but I’m > wondering if I’m missing something obvious?
You can wrap `stream-cons`, etc. in contracts and keep the original stream data type, but it's trickier than wrapping a normal function, and involves: - an untyped file which imports the macros and exports "function-ized" versions of the macros - a typed file which imports those function-ized things with require/typed, then exports new versions of the macros in terms of the functions And looks something like like these two files: ; untyped-stream-function-ized.rkt #lang racket (provide stream-cons/fn) (require racket/stream) (define (stream-cons/fn a b) (stream-cons (a) (b))) ; typed-stream.rkt #lang typed/racket (provide stream-cons) (require/typed "untyped-stream-function-ized.rkt" [stream-cons/fn (All (a) (-> (-> a) (-> (Sequenceof a)) (Sequenceof a)))]) (define-simple-macro (stream-cons a b) (stream-cons/fn (thunk a) (thunk b))) This is the strategy I used for my `typed-racket-stream` repository: https://github.com/AlexKnauth/typed-racket-stream <https://github.com/AlexKnauth/typed-racket-stream> I wanted to do this instead of "rolling my own" stream library because I wanted to be able to share the same stream data-structure as existing untyped racket files. Alex Knauth -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/50960124-B18A-445F-9511-5899E60D9A86%40knauth.org.