Re: SRFI 284: define-typed
Dr. Arne Babenhauserheide 20 Sep 2026 23:45 UTC
Hi jobol,
thank you for your reply!
jobol <xxxxxx@nonadev.net> writes:
> I'm suspecting that the example
>
> (define-typed (foo a) (integer? -> (all-integer?))
> (values a a))
>
> should be
>
> (define-typed (foo a) (integer? -> all-integer?)
> (values a a))
(all-integer?) is correct: it means that `all-integer?' receives all
values to check in one go.
The parentheses are required to distinguish it from single-value return.
This:
(define (all-integer? vals)
(not (member #f (map integer? vals))))
(define-typed (foo a) (integer? -> (all-integer?))
(values a a))
Does the same value checks as
(define-typed (foo a) (integer? -> (integer? integer?))
(values a a))
But with more flexibility for the implementation (adding a third value
will still validate, because all-integer? doesn’t care about the number
of values).
The parentheses around (integer? integer?) are necessary to make this
easy to implement with syntax-rules (using an ellipsis two times at the
same depth causes problems).
For the single-return value there’s the special case without parentheses,
because that’s the most common, so it should have the least amount of
syntax overhead:
(define-typed (foo a) (integer? -> integer?) a)
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
https://www.draketo.de