racket/prefab

34 views
Skip to first unread message

Andrew Kent

unread,
May 10, 2018, 10:22:11 AM5/10/18
to Racket Developers
IMHO, the tools for statically reasoning about prefab structs could use a little love. I'm trying to add better contract and type support for prefabs and I feel like I'm rewriting/duplicating boilerplate that should just exist in a `racket/prefab` module (and in fact if you search around you'll see there are a couple places where such boilerplate is lying around the Racket ecosystem).

For example, it would be nice to be able to---with just the prefab keys and field counts in hand---do the following (without _having_ to call `prefab-key->struct-type` and `struct-type-info`):
1. normalize the key to it's canonical compact form,
2. normalize the key to it's canonical verbose form (if this is actually a sensible thing to do; there's currently a function like this in Typed Racket's implementation),
3. decide if a prefab key is compatible with a particular field count,
4. decide if one prefab-key+field-count is a "subtype/subkey" of another prefab-key+field-count,
5. extract a descriptor for the immutable/mutable fields given a prefab-key+field-count
6. inquire if a particular field is mutable/immutable for a given prefab-key+field-count (w/o allocating)
7. extract a parent prefab-key+count
etc (Carl's `mischief/struct` has more that people might consider useful)

Assuming at least some of those are useful and desirable, would it be better to:

1. Export any/all useful functions from https://github.com/racket/racket/blob/master/racket/src/cs/rumble/prefab.ss and then add any additional functionality to aν explicit `racket/prefab` module? (I like this because it means less duplicate code... but it would mean the `kernel` language exporting more identifiers (I think), and perhaps that's undesirable...?)

2. Re-implement each desired function at the Racket level in a `racket/prefab` module so there is one canonical place for this kind of boilerplate?

3. Something else sensible?

Best,
Andrew
Reply all
Reply to author
Forward
0 new messages