Re: Type declarations for SRFIs?
Wolfgang Corcoran-Mathe 05 Aug 2026 16:20 UTC
Peter,
On 2026-08-05 14:24 +0200, Peter Bex wrote:
> I don't know - those SRFIs seem overly dynamic, using things like
> predicates and disjoin/union. The CHICKEN type system is a lot simpler.
I may be wrong, but I believe in Scheme it’s necessary to check types
dynamically, as in Artyom’s SRFIs, unless either (a) you have a way
to express gnarly types, or (b) you’re willing to ignore a variety
of possibilities. For example, procedures can return various numbers
of various types of values depending on their arguments, something
that makes static typing of higher-order procedures a pain at best.
For another, static typing of procedures that juggle control requires
a type system which expresses Scheme’s first-class continuations.
(I don’t mean to bash CHICKEN’s type system, which I’ve used in most
of my CHICKEN libraries. But I’ve had to resort to the ‘*’ result
type more often than I’d like.)
Whatever their runtime cost, contracts at least have the flexibility
to cover some of what Scheme offers. First-class contracts can be
dynamically constructed and passed, which can allow checking of argument
procedures of higher-order functions. (I don’t think Artyom’s SRFIs
support this yet, but it is possible.) Continuations are harder —
I don’t know how much checking it’s possible to do (especially with
undelimited ‘call/cc’ continuations), but contracts using continuation
marks and barriers might be plausible.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>