From 1b23eec4517a8628a9564c9ed25923e6c9ea5bd8 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 2 Nov 2025 19:40:29 +0100 Subject: Add custom display functions for certain model entities. --- models/nutrient-target.rkt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'models/nutrient-target.rkt') diff --git a/models/nutrient-target.rkt b/models/nutrient-target.rkt index 8611a40..5a6d673 100644 --- a/models/nutrient-target.rkt +++ b/models/nutrient-target.rkt @@ -30,7 +30,18 @@ "nutrient.rkt") ;; Instances of this struct are persisted in the nutrient_targets table. -(struct nutrient-target (id effective-on nutrient-values) #:transparent) +(struct nutrient-target (id effective-on nutrient-values) + #:transparent + #:property prop:custom-write + (λ (v out _) + (fprintf out "Target #~a on ~a\n" + (nutrient-target-id v) + (nutrient-target-effective-on v)) + (for ([nv (nutrient-target-nutrient-values v)]) + (match-define (cons n v) nv) + (fprintf out "~a ~a\n" + (~a (nutrient-name n) #:min-width 14) + (~a v #:max-width 6 #:align 'right))))) ;; CREATE -- cgit v1.2.3