thank you for your reply, Alex. That was informative and helpful. On 08/19/2016 02:56 PM, Alex Knauth wrote: > So to work around that, you can use `define-new-subtype` along with > `unsafe-require/typed`. > > #lang typed/racket > (require typed/racket/unsafe) > (define-new-subtype My-Type (make-my-type My-Type)) > (unsafe-require/typed "untyped.rkt" [my-type? (-> Any Boolean : My-Type)] > [my-type My-Type]) >
This is quite wonky and the warnings in the Typed Racket docs about unsafe make me very wary about using such stuff in production. Can the others confirm if this is indeed the desired behavior or something that might be fixed in a later version? Regards, M.e. > > Alex Knauth > >> Hi all, >> >> I note that Racket 6.6 now issues warnings for certain generated >> contracts in typed/untyped interactions. In particular, these warnings >> come up when requiring an untyped file from a typed file. For example, >> say I have >> >> test.rkt: >> --------- >> #lang racket >> >> >> (define my-type >> (let () >> (struct my-type () ) >> (my-type))) >> (define (my-type? x) >> (eq? x my-type)) >> >> >> (provide my-type? my-type) >> >> And follow that with type interactions: >> >> $ racket -I typed/racket >> Welcome to Racket v6.6. >> -> (require/typed "test.rkt" [#:opaque My-Type my-type?] [my-type My-Type]) >> my-type?: contract violation >> any-wrap/c: Unable to protect opaque value passed as `Any` >> value: #<my-type> >> This warning will become an error in a future release. >> in: the 1st argument of >> a part of the or/c of >> (or/c >> struct-predicate-procedure?/c >> (-> Any boolean?)) >> contract from: (interface for my-type?) >> blaming: top-level >> (assuming the contract is correct) >> at: readline-input:1.44 >> >> I use a similar pattern to call the untyped db library from typed code, >> say with >> (require/typed db [#:opaque Sql-Null] [sql-null Sql-Null]), which would >> bring up a similar warning. >> >> Is there a "correct" way to handle these sorts of cases? >> >> Thanks! >> >> Matthew Eric >> >> -- >> Matthew Eric Bassett | http://mebassett.info > > -- Matthew Eric Bassett | http://mebassett.info -- 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.
signature.asc
Description: OpenPGP digital signature