Make sql-null
a transparent struct.
This allows it to cooperate better with Typed Racket, particularly regarding the `Any` type. The guard and use of `#:authentic` also check that it's still a singleton in all cases.
This commit is contained in:
parent
de82588e08
commit
25efc68b17
|
@ -11,8 +11,16 @@
|
||||||
;; NULL
|
;; NULL
|
||||||
|
|
||||||
(define-values (sql-null sql-null?)
|
(define-values (sql-null sql-null?)
|
||||||
(let ()
|
(let ([created? #false])
|
||||||
(struct sql-null ()
|
(struct sql-null ()
|
||||||
|
#:transparent
|
||||||
|
#:authentic
|
||||||
|
#:guard (lambda (n)
|
||||||
|
(when created?
|
||||||
|
(error 'sql-null "cannot create new instances of sql-null"))
|
||||||
|
(set! created? #true)
|
||||||
|
(values))
|
||||||
|
#:property prop:custom-write (lambda (v p w?) (write-string "#<sql-null>" p))
|
||||||
;; must deserialize to singleton, so can't just use serializable-struct
|
;; must deserialize to singleton, so can't just use serializable-struct
|
||||||
#:property prop:serializable
|
#:property prop:serializable
|
||||||
(make-serialize-info (lambda _ '#())
|
(make-serialize-info (lambda _ '#())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user