This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
guile-prescheme/prescheme/record-discloser.scm
2022-07-21 22:52:47 +10:00

13 lines
465 B
Scheme

;;; Copyright 2022 Andrew Whatson
(define-module (prescheme record-discloser)
#:use-module (srfi srfi-9 gnu)
#:export (define-record-discloser))
(define (define-record-discloser type discloser)
(set-record-type-printer! type
(lambda (record port)
(let* ((vals (discloser record))
(specs (string-join (make-list (length vals) "~a")))
(template (string-append "{" specs "}")))
(apply format port template vals)))))