[plt-scheme] Higher-order contracts for variable-arity functions

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu May 25 15:20:36 EDT 2006

listof cannot accept higher-order contracts, due to the presence of
mutation. The tricky case is that someone hands you the list and, at
that point, the contract is check and the functions inside the list are
wrapped. Now, imagine that someone mutates the list -- what happens?
How do the contracts get onto the new functions in the list? (We could
change mutation operator, but we haven't taken that step ... yet)

Note that if you could use immutable lists, that would work fine.

Maybe time to petition any nearby R6RS committee members? ;)


At Thu, 25 May 2006 15:07:06 -0400, "Carl Eastlund" wrote:
> Is there a way to apply function contracts to the elements of "rest"
> arguments?  Let's say I had a simple "compose" function that operated
> on any number of functions, each with one argument and one return
> value.  I might try to write its contract like this:
> (module stuff mzscheme
>   (require (lib "contract.ss"))
>   (provide/contract
>     [compose ([(any/c . -> . any/c)] (listof (any/c . -> . any/c)) .
> ->* . [(any/c . -> . any/c)])])
>   (define (compose f . rest)
>     ...)
>   )
> The problem here is that "listof" does not take higher-order
> contracts.  I don't see any contract utilities that treat "rest"
> arguments as anything other than a list.  Have I missed one?  Is there
> a way to write one?
> -- 
> Carl Eastlund
> "Cynical, but technically correct."
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.