Re: [racket-users] Contracts not enforced with serial-lambda

2017-03-29 Thread Matthew Flatt
This example and variants exposed multiple problems with the
implementation of chaperones, and I've pushed repairs.

At Wed, 29 Mar 2017 09:12:25 -0600, Matthew Flatt wrote:
> It's also not really contracts, but chaperones:
> 
>  #lang racket/base
> 
>  (define kwstruct-add1
>(let ()
>  (struct the-struct ()
>#:property prop:procedure
>(make-keyword-procedure (λ (kws kw-values _ i) "broken")))
>  (the-struct)))
> 
>  ((chaperone-procedure kwstruct-add1 (make-keyword-procedure
>   (lambda (kws values arg)
> (error "no"
>   "bad arg")
> 
> Thanks for the example, and I'll continue investigating.
> 
> At Wed, 29 Mar 2017 10:52:05 -0400, Jay McCarthy wrote:
> > This is actually a problem in racket/contract with applicable structs
> > where prop:procedure is a keyword procedure. This file shows the
> > development --- http://pasterack.org/pastes/361 --- and the simple
> > thing that breaks is:
> > 
> > #lang racket
> > (define kwstruct-add1
> >   (let ()
> > (struct the-struct ()
> >   #:property prop:procedure
> >   (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
> > (the-struct)))
> > ((contract (-> number? number?) kwstruct-add1 'pos 'neg) "bad arg")
> > 
> > 
> > 
> > On Mon, Mar 27, 2017 at 4:03 PM, Philip McGrath
> >  wrote:
> > > I've been playing around with trying to attach contracts to serializable
> > > procedures created with serial-lambda. What I've been trying to do hasn't
> > > been working, and I've also come across some surprising behavior. For
> > > example, this program:
> > >>
> > >> #lang racket
> > >> (require web-server/lang/serial-lambda
> > >>  racket/serialize
> > >>  )
> > >> (define/contract serial-add1
> > >>   (-> number? number?)
> > >>   (serial-lambda (i)
> > >> "broken"))
> > >> (serial-add1 "bad arg")
> > >
> > > prints "broken", rather than raising an error for either the domain part 
> > > or
> > > the range part of the contract (neither of which pass).
> > >
> > > I was expecting to potentially run into trouble with things like
> > > deserialization, but I'm not at all sure why the contract in this simple
> > > example isn't enforced.
> > >
> > > Thanks,
> > > Philip
> > >
> > > --
> > > 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.
> > 
> > 
> > 
> > -- 
> > -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> > -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
> > -=[ Moses 1:33: And worlds without number have I created; ]=-
> > 
> > -- 
> > 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.
> 
> -- 
> 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.

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


Re: [racket-users] Contracts not enforced with serial-lambda

2017-03-29 Thread Matthew Flatt
It's also not really contracts, but chaperones:

 #lang racket/base

 (define kwstruct-add1
   (let ()
 (struct the-struct ()
   #:property prop:procedure
   (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
 (the-struct)))

 ((chaperone-procedure kwstruct-add1 (make-keyword-procedure
  (lambda (kws values arg)
(error "no"
  "bad arg")

Thanks for the example, and I'll continue investigating.

At Wed, 29 Mar 2017 10:52:05 -0400, Jay McCarthy wrote:
> This is actually a problem in racket/contract with applicable structs
> where prop:procedure is a keyword procedure. This file shows the
> development --- http://pasterack.org/pastes/361 --- and the simple
> thing that breaks is:
> 
> #lang racket
> (define kwstruct-add1
>   (let ()
> (struct the-struct ()
>   #:property prop:procedure
>   (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
> (the-struct)))
> ((contract (-> number? number?) kwstruct-add1 'pos 'neg) "bad arg")
> 
> 
> 
> On Mon, Mar 27, 2017 at 4:03 PM, Philip McGrath
>  wrote:
> > I've been playing around with trying to attach contracts to serializable
> > procedures created with serial-lambda. What I've been trying to do hasn't
> > been working, and I've also come across some surprising behavior. For
> > example, this program:
> >>
> >> #lang racket
> >> (require web-server/lang/serial-lambda
> >>  racket/serialize
> >>  )
> >> (define/contract serial-add1
> >>   (-> number? number?)
> >>   (serial-lambda (i)
> >> "broken"))
> >> (serial-add1 "bad arg")
> >
> > prints "broken", rather than raising an error for either the domain part or
> > the range part of the contract (neither of which pass).
> >
> > I was expecting to potentially run into trouble with things like
> > deserialization, but I'm not at all sure why the contract in this simple
> > example isn't enforced.
> >
> > Thanks,
> > Philip
> >
> > --
> > 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.
> 
> 
> 
> -- 
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
> -=[ Moses 1:33: And worlds without number have I created; ]=-
> 
> -- 
> 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.

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


Re: [racket-users] Contracts not enforced with serial-lambda

2017-03-29 Thread Sam Tobin-Hochstadt
I think the problem is actually in the implementation of
`chaperone-procedure` for keywords. This program has the same
behavior:

#lang racket
(require (prefix-in k: '#%kernel))
(define kwstruct-add1
  (let ()
(struct the-struct ()
  #:property prop:procedure
  (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
(the-struct)))
((chaperone-procedure kwstruct-add1
  (make-keyword-procedure (λ _ (error 'fail))
  (λ _ (error 'fail
 "bad arg")

but if we use `k:chaperone-procedure` it throws an error.

Sam

On Wed, Mar 29, 2017 at 10:52 AM, Jay McCarthy  wrote:
> This is actually a problem in racket/contract with applicable structs
> where prop:procedure is a keyword procedure. This file shows the
> development --- http://pasterack.org/pastes/361 --- and the simple
> thing that breaks is:
>
> #lang racket
> (define kwstruct-add1
>   (let ()
> (struct the-struct ()
>   #:property prop:procedure
>   (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
> (the-struct)))
> ((contract (-> number? number?) kwstruct-add1 'pos 'neg) "bad arg")
>
>
>
> On Mon, Mar 27, 2017 at 4:03 PM, Philip McGrath
>  wrote:
>> I've been playing around with trying to attach contracts to serializable
>> procedures created with serial-lambda. What I've been trying to do hasn't
>> been working, and I've also come across some surprising behavior. For
>> example, this program:
>>>
>>> #lang racket
>>> (require web-server/lang/serial-lambda
>>>  racket/serialize
>>>  )
>>> (define/contract serial-add1
>>>   (-> number? number?)
>>>   (serial-lambda (i)
>>> "broken"))
>>> (serial-add1 "bad arg")
>>
>> prints "broken", rather than raising an error for either the domain part or
>> the range part of the contract (neither of which pass).
>>
>> I was expecting to potentially run into trouble with things like
>> deserialization, but I'm not at all sure why the contract in this simple
>> example isn't enforced.
>>
>> Thanks,
>> Philip
>>
>> --
>> 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.
>
>
>
> --
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
> -=[ Moses 1:33: And worlds without number have I created; ]=-
>
> --
> 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.

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


Re: [racket-users] Contracts not enforced with serial-lambda

2017-03-29 Thread Jay McCarthy
This is actually a problem in racket/contract with applicable structs
where prop:procedure is a keyword procedure. This file shows the
development --- http://pasterack.org/pastes/361 --- and the simple
thing that breaks is:

#lang racket
(define kwstruct-add1
  (let ()
(struct the-struct ()
  #:property prop:procedure
  (make-keyword-procedure (λ (kws kw-values _ i) "broken")))
(the-struct)))
((contract (-> number? number?) kwstruct-add1 'pos 'neg) "bad arg")



On Mon, Mar 27, 2017 at 4:03 PM, Philip McGrath
 wrote:
> I've been playing around with trying to attach contracts to serializable
> procedures created with serial-lambda. What I've been trying to do hasn't
> been working, and I've also come across some surprising behavior. For
> example, this program:
>>
>> #lang racket
>> (require web-server/lang/serial-lambda
>>  racket/serialize
>>  )
>> (define/contract serial-add1
>>   (-> number? number?)
>>   (serial-lambda (i)
>> "broken"))
>> (serial-add1 "bad arg")
>
> prints "broken", rather than raising an error for either the domain part or
> the range part of the contract (neither of which pass).
>
> I was expecting to potentially run into trouble with things like
> deserialization, but I'm not at all sure why the contract in this simple
> example isn't enforced.
>
> Thanks,
> Philip
>
> --
> 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.



-- 
-=[ Jay McCarthy   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

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


[racket-users] Contracts not enforced with serial-lambda

2017-03-27 Thread Philip McGrath
I've been playing around with trying to attach contracts to serializable
procedures created with serial-lambda. What I've been trying to do hasn't
been working, and I've also come across some surprising behavior. For
example, this program:

> #lang racket
> (require web-server/lang/serial-lambda
>  racket/serialize
>  )
> (define/contract serial-add1
>   (-> number? number?)
>   (serial-lambda (i)
> "broken"))
> (serial-add1 "bad arg")

prints "broken", rather than raising an error for either the domain part or
the range part of the contract (neither of which pass).

I was expecting to potentially run into trouble with things like
deserialization, but I'm not at all sure why the contract in this simple
example isn't enforced.

Thanks,
Philip

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