Re: [racket-users] How to tighten the contract on a function

2018-09-05 Thread David Storrs
On Wed, Sep 5, 2018 at 2:29 PM, Alexander McLin wrote: > Something like the following program: > > #lang racket > > (module foomod racket > (provide foo) > (define/contract (foo arg) (-> string? #t) #t)) > > (require 'foomod) > (provide (contract-out (foo (-> non-empty-string? #t > > I wa

Re: [racket-users] How to tighten the contract on a function

2018-09-05 Thread Alexander McLin
Something like the following program: #lang racket (module foomod racket (provide foo) (define/contract (foo arg) (-> string? #t) #t)) (require 'foomod) (provide (contract-out (foo (-> non-empty-string? #t On Tuesday, September 4, 2018 at 9:00:06 PM UTC-4, David K. Storrs wrote: > >

Re: [racket-users] How to tighten the contract on a function

2018-09-05 Thread Alexander McLin
What about reproviding foo and using contract-out to wrap foo in a new contract? On Tuesday, September 4, 2018 at 9:00:06 PM UTC-4, David K. Storrs wrote: > > > > On Tue, Sep 4, 2018 at 8:55 PM, Matthew Butterick > wrote: > >> >> On Sep 4, 2018, at 3:54 PM, David Storrs > > wrote: >> >> Say

Re: [racket-users] How to tighten the contract on a function

2018-09-04 Thread David Storrs
On Tue, Sep 4, 2018 at 8:55 PM, Matthew Butterick wrote: > > On Sep 4, 2018, at 3:54 PM, David Storrs wrote: > > 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

[racket-users] How to tighten the contract on a function

2018-09-04 Thread David Storrs
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 pr