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

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu May 25 15:07:06 EDT 2006

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."


Posted on the users mailing list.