On 10/29/20, William J. Bowman <[email protected]> wrote:
> I'm considering implementing, maybe as a library or a pull-request to
> racket/dict, contracts for (partially) specifying which keys exist in a
> dictionary and a contract for the value on that key.

Great!

Please make the contract error messages point out the bad key and bad
value. The error messages from hash/dc are usually too big for me, and
I end up moving my key-check and value-check contracts into a function
that checks things one-by-one.

(Maybe hash/dc can give better errors ... I never looked into a fix.)

> I've got a quick prototype here:
>
>   https://gist.github.com/wilbowma/7e97c8a38130c720568d008b288466f0
>
>   (dictof (id expr) ...)
>   A contract for a dictionary that contains exactly the keys id ... that map
> to
>   values that satisfy the contracts expr ... (respectively).
>
>   (rho-dictof (id expr) ...)
>   A contract for a dictionary that contains at least the keys id ... that
> map to
>   values that satisfy the contracts expr ... (respectively).
>
> Before I start documenting and making it a thing, I thought I'd solicit
> feedback.

Two comments:

1. make these functions, not macros

2. make "at least" the default behavior for dictof, add an option to
override (#:exact-keys?), and remove rho-dictof

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R7SMK%2BfCxGDHGm_eu%2BmTfcZ%2BZdC4R_dMceg%2Bn6VyY8oXQ%40mail.gmail.com.

Reply via email to