PasteRack.org
Paste # 84370
2025-03-28 11:47:44

Fork as a new paste.

Paste viewed 184 times.


Embed:

#lang racket/gui

(require racket/gui/easy)

(require racket/dict
         racket/function)

(struct food^ (name checked?) #:transparent)

(define (set-food^-checked? f checked?)
  (struct-copy food^ f [checked? checked?]))

(define (update-food foods k checked?)
  (dict-update foods k (curryr set-food^-checked? checked?)))

(define/obs @foods
  `((1 . ,(food^ "Apple" #t))
    (2 . ,(food^ "Banana" #f))
    (3 . ,(food^ "Broccoli" #f))
    (4 . ,(food^ "Ice Cream" #t))))
(obs-observe! @foods println)

(render

 (window
  #:size '(250 250)
  (list-view
   @foods
   #:key car
   (λ (k @id+food)
     (define @food (@id+food . ~> . cdr))
     (checkbox
      #:label (@food . ~> . food^-name)
      #:checked? (@food . ~> . food^-checked?)
      (λ (checked?)
        (@foods . <~ . (curryr update-food k checked?))))))))

=>

open-input-file: cannot open module file
  module path: racket/gui/easy
  path: /home/pasterack/racket88/collects/racket/gui/easy.rkt
  system error: no such file or directory; rkt_err=3
  context...:
   /home/pasterack/racket88/collects/racket/require-transform.rkt:266:2: expand-import
   /home/pasterack/racket88/collects/racket/private/reqprov.rkt:648:16
   /home/pasterack/racket88/collects/racket/private/reqprov.rkt:646:2: filter-by-mode
   /home/pasterack/racket88/collects/racket/require-transform.rkt:266:2: expand-import
   /home/pasterack/racket88/collects/racket/private/reqprov.rkt:287:21: try-next
   /home/pasterack/racket88/collects/racket/private/reqprov.rkt:401:21: try-next
   /home/pasterack/racket88/collects/racket/private/reqprov.rkt:258:2
   /home/pasterack/racket88/collects/syntax/wrap-modbeg.rkt:46:4
   /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/run.rkt:175:26: go
   .../private/map.rkt:40:19: loop
   .../racket/cmdline.rkt:191:51
   body of "/home/pasterack/racket88/share/pkgs/scribble-lib/scribble/run.rkt"