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

From: Ray Racine (ray.racine at gmail.com)
Date: Thu Jul 19 20:11:50 EDT 2012

While it does work, there is definitely a loss of informative intent in the
sense of the "documentation" to the human reader provided by the type
signatures.  If define-type is strictly an aliasing then the original
construction should work and its failure a bug.  Do you agree?  If so I'll
open a bug report.

Thanks again.

Ray

On Thu, Jul 19, 2012 at 6:51 PM, Ray Racine <ray.racine at gmail.com> wrote:

> 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/7f259e2a/attachment.html>

Posted on the users mailing list.