282: Missing R7RS (Type) Predicates

by Artyom Bologov

Status

This SRFI is currently in draft status. Here is an explanation of each status that a SRFI can hold. To provide input on this SRFI, please send email to srfi-282@nospamsrfi.schemers.org. To subscribe to the list, follow these instructions. You can access previous messages via the mailing list archive.

Abstract

Types and entities deserve predicates so that their user can meaningfully understand what they are dealing with, and usefully dispatch on them in their code. However, some R7RS “types” have no respective predicates. This SRFI defines them.

Issues

??? Optional section that may point out things to be resolved. This will not appear in the final SRFI.

Rationale

The discussion of types in Scheme is often predicate-reliant, including in the in R7 “Disjointness of types” section. Types are reliably represented by these predicates. (This is, in part, why the author’s own SRFIs rely on predicates for typing.) The predicate set essentially defines what types of object semantically “exist.” If there’s no predicate, there is no (programmatically-reachable) type.

Thus more predicates are needed than R7RS Small provides. There are types that do actually exist, but have no predicates proving their existence. Some implementations provide these predicates, but there’s no portable way to use them. Thus this SRFI: to have a common ground set of predicates for entities that otherwise exist in Scheme.

Specification

There are only four exported procedures in this SRFI.

(srfi 282) procedure (library? object) → boolean

This predicate returns true whenever given a library object, and false otherwise.

While libraries are part of the “meta-language” of Scheme, they are semantic entities. They might as well be represented in the run-time. Modules are present in many implementations, or otherwise, so there’s a need for a predicate checking for them.

(srfi 282) procedure (environment? object) → boolean

Returns true whenever given an environment object, as returned by environment and the like, and false otherwise.

Lack of a predicate for environments is an interesting omission in the standard. These are first-class entities of a distinct type. They deserve a predicate.

(srfi 282) procedure (parameter? object) → boolean

Returns true whenever object is a parameter object, and false otherwise.

While parameters are almost invariably represented as procedures, they might happen to be distinct callable objects. Thus the need for a predicate.

(srfi 282) procedure (syntax-transformer? object) → boolean

Returns true whenever object is a syntax transformer, like the ones returned by syntax-rules. Returns false otherwise.

While, again, these objects are not necessarily representable in all implementations, being essentially part of the Scheme meta-language some implementations do represent them as “macro” and “syntax” objects reachable programmatically, so a predicate is necessary.

Not Included

record? and record-type?. While records and their types are also part of the standard type repertoire, they have respective SRFIs, like SRFI-237 and SRFI-76.

Implementation

Sample implementation not provided yet.

The simplest conforming implementation might be:

(define (library? object) #f)
(define (environment? object) #f)
(define (parameter? object) #f)
(define (syntax-transformer? object) #f)

Acknowledgements

Thanks to numerous individuals that contributed and continue to contribute to R7RS. This SRFI is by no means an attack on them, but rather a suggestion highlighting the lack of predicates for otherwise important entities.

Thanks to Arthur Gleckler for shepherding SRFI process all these years.

© 2026 Artyom Bologov.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Editor: Arthur A. Gleckler