[racket] Typed Racket: Defining a sequence predicate

From: Matthias Benkard (mailing-lists at mail.matthias.benkard.de)
Date: Thu Aug 11 15:16:10 EDT 2011

Hi again,

Thank you for the quick and helpful response!


> This is a bug; it should give you roughly the same error as above, but
> for the different reason.  The problem is that we'd need to check
> *every* element of the sequence to make sure it had the right type,
> which a simple predicate can't do.  You'd need to write a coercion
> function, which Typed Racket could probably help with -- I'll try to
> do that soon.
>
OK.  I've worked around the problem by defining an untyped module 
containing a dummy procedure:

     ;;;; --- typed-sequence.rkt ---
     #lang racket
     (provide sequence->sequence)
     (define sequence->sequence identity)

and using that along with an opaque import:

     ;;;; --- main.rkt ---
     #lang typed/racket
     (require/typed racket
       [opaque Sequence sequence?])
     (require/typed "typed-sequence.rkt"
       [sequence->sequence (Sequence -> (Sequenceof Any))])

which is an amazingly ugly hack, but works.   For now. :)

Thanks again,
Matthias


Posted on the users mailing list.