New property-based struct-map

This commit is contained in:
Tony Garnock-Jones 2013-03-13 17:23:18 -04:00
parent 45e7d209b3
commit f68f9cb56a
1 changed files with 5 additions and 7 deletions

12
api.rkt
View File

@ -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.