[racket] Typed Racket - Recursive Types (Little help please)
This works if you expand the use of Iteratee within the definition of
Continuation. Mutually-recursive polymorphic types are problematic,
but Continuation is only actually singly-recursive. You can still
have the definition Iteratee for outside use.
Carl Eastlund
#lang typed/racket/base
;; Inputs
(define-type (Stream D) (U (Datum D) 'Nothing 'EOS))
(struct: (D) Datum ([iota : D]))
;; Iteratee
(define-type (Iteratee D A) (U (Done D A) (Continuation D A)))
(struct: (D A) Done ([accum : A] [stream : (Stream D)]))
(struct: (D A) Continuation ([resume : ((Stream D) -> (U (Done D A)
(Continuation D A)))]))
On Thu, Jul 19, 2012 at 6:07 PM, Ray Racine <ray.racine at gmail.com> wrote:
> #lang typed/racket/base
>
> ;; Inputs
> (define-type (Stream D) (U (Datum D) 'Nothing 'EOS))
> (struct: (D) Datum ([iota : D]))
>
> ;; Iteratee
> (define-type (Iteratee D A) (U (Done D A) (Continuation D A)))
> (struct: (D A) Done ([accum : A] [stream : (Stream D)]))
> (struct: (D A) Continuation ([resume : ((Stream D) -> (Iteratee D A))]))
>
> 1. How can I get the recursive nature of Iteratee and Continuation to type
> check?
> 2. Ideally, but not necessary, like to define Continuation as a
> define-struct/exec:
>
> Thanks,
>
> Ray