[plt-scheme] The contract

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Dec 17 09:15:08 EST 2007

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
>
>


Posted on the users mailing list.