[racket] code review request for LRU code

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Wed Mar 13 00:24:51 EDT 2013

Why cannot that contract be checked? It seems that since the or/c is
the unwrapping of the parametric contracts it should be possible,
since the first order checks should differentiate them.

On Tue, Mar 12, 2013 at 8:46 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> On 2013-03-12 13:16:02 -0700, Danny Yoo wrote:
>> slab:lru dyoo$ racket untyped-client.rkt
>> untyped-client.rkt:10:0: Type Checker: The type of lru-ref cannot be
>> converted to a contract
>>   in: (lru-ref l "greeting")
>>   context...:
>>    /Applications/Racket v5.3.2/collects/racket/private/modbeg.rkt:46:4
>>    standard-module-name-resolver
>
> I think this boils down to the fact that the following does not work:
>
>   #lang racket
>
>   (module b typed/racket
>     (: f (All (A B) (A B -> (U A B))))
>     (define (f x y) x)
>     (provide f))
>
>   (require 'b)
>   f
>
> The reason this doesn't work is because this contract does not work:
>
>   #lang racket
>
>   (define/contract (f x y)
>     (parametric->/c (A B) (-> A B (or/c A B)))
>     x)
>
>   (f 1 "foo")
>
>   ;;;
>
>   f: broke its contract
>    two of the clauses in the or/c might both match: B and A
>    produced: #<A>
>    in: the range of
>        ...
>         (parametric->/c (A B) ...)
>    contract from: (function f)
>    blaming: (function f)
>    at: unsaved-editor160271:3.18
>
> Cheers,
> Asumu
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.