Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-30 Thread Alexis King
Okay, now I see what you’re saying. That’s a reasonable point, and it’s worth considering. Thanks for bearing with me. > On Jan 30, 2015, at 13:24, Alexander D. Knauth wrote: > > > On Jan 30, 2015, at 3:59 PM, Alexis King > wrote: > >> No, the typechecker can’t

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-30 Thread Alexander D. Knauth
On Jan 30, 2015, at 3:59 PM, Alexis King wrote: > No, the typechecker can’t make any assumptions about the results of opaque > types. If you explicitly instantiate a Posn with the type Real, the > typechecker should only guarantee the result will be Real. Annotate the type > as (U 1 2), thoug

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-30 Thread Alexander D. Knauth
On Jan 30, 2015, at 1:53 PM, Alexis King wrote: > No, it doesn’t need to be wrapped in an opaque structure. Wrapping it in an > opaque structure would add a layer of indirection for absolutely no gain. > Remember, the value itself is already, by definition, opaque. The only way > typed code c

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-30 Thread Alexis King
No, it doesn’t need to be wrapped in an opaque structure. Wrapping it in an opaque structure would add a layer of indirection for absolutely no gain. Remember, the value itself is already, by definition, opaque. The only way typed code can manipulate the value is by passing it to other functions

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-30 Thread Alexander D. Knauth
On Thu, Jan 29, 2015, at 09:03 PM, Alexis King wrote: > It isn’t wrapped in an opaque structure. That wasn’t a part of my > proposal, and while I didn’t think of it until you brought it up, I > still think it’s unnecessary and doesn’t add any convenience. I think the opaque structures would be

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexis King
It isn’t wrapped in an opaque structure. That wasn’t a part of my proposal, and while I didn’t think of it until you brought it up, I still think it’s unnecessary and doesn’t add any convenience. Perhaps I’m not understanding you properly, but your “one-length string” idea sounds like it has li

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexander D. Knauth
On Jan 29, 2015, at 11:34 PM, Alexis King wrote: >> But the problem is that if it’s an opaque type then it can’t unwrap it once >> the value is returned from make-posn. > > Yes, that’s precisely the problem. Your point about implementing everything > as single-valued structs on the typed side

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexis King
> But the problem is that if it’s an opaque type then it can’t unwrap it once > the value is returned from make-posn. Yes, that’s precisely the problem. Your point about implementing everything as single-valued structs on the typed side is an interesting one, though I don’t think it ultimately

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexander D. Knauth
Furthermore, even if the wrappers were shared between functions, untyped code would recieved wrapped values, which would render them quite useless. If it’s not an opaque type, but something like a list, then this works, and the untyped code receiving wrapped values isn’t a problem here: #lang ty

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexis King
I think you’re reading too far into what I’m proposing, though I admit I probably didn’t give enough context. I’ve been talking with Sam about this issue on IRC, so he knows what I’m talking about, but I’ll try and clarify here. This entire thing is just a fix for the problem described in Sectio

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Benjamin Greenman
This has bothered me too, but I've realized that I was on the wrong track. The string "a" and symbol 'b are not different types. A struct (Foo "a" 'b), or (list "a" 'b), is a homogeneous data structure of type (U String Symbol) just like Alexander said. This really upsets me -- I like the Hindley

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexis King
Or Any for that matter. I know. The fact that it could be literally anything was sort of the point. > On Jan 29, 2015, at 19:10, Alexander D. Knauth wrote: > > Um, for this: > (module > > t

Re: [racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexander D. Knauth
Um, for this: (module typed typed/racket/base (provide (struct-out Foo)) (struct [A] Foo ([x : A] [y : A]) #:transparent)) (Foo "a" 'b) Should be fine because Foo could be instantiated at the type (U String Symbol). On Jan 29, 2015, at 9:25 PM, Alexis King wrote: > I recently ran into a

[racket-dev] A proposal for parametric opaque types in Typed Racket

2015-01-29 Thread Alexis King
I recently ran into a problem in which opaque types (types imported from untyped code) cannot by parameterized by Typed Racket. I initially encountered this problem in my attempt to port 2htdp/image to TR . After some further considera