utils: records: Integrate the contract system.

This commit is contained in:
Hilton Chain committed 2026-09-13 17:41:06 +08:00
1 parent a88ac359a0
commit c8625f6a8c
2 files changed
+57 -4

No files matched your search

+12 -1
View File
@@ -10,7 +10,8 @@
#:use-module (rosenthal utils contract impl)
#:use-module (rosenthal utils contract blame)
#:use-module (rosenthal utils contract combinators)
#:export (contract
#:export (apply-contract/guix-record-field
contract
define/contract))
#|
@@ -54,6 +55,16 @@ See (rosenthal utils contract impl) for more information.
(else
(((contract-enforcer ctc) blame) value negative)))))
(define-syntax apply-contract/guix-record-field
(lambda (stx)
(syntax-case stx ()
((_ ctc value record-name field-name)
(with-syntax ((field-name #'(format #f "(field: ~a)" field-name))
(location (src->location-str (syntax-source stx))))
;; Use field-name for both positive and negative parties, to ensure the
;; error message is always "contract violation".
#'(apply-contract ctc value field-name field-name record-name location))))))
(define-syntax contract
(lambda (stx)
(syntax-case stx ()