[racket] Why this contract violation behaviour?

From: Galler (lzgaller at optonline.net)
Date: Fri Nov 16 19:22:24 EST 2012

Use (define/contract...

to enforce a contract within a module

(define/contract  (amount) 
  (-> positive?)
  -7)

#|
  amount: broke its contract
  promised: positive?, produced: -7
  in: the range of
      (-> positive?)
  contract from: (function amount)
  blaming: (function amount)
  at: unsaved-editor34887:5.19

|# 

and use (provide/contract

to enforce across module boundaries but not within a module

As a practical matter, I use the (define/contract form and the (provide form
[not (provide/contract]

to enforce contracts both within and without a module



Posted on the users mailing list.