[plt-scheme] The contract
Oh, one other point. It was pointed out earlier that the function does
not actually need that strict of a contract and I believe the contract
has been relaxed in SVN.
Robby
On Dec 17, 2007 8:22 AM, <yug at ios.ac.cn> wrote:
> Thanks!! Robby
>
> The right def is
>
>
> (call/input-url (string->url "https://210.77.16.29/php/user_login.php")
> (case-lambda
> [(url) (post-impure-port url data rhead)]
> [(url rhead) (post-impure-port url data rhead)])
> display-pure-port
> )
>
>
>
> On Dec 17, 2007 10:15 PM, Robby Findler <robby at cs.uchicago.edu> wrote:
> > The contract is insisting that you provide a function that accepts
> > *both* one argument and two arguments.
> >
> > Robby
> >
> >
> >
> >
> > On Dec 17, 2007 8:13 AM, < yug at ios.ac.cn> wrote:
> > > Hi,
> > >
> > > I'm fresh to contracts. Here is my problem:
> > >
> > > I just want to pass the contracts check on the following definition:
> > >
> > > (define test (lambda (url)
> > > (post-impure-port url data rhead)))
> > >
> > > (provide/contract (test (-> url? input-port?)))
> > >
> > > (call/input-url (string->url " https://210.77.16.29/php/user_login.php")
> test
> > > display-pure-port)
> > >
> > > or even more simplified:
> > >
> > > (call/input-url (string->url " https://210.77.16.29/php/user_login.php")
> > > (lambda (url)
> > > (post-impure-port url data rhead)))
> > > display-pure-port)
> > >
> > > Every time, I get:
> > > (case->
> > > (->
> > > url?
> > > (case->
> > > (-> url? input-port?)
> > > (-> url? (listof string?) input-port?))
> > > (-> input-port? any)
> > > any)
> > > (->
> > > url?
> > > (case->
> > > (-> url? input-port?)
> > > (-> url? (listof string?) input-port?))
> > > (-> input-port? any)
> > > (listof string?)
> > > any))
> > > on call/input-url; expected a procedure that accepts 2 arguments, given:
> > > #<procedure:test>
> > >
> > > If I change the definition to
> > > (call/input-url (string->url " https://210.77.16.29/php/user_login.php")
> > > (lambda (url rhead)
> > > (post-impure-port url data rhead)
> > > )
> > > display-pure-port
> > > )
> > > . . ssl-url.scm:40:4: /home/yug/ssl-url.scm:40:4: top-level broke the
> > > contract
> > > (case->
> > > (->
> > > url?
> > > (case->
> > > (-> url? input-port?)
> > > (-> url? (listof string?) input-port?))
> > > (-> input-port? any)
> > > any)
> > > (->
> > > url?
> > > (case->
> > > (-> url? input-port?)
> > > (-> url? (listof string?) input-port?))
> > > (-> input-port? any)
> > > (listof string?)
> > > any))
> > > on call/input-url; expected a procedure that accepts 1 arguments, given:
> > > #<procedure>
> > > >
> > >
> > > How can I define my function?
> > >
> > > Thanks
> > >
> > > --
> > > Gang
> > > _________________________________________________
> > > For list-related administrative tasks:
> > > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> > >
> > _________________________________________________
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>
>
>
> --
> Gang