
Other than using contract
, is there a way to attach a contract to the procedure given to a struct type’s prop:procedure
property?

Never mind, I realized that the contract can be attached to a smart constructor.

I need some help trying to implement the “chaperone” version of dict/c
, on the dict-ref
method variant where a failure-result
is given as a normal value, not as a procedure. I would like to distinguish these two cases: (define/contract d (dict/c symbol? number?) (mutable-dict 'a #f))
(dict-ref d 'other #f) ; Case 1, key not found, returns #f as the failure-result, should passes contract
(dict-ref d 'a #f) ; Case 2, key found, would return #f as the value, but should fail the contract
And I need to distinguish these without calling the user’s underlying dict-ref
function multiple times. My idea was to change dict-ref
so it normalizes failure-results into procedures like this: (dict-ref d 'other (λ () #f)) ; Case 1, key not found, calls the failure-result procedure, passes contract
(dict-ref d 'a (λ () #f)) ; Case 2, key found, does not call failure-result procedure, fails the contract
When failure-result
is a procedure, this is easier to distinguish because I can chaperone that procedure to determine whether it was called. However, this brings another problem with define/generic
: (define/generic gen-dict-ref dict-ref)
(gen-dict-ref d 'other #f)
When someone uses define/generic
they can get gen-dict-ref
as the “raw” version that expects only a failure-result procedure, bypassing whatever wrapper I might put around the exported dict-ref
to fix it.
Is there a way around this problem?

Hi there! Anyone using neovim or vim to edit racket? I want to use the racket LSP there. There is no coc.nvim extension available. Besides, NVIM 0.5 provides support for LSP, I wonder if someone managed to configure it correctly?


I haven’t put in the time to fully wrap my head around this but I hope you find a solution, it seems like an important problem

I suppose that this is more a of a history question than one of practice… Is it the case that map
ought to have a universal contract attached to it, or is there some pragmatic/idiomatic reason to use the much weaker procedure?
and list?
contracts for the arguments?