只关心返回值的函数契约?
问题描述:
假设以下琐碎的功能:只关心返回值的函数契约?
(define/contract (foo func)
(-> (-> any/c ... any/c) #t)
#t)
这是试图(和失败)表达的想法“富需要一个处理器功能我不在乎(这是调用程序作业)处理器需要什么论点,但处理器必须返回一个单一的结果。“
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]
原始Q/A :https://groups.google.com/d/msg/racket-users/YLGstyj-o_U/lhKKctSTBwAJ –