> On Aug 24, 2016, at 9:12 AM, Matthew Eric Bassett <mebass...@gegn.net> wrote: > > 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?
The warnings for `unsafe-required/typed` are definitely not the desired behavior, and there is currently a pull request to fix that: https://github.com/racket/typed-racket/pull/418 With this pull request, you would be able to use #lang typed/racket (require typed/racket/unsafe) (unsafe-require/typed "untyped.rkt" [#:opaque My-Type my-type?] [my-type My-Type]) (my-type? my-type) ; produces #t Without it producing that warning. However it's still not a very good solution because it still uses unsafe. That's the short-term solution. A better solution would be for typed racket to implement a different version of #:opaque that would actually wrap the values in opaque structs when they flow from untyped-to-typed and unwrap them when they flow from typed-to-untyped. That way typed racket would know how to protect the values. Alex Knauth -- 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.