Improve Guide example on `flat-named-contract'

Previously, on the example, the function was not anonymous, so no
`tempN' would appear on the error message.

The fixed example makes use of `flat-named-contract' on an anonymous
function, which resembles the snippet above it and demonstrates the
purpose of `flat-named-contract' better.
This commit is contained in:
Leandro Facchinetti 2016-03-25 17:23:28 -04:00 committed by Vincent St-Amour
parent 209f2db611
commit 05292b7e69

View File

@ -404,11 +404,14 @@ the contract so that error messages become intelligible:
@interaction[#:eval
contract-eval
(module improved-bank-server racket
(define (amount? x) (and (number? x) (integer? x) (>= x 0)))
(define amount (flat-named-contract 'amount amount?))
(provide (contract-out [deposit (amount . -> . any)]))
(provide
(contract-out
[deposit (-> (flat-named-contract
'amount
(λ (x)
(and (number? x) (integer? x) (>= x 0))))
any)]))
(define total 0)
(define (deposit a) (set! total (+ a total))))]