Racket 只关心返回值的函数的契约?
假设以下平凡函数:Racket 只关心返回值的函数的契约?,racket,contract,Racket,Contract,假设以下平凡函数: (define/contract (foo func) (-> (-> any/c ... any/c) #t) #t) 这试图(但失败)表达“foo接受处理器函数。我不在乎处理器需要什么参数(这是调用方的工作),但处理器必须返回一个单一的结果。” foo的正确合同是什么?我已经浏览了功能合同部分;以上是我的第一个猜测,但这失败了: (foo identity) ; foo: contract violation ; expected: a proc
(define/contract (foo func)
(-> (-> any/c ... any/c) #t)
#t)
这试图(但失败)表达“foo接受处理器函数。我不在乎处理器需要什么参数(这是调用方的工作),但处理器必须返回一个单一的结果。”
foo的正确合同是什么?我已经浏览了功能合同部分;以上是我的第一个猜测,但这失败了:
(foo identity)
; foo: contract violation
; expected: a procedure that accepts 0 non-keyword arguments and arbitrarily
; many more
; given: #<procedure:identity>
; identity accepts: 1 argument
; in: the 1st argument of
; (-> (-> any/c ... any/c) #t)
; contract from: (function foo)
; blaming: top-level
; (assuming the contract is correct)
; at: readline-input:8.18
; [,bt for context]
我想你想要原版问答:
(define/contract (foo func)
(-> (-> any any/c) #t)
#t)
; readline-input:10:33: any: use of 'any' outside the range of an arrow
; contract
; in: any
; [,bt for context]