Say I have this (possibly from a third-party module):

  (define/contract (foo arg) (-> string? #t) #t)

I want to ensure that the argument is always non-empty, so I tighten the
contract.  I could do this:

  (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg))

Mutating the function is pretty ugly, but I'm not sure of a better way.  I
am left with the following questions:

1) Is there a better way to do this?

2) If I use this method in a module other than the one where foo was
defined, my expectation is that I would affect it only in the current
module but that other importers would not see the change.  Is this right?

3) What do I use for the negative blame position such that it accurately
reports the caller?  I have yet to figure that out in the general case and
the examples in the docs aren't useful.
https://docs.racket-lang.org/reference/attaching-contracts-to-values.html?q=contract#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fbase..rkt%29._contract%29%29

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to