At Mon, 05 Nov 2012 08:13:16 -0500, Prabhakar Ragde wrote: > On 2012-11-05 6:43 AM, Matthew Flatt wrote: > > > Here's a first cut at a module that you can import into BSL programs. > > > > The least obvious part is defining a new `define-type' and `type-case' > > that invents hidden names for the variants and them maps between them > > while expanding to the original forms. > > Wow, thanks. I will study the code and do my best to understand it, and > test it for deployment next fall. I can already see the outline of how > your code achieves what you describe, but could you please say a few > words about why that's necessary, to improve my understanding of BSL? > Thanks again. --PR
You had worked out the need for `first-order->higher-order' on contracts for variant fields. The flip side is using BSL's `define' to define variant constructors so that BSL is willing to see them used in an application position. But if the constructors are defined with BSL's `define', then you have to give different names to the variants as defined by `define-type', so those can be wrapped by BSL-friendly definitions. The last piece, then, is to rewrite variant names in a `type-case' (which correspond to the BSL-`define'd wrappers) to the names as defined by `define-type'. ____________________ Racket Users list: http://lists.racket-lang.org/users