Re: [racket-users] no TR support for streams?

2019-09-10 Thread 'John Clements' via Racket Users
Oh! and in fact, you already bundled it as a pkg: 
https://pkgs.racket-lang.org/package/typed-racket-stream

Thanks!

John

> On Sep 7, 2019, at 2:23 PM, Alex Knauth  wrote:
> 
> 
>> On Sep 6, 2019, at 1:04 PM, 'John Clements' via Racket Users 
>>  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
> 
> 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.



-- 
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/2102ff51-b1e3-49a8-8348-c023dc83d960%40mtasv.net.


Re: [racket-users] no TR support for streams?

2019-09-07 Thread Alex Knauth

> On Sep 6, 2019, at 1:04 PM, 'John Clements' via Racket Users 
>  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 


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.


[racket-users] no TR support for streams?

2019-09-06 Thread 'John Clements' via Racket Users
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?

John

-- 
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/e689a110-fe59-4a23-9dc6-185bbf9d2d09%40mtasv.net.