Re: [racket-users] Combining contract checking with normalization?

2022-03-16 Thread jackh...@gmail.com
This is also something I want and have thought about for some time. My main use case is for functions that I want to accept an arbitrary sequence, but coerce the sequence to a list/set/etc. if it's not already a list/set/etc. I think one viable approach would be to do the following: 1. Add

Re: [racket-users] Combining contract checking with normalization?

2022-03-07 Thread David Storrs
Would this give part of what you're looking for? #lang racket (define (my-string-length s) ((or/c (and/c (or/c symbol? string?) (compose1 string-length ~a)) (curry raise-arguments-error 'my-string-length "invalid arg" "arg")) s)) (my-string-length "foo") (my-string-length 'foo)

[racket-users] Combining contract checking with normalization?

2022-03-06 Thread Alexis King
Hello, As a user of the Racket contract system, I sometimes find myself thinking about the potential utility of “coercing” or “canonicalizing” contracts. In Racket programs, we often idiomatically allow values to be provided to a function in a non-canonical form for the sake of convenience. One