[racket] What am I doing wrong in this typed racket program?

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Wed Sep 19 14:26:00 EDT 2012

Thinking about this further, I think Typed Racket should always know
when chaperone contracts are required, just as it currently checks
when flat contracts are required. So this shouldn't be too hard to
fix.

On Tue, Sep 18, 2012 at 6:23 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Can you explain more? Surely TR must know what "Setof" is, because it
> translated it to "set/c" and surely it must know what "Any" is, since
> it turned it into some other contract. That seems like enough
> information to me.
>
> Robby
>
> On Tue, Sep 18, 2012 at 5:00 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>> I'm saying that I don't at the moment know how to avoid giving this
>> error, given the current behavior of `set/c`.
>>
>> On Tue, Sep 18, 2012 at 5:57 PM, Robby Findler
>> <robby at eecs.northwestern.edu> wrote:
>>> Are you saying it is reasonable that a typed racket program should
>>> produce contract constructor errors like that?
>>>
>>> Robby
>>>
>>> On Tue, Sep 18, 2012 at 4:53 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>>>> The problem here is that `Any` is a special contract which isn't a
>>>> "chaperone contract", and `set/c` requires chaperone contracts.
>>>>
>>>> It's not obvious to me if this can be detected statically, but you can
>>>> work around this by changing `Any` to some other type.
>>>>
>>>> Sam
>>>>
>>>> On Tue, Sep 18, 2012 at 5:44 PM, Tony Garnock-Jones <tonyg at ccs.neu.edu> wrote:
>>>>> Hi all,
>>>>>
>>>>> What could I be doing wrong here?
>>>>>
>>>>>     #lang typed/racket
>>>>>     (provide (struct-out foo))
>>>>>     (struct: foo ([bar : (Setof Any)]))
>>>>>
>>>>> Racket 5.3.0.24 complains about it ("racket problem.rkt"):
>>>>>
>>>>>     set/c: contract violation
>>>>>       expected: chaperone-contract?
>>>>>       given: #<make-contract>
>>>>>       context...:
>>>>>        /Users/tonyg/src/racket-typed-matrix/problem.rkt: [running body]
>>>>>
>>>>> The complaint vanishes if I comment out the provide, remove the bar
>>>>> field, or change the bar field's type to Any/Integer/etc.
>>>>>
>>>>>   Tony
>>>>> ____________________
>>>>>   Racket Users list:
>>>>>   http://lists.racket-lang.org/users
>>>>
>>>>
>>>>
>>>> --
>>>> sam th
>>>> samth at ccs.neu.edu
>>>> ____________________
>>>>   Racket Users list:
>>>>   http://lists.racket-lang.org/users
>>
>>
>>
>> --
>> sam th
>> samth at ccs.neu.edu



-- 
sam th
samth at ccs.neu.edu

Posted on the users mailing list.