[racket-users] Typed Racket and struct
Hi, I've been using Typed Racket in the last few months and it has been an interesting experience. However, there are a few helpful features of "normal" Racket that are not yet available in Typed Racket. One of them is the ability to use #:constructor-name in struct type definitions. I used rename-out as a replacement but it is not the same thing and it has other annoying effects. So, my questions are: 1. Are there any plans to support #:constructor-name in Typed Racket? 2. Which techniques do you recommend to circumvent that lack of #:constructor-name ? Best regards, António. -- 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.
Re: [racket-users] Typed Racket and struct
1. define structs in untyped racket; 2. (require/typed/provide) it with #:constructor-name option. On Thu, Nov 19, 2015 at 5:11 PM, Antonio Menezes Leitao < antonio.menezes.lei...@ist.utl.pt> wrote: > Hi, > > I've been using Typed Racket in the last few months and it has been an > interesting experience. > > However, there are a few helpful features of "normal" Racket that are not > yet available in Typed Racket. > > One of them is the ability to use #:constructor-name in struct type > definitions. > > I used rename-out as a replacement but it is not the same thing and it has > other annoying effects. > > So, my questions are: > > 1. Are there any plans to support #:constructor-name in Typed Racket? > > 2. Which techniques do you recommend to circumvent that lack > of #:constructor-name ? > > Best regards, > António. > > -- > 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.
Re: [racket-users] Typed Racket and struct
Hi, On Thu, Nov 19, 2015 at 11:36 AM, WarGrey Gyoudmon Ju wrote: > 1. define structs in untyped racket; > 2. (require/typed/provide) it with #:constructor-name option. > > Thanks for the suggestion. Meanwhile, I thought about a different approach. Here is one example: (module test typed/racket (struct foo ([a : Real] [b : Integer])) (provide (except-out (struct-out foo) foo) (rename-out [foo new-foo]))) (require 'test) (define f (new-foo 1.0 2)) (foo-a f) (foo-b f) Can you (or someone else) comment on the advantages of these two approaches? Finally, can we define syntax to wrap both the module and the require? Is it possible for a macro to expand into such combination of forms? My quick experiments didn't produce the results I was expecting. Best, António. > On Thu, Nov 19, 2015 at 5:11 PM, Antonio Menezes Leitao < > antonio.menezes.lei...@ist.utl.pt> wrote: > >> Hi, >> >> I've been using Typed Racket in the last few months and it has been an >> interesting experience. >> >> However, there are a few helpful features of "normal" Racket that are not >> yet available in Typed Racket. >> >> One of them is the ability to use #:constructor-name in struct type >> definitions. >> >> I used rename-out as a replacement but it is not the same thing and it >> has other annoying effects. >> >> So, my questions are: >> >> 1. Are there any plans to support #:constructor-name in Typed Racket? >> >> 2. Which techniques do you recommend to circumvent that lack >> of #:constructor-name ? >> >> Best regards, >> António. >> >> -- >> 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. > -- 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.
Re: [racket-users] Typed Racket and struct
On 2015-11-19 09:11:08 +, Antonio Menezes Leitao wrote: >So, my questions are: >1. Are there any plans to support #:constructor-name in Typed Racket? I haven't tried to implement support for it, but I can't think of anything off the top of my head that would make it difficult. I suspect we just haven't gotten around to it. Maybe we can support it for (add1 v6.3). Cheers, Asumu -- 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.
Re: [racket-users] Typed Racket and struct
On Fri, Nov 20, 2015 at 3:27 AM, Antonio Menezes Leitao < antonio.menezes.lei...@ist.utl.pt> wrote: > Hi, > > On Thu, Nov 19, 2015 at 11:36 AM, WarGrey Gyoudmon Ju < > juzhenli...@gmail.com> wrote: > >> 1. define structs in untyped racket; >> 2. (require/typed/provide) it with #:constructor-name option. >> >> > Thanks for the suggestion. > > Meanwhile, I thought about a different approach. Here is one example: > > (module test typed/racket > (struct foo > ([a : Real] > [b : Integer])) > (provide (except-out (struct-out foo) foo) >(rename-out [foo new-foo]))) > > (require 'test) > > (define f (new-foo 1.0 2)) > > (foo-a f) > > (foo-b f) > > Can you (or someone else) comment on the advantages of these two > approaches? > Generally speaking, Racket Struct is not only a compact data collection (like a vector with fields accessors, benefits both compiler and human readers), Struct itself also has their own properties and methods to define generic interfaces which is widely known in Class-based System (ignoring that Racket Class-based System is also implemented in terms of Struct, they are different things but have same effects). Currently, Typed Racket only treats Struct as the compact data collection, therefore, if you want to take full advantages of Struct, defining it in untyped module than requiring it in typed module is the only choice, but not vice versa. I never tried your approach in practice, and you have already known the side effects. Nonetheless, if you don't like the untyped way. How about just defining one more function to make its instance? In this way, you also have a more flexible guard procedure (see #:guard option). Besides I just cannot understand the design of #:auto and #:auto-value options, it's so weird that almost makes nonsense. > > Finally, can we define syntax to wrap both the module and the require? Is > it possible for a macro to expand into such combination of forms? My quick > experiments didn't produce the results I was expecting. > I found it impossible too. > > Best, > António. > -- 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.
Re: [racket-users] Typed Racket and struct
Hi, On Fri, Nov 20, 2015 at 1:59 AM, WarGrey Gyoudmon Ju wrote: > > > On Fri, Nov 20, 2015 at 3:27 AM, Antonio Menezes Leitao < > antonio.menezes.lei...@ist.utl.pt> wrote: > >> Hi, >> >> On Thu, Nov 19, 2015 at 11:36 AM, WarGrey Gyoudmon Ju < >> juzhenli...@gmail.com> wrote: >> >>> 1. define structs in untyped racket; >>> 2. (require/typed/provide) it with #:constructor-name option. >>> >>> >> Thanks for the suggestion. >> >> Meanwhile, I thought about a different approach. Here is one example: >> >> (module test typed/racket >> (struct foo >> ([a : Real] >> [b : Integer])) >> (provide (except-out (struct-out foo) foo) >>(rename-out [foo new-foo]))) >> >> (require 'test) >> >> (define f (new-foo 1.0 2)) >> >> (foo-a f) >> >> (foo-b f) >> >> Can you (or someone else) comment on the advantages of these two >> approaches? >> > > Generally speaking, Racket Struct is not only a compact data collection > (like a vector with fields accessors, benefits both compiler and human > readers), Struct itself also has their own properties and methods to define > generic interfaces which is widely known in Class-based System (ignoring > that Racket Class-based System is also implemented in terms of Struct, they > are different things but have same effects). > > Currently, Typed Racket only treats Struct as the compact data collection, > therefore, if you want to take full advantages of Struct, defining it in > untyped module than requiring it in typed module is the only choice, but > not vice versa. > That's a good point. Thanks. > I never tried your approach in practice, and you have already known the > side effects. Nonetheless, if you don't like the untyped way. How about > just defining one more function to make its instance? In thi way, you also > have a more flexible guard procedure (see #:guard option). Besides I just > cannot understand the design of #:auto and #:auto-value options, it's so > weird that almost makes nonsense. > > >> >> Finally, can we define syntax to wrap both the module and the require? Is >> it possible for a macro to expand into such combination of forms? My quick >> experiments didn't produce the results I was expecting. >> > > I found it impossible too. > > >> >> Best, >> António. >> > > -- > 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.
Re: [racket-users] Typed Racket and struct
Hi, On Thu, Nov 19, 2015 at 8:29 PM, Asumu Takikawa wrote: > On 2015-11-19 09:11:08 +, Antonio Menezes Leitao wrote: > >So, my questions are: > >1. Are there any plans to support #:constructor-name in Typed Racket? > > I haven't tried to implement support for it, but I can't think of anything > off > the top of my head that would make it difficult. I suspect we just haven't > gotten around to it. > > Maybe we can support it for (add1 v6.3). > > That would be great! I don't mind testing it on a snapshot build. Best, António. -- 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.
Re: [racket-users] Typed Racket and struct
On 2015-11-20 16:02:32 +, Antonio Menezes Leitao wrote: >That would be great! >I don't mind testing it on a snapshot build. I created an issue for it on the TR repo so you can follow that for progress: https://github.com/racket/typed-racket/issues/253 Cheers, Asumu -- 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.
Re: [racket-users] Typed Racket and struct
On 2015-11-20 16:02:32 +, Antonio Menezes Leitao wrote: >That would be great! >I don't mind testing it on a snapshot build. Just so you know, the pre-release version of TR's struct should now support this option: http://plt.eecs.northwestern.edu/snapshots/current/doc/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._struct%29%29 Cheers, Asumu -- 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.