First, gfib_t needs a return type annotation. You can either add `:
(Stream Number)` to the end of the line, or write a full signature
above the define
(: gfib_t (-> (Listof Number) (Stream Number)))
(define (gfib_t ys)
After this, the typechecker can run. But it finds a problem with
stream-append. The issue here is that the two arguments to
stream-append have different types. One contains lists of numbers and
the other contains numbers.
typed.rkt:11:2: Type Checker: Polymorphic function `stream-append'
could not be applied to arguments:
Argument 1:
Expected: (Rec Stream (U (Boxof (U (-> (Pairof A Stream)) (Pairof
A Stream))) Null))
Given: (Rec x₀ (U (Boxof (U (-> (Pairof (Listof Number) x₀))
(Pairof (Listof Number) x₀))) Null))
Argument 2:
Expected: (Rec Stream (U (Boxof (U (-> (Pairof A Stream)) (Pairof
A Stream))) Null))
Given: (Rec x₀ (U (Boxof (U (-> (Pairof Number x₀)) (Pairof
Number x₀))) Null))
in: (stream-append (stream (drop-right xs 1)) (gfib_t xs))
Change (stream (drop-right xs 1)) to (apply stream (drop-right xs 1))
and you should be OK.
(It might be possible to call stream-append with a list and a stream
--- like the untyped code does --- but I haven't figured out how to do
that. Better stick with the Stream datatype.)