Re: [racket-users] Sequences in Typed Racket?

2018-04-23 Thread Philip McGrath
Yep, this works. Of course, it assumes that fibonacci is memoized or something to give good performance. #lang typed/racket (require math (for-syntax syntax/parse)) (: check-nat (-> Any Any)) (define (check-nat n) (unless (exact-nonnegative-integer? n) (raise-argument-error

Re: [racket-users] Sequences in Typed Racket?

2018-04-23 Thread Philip McGrath
It looks like you copied the code incorrectly: it should be (module adapter racket ...), but you have (module adapter racket/stream ...). To get the special performance you are referring to, you don't want to make a structure that's a sequence: you need to use `define-sequence-syntax` with

Re: [racket-users] Sequences in Typed Racket?

2018-04-23 Thread HiPhish
The adapter submodule does not work, I get the following error (in both typed and untyped Racket): fib.rkt:9:0: module: no #%module-begin binding in the module's language in: (module adapter racket/stream (provide stream-first stream-rest (rename-out (stream-cons* stream-cons)))

Re: [racket-users] Sequences in Typed Racket?

2018-04-22 Thread Philip McGrath
I hope there's a better way, but this works. The adapter submodule is needed because the normal `stream-cons` is a macro that expands into some private things that don't have types, and it requires that the rest expression produce a stream, not just any sequence. Note also, if you haven't worked