Re: [racket-users] Typed Racket: 'Unable to protect opaque value passed as `Any`' with interesting behavior

2019-12-16 Thread Sam Tobin-Hochstadt
The best approach to this is to avoid using `Any` as the type you pass to untyped code. Often you just need to be more specific about the type; sometimes you need to use polymorphism. Sam On Mon, Dec 16, 2019 at 1:40 PM Marc Kaufmann wrote: > > Follow up on this: Is there a way to resolve this t

Re: [racket-users] Typed Racket: 'Unable to protect opaque value passed as `Any`' with interesting behavior

2019-12-16 Thread Marc Kaufmann
Follow up on this: Is there a way to resolve this type of issue when I import typed code in a non-typed place? I did hit the same issue today, roughly as follows: the typed code uses an opaque type for `Time` (using predicate `time?`), and the function `my-function` has return type `Any`, and c

Re: [racket-users] Typed Racket: 'Unable to protect opaque value passed as `Any`' with interesting behavior

2019-12-11 Thread Marc Kaufmann
Thanks. Yes, I realized that the two gave the same answer, but for debugging I tried to see if it was different. I think I now see where I am thinking about this in the wrong way. I thought `(U A B)` means 'it is either of type A or of type B', with the implication that it picks the more string

Re: [racket-users] Typed Racket: 'Unable to protect opaque value passed as `Any`' with interesting behavior

2019-12-11 Thread Sam Tobin-Hochstadt
First, (U Any response) is the same as (U response Any) which is the same as Any -- Any includes all other types and thus includes response. Second, f4 really is breaking the contract -- the contract Any turns into says: don't try to pass through any "interesting" values, or if you do, the other s

[racket-users] Typed Racket: 'Unable to protect opaque value passed as `Any`' with interesting behavior

2019-12-11 Thread Marc Kaufmann
Hello, I have one file called `type-test.rkt` with the following (notice that I discovered that there is a typed version of the web-server/http module, which solves another of my issues): ``` #lang typed/racket (require (only-in typed/web-server/http response/xexpr response)) (provide f1 f2 f