The best solution is usually to avoid using Any when interoperating with untyped code. Presumably you can describe a more specific type for this case, such as an opaque type for the sql-null value.
Sam On Tue, Sep 1, 2015, 3:03 PM 'John Clements' via Racket Users < racket-users@googlegroups.com> wrote: > I’m trying to use the database library db with TR, and I’ve run into a > problem whose only workaround seems really nasty. > > Specifically, it concerns vectors (or lists, presumably) that contain > opaque values. So, for instance, here’s foo1.rkt: > > #lang racket > > (provide return-a-list) > > (struct my-struct ()) > > (define (return-a-list) > (vector 13 (my-struct) 15)) > > … and here’s foo2.rkt: > > #lang typed/racket > > (require/typed "foo1.rkt" > [return-a-list (-> (Vectorof Any))]) > > (return-a-list) > > Running foo2.rkt produces this error: > > . . return-a-list: contract violation > Attempted to use a higher-order value passed as `Any` in untyped code: > #<my-struct> > in: an element of > the range of > (-> (vectorof Any)) > contract from: (interface for return-a-list) > blaming: /private/tmp/foo2.rkt > (assuming the contract is correct) > at: /private/tmp/foo2.rkt:4.16 > > Making “my-struct” transparent solves this problem, but the problem arises > for me in the use of db’s #<sql-null>, which I can’t mess with. > > Frankly, it looks like the easiest workaround is just … not to use TR > here. Am I missing something obvious? Also, I’d love a bit more explanation > of how this breaks TR’s type safety guarantee. > > Thanks! > > John > > > > -- > 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.