[racket] Typed Racket - Recursive Types (Little help please)

From: Ray Racine (ray.racine at gmail.com)
Date: Thu Jul 19 18:51:54 EDT 2012

Nice.  Thank you.

On Thursday, July 19, 2012, Carl Eastlund <cce at ccs.neu.edu> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120719/a984ce96/attachment-0001.html>

Posted on the users mailing list.