[racket] contracts for sequenceof and streamof ?

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri Aug 9 00:20:51 EDT 2013

Hi Christopher,

On 2013-08-08 13:37:00 -0600, Christopher wrote:
>    I can't find contracts for "sequenceof" or "streamof" for
>    non-typed (standard) Racket that would do much the same thing as listof
>    and vectorof.

There is a `sequence/c` in Racket, but it's in the "unstable" library:
  http://docs.racket-lang.org/unstable/contract.html?q=sequence/c#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29

Since all streams are sequences too, this contract should work for
both purposes.

>    Is there a trivial way to construct these types of contracts and use them
>    in non-typed Racket?

The Reference details how to construct your own contracts (if you can't
express them with the existing combinators). It's non-trivial though:
  http://docs.racket-lang.org/reference/Building_New_Contract_Combinators.html

Cheers,
Asumu

Posted on the users mailing list.