> On Dec 1, 2016, at 16:29, David Storrs <[email protected]> wrote:
>
> - This function returns #t because it is a simple test function intended to
> get the hang of hash contracts...
> - This function takes one argument...
> - Which is a hash...
> - Which has keys 'success, 'file-id, 'scratchdir-path, and 'chunk-hash...
> - All of which are symbols...
> - The values will be, respectively:
> success boolean?
> file-id (or/c #f exact-positive-integer?)
> scratchdir-path path-string?
> chunk-hash string?
The hash/dc contract is not designed to assign contracts to the values
associated with specific keys; rather, it allows the contract on a value
to depend generally on the value of the key. You could theoretically use
the right hand side of the contract to do a case analysis on the value
of the key, but that would not be pretty. This is mostly intentional,
though: Racket hashes are designed to be used as dictionaries, not
structures.
It sounds like you likely want a struct, not a hash. Probably something
like this:
(struct some-name (success file-id scratchdir-path chunk-hash))
…with the following contract:
(struct/c some-name
boolean?
(or/c #f exact-positive-integer?)
path-string?
string?)
--
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].
For more options, visit https://groups.google.com/d/optout.