New property-based struct-map
This commit is contained in:
parent
45e7d209b3
commit
f68f9cb56a
12
api.rkt
12
api.rkt
|
@ -37,6 +37,7 @@
|
|||
(require "mapping.rkt")
|
||||
(require racket/set)
|
||||
(require racket/match)
|
||||
(require racket-typed-matrix/struct-map)
|
||||
|
||||
;; (These utilities need to be defined ahead of the domain struct
|
||||
;; definition.)
|
||||
|
@ -52,13 +53,10 @@
|
|||
;; www.google.com is represented as '(#"www" #"google" #"com").
|
||||
(struct domain (labels downcased-labels)
|
||||
#:transparent
|
||||
#:property prop:equal+hash (list domain=? domain-hash-1/2 domain-hash-1/2))
|
||||
|
||||
(require racket-typed-matrix/struct-map)
|
||||
(install-struct-mapper! struct:domain
|
||||
(lambda (f seed x)
|
||||
(let-values (((labels seed) (f (domain-labels x) seed)))
|
||||
(values (make-domain labels) seed))))
|
||||
#:property prop:equal+hash (list domain=? domain-hash-1/2 domain-hash-1/2)
|
||||
#:property prop:struct-map (lambda (f seed x)
|
||||
(let-values (((labels seed) (f (domain-labels x) seed)))
|
||||
(values (make-domain labels) seed))))
|
||||
|
||||
;; A ShortString is a String with length 255 or shorter.
|
||||
|
||||
|
|
Loading…
Reference in New Issue