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:
parent
209f2db611
commit
05292b7e69
|
@ -404,10 +404,13 @@ the contract so that error messages become intelligible:
|
||||||
@interaction[#:eval
|
@interaction[#:eval
|
||||||
contract-eval
|
contract-eval
|
||||||
(module improved-bank-server racket
|
(module improved-bank-server racket
|
||||||
(define (amount? x) (and (number? x) (integer? x) (>= x 0)))
|
(provide
|
||||||
(define amount (flat-named-contract 'amount amount?))
|
(contract-out
|
||||||
|
[deposit (-> (flat-named-contract
|
||||||
(provide (contract-out [deposit (amount . -> . any)]))
|
'amount
|
||||||
|
(λ (x)
|
||||||
|
(and (number? x) (integer? x) (>= x 0))))
|
||||||
|
any)]))
|
||||||
|
|
||||||
(define total 0)
|
(define total 0)
|
||||||
(define (deposit a) (set! total (+ a total))))]
|
(define (deposit a) (set! total (+ a total))))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user