change `define-type' to use #:reflection-name instead of prop:custom-write
This commit is contained in:
parent
dafb9de74c
commit
e99c53eee8
|
@ -143,14 +143,7 @@
|
|||
#:transparent
|
||||
#:omit-define-syntaxes
|
||||
#:mutable
|
||||
#:property
|
||||
prop:custom-write
|
||||
(lambda (v port write?)
|
||||
((if write? write display)
|
||||
(list 'variant
|
||||
(variant-field v)
|
||||
...)
|
||||
port)))
|
||||
#:reflection-name 'variant)
|
||||
...
|
||||
(define variant?
|
||||
(flat-named-contract 'variant? variant*?))
|
||||
|
|
23
collects/tests/plai/printer.rkt
Normal file
23
collects/tests/plai/printer.rkt
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang racket/base
|
||||
(require (only-in plai define-type)
|
||||
racket/contract)
|
||||
|
||||
(define-type Foo
|
||||
[bar (v any/c)
|
||||
(v2 any/c)])
|
||||
|
||||
(define (to-string print v)
|
||||
(let ([s (open-output-string)])
|
||||
(print v s)
|
||||
(get-output-string s)))
|
||||
|
||||
(define (check a b)
|
||||
(unless (equal? a b) (error 'check "failed: ~s vs. ~s" a b)))
|
||||
|
||||
(check (to-string print (bar "a" 'b)) "(bar \"a\" 'b)")
|
||||
(check (to-string write (bar "a" 'b)) "#(struct:bar \"a\" b)")
|
||||
(check (to-string display (bar "a" 'b)) "#(struct:bar a b)")
|
||||
|
||||
(check (to-string print (list (bar "a" (list 'b)))) "(list (bar \"a\" '(b)))")
|
||||
(check (to-string write (list (bar "a" (list 'b)))) "(#(struct:bar \"a\" (b)))")
|
||||
(check (to-string display (list (bar "a" (list 'b)))) "(#(struct:bar a (b)))")
|
Loading…
Reference in New Issue
Block a user