Found source of the "ill-formed code (unexpected graph structure)" error (https://github.com/racket/racket/issues/1580)
This commit is contained in:
parent
3caeea4d9f
commit
00c5471830
|
@ -25,11 +25,36 @@
|
|||
{~seq #:invariant a {~and op {~or ∈ ∋ ≡ ≢ ∉}} b} …
|
||||
{~seq #:invariant p} …))))
|
||||
|
||||
;; DEBUG
|
||||
(require (for-syntax mzlib/pconvert
|
||||
racket/list))
|
||||
(define-for-syntax (to-datum v)
|
||||
(syntax->datum (datum->syntax #f v)))
|
||||
(define-for-syntax ((syntax-convert old-print-convert-hook)
|
||||
val basic-convert sub-convert)
|
||||
(cond
|
||||
[(set? val)
|
||||
(cons 'set (map sub-convert (set->list val)))]
|
||||
[(and (hash? val) (immutable? val))
|
||||
(cons 'hash
|
||||
(append-map (λ (p) (list (sub-convert (car p))
|
||||
(sub-convert (cdr p))))
|
||||
(hash->list val)))]
|
||||
[(syntax? val)
|
||||
(list 'syntax (to-datum val))]
|
||||
[else
|
||||
(old-print-convert-hook val basic-convert sub-convert)]))
|
||||
|
||||
(define-syntax/parse (define-graph-type . :signature)
|
||||
(define gi <graph-info>)
|
||||
(local-require racket/pretty)
|
||||
#;(parameterize ([pretty-print-columns 188])
|
||||
(pretty-print gi (current-output-port) 0))
|
||||
#;(let ([old-print-convert-hook (current-print-convert-hook)])
|
||||
(parameterize ([constructor-style-printing #t]
|
||||
[show-sharing #f]
|
||||
[current-print-convert-hook
|
||||
(syntax-convert old-print-convert-hook)])
|
||||
(parameterize ([pretty-print-columns 188])
|
||||
(pretty-write (print-convert gi)))))
|
||||
#`(begin
|
||||
(define-syntax name #,gi)))]
|
||||
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
#lang typed/racket
|
||||
#lang racket
|
||||
|
||||
(define-syntax (mk stx)
|
||||
(syntax-case stx ()
|
||||
[(_ x)
|
||||
#`(define-syntax x
|
||||
#,(make-prefab-struct 's (hash)))]))
|
||||
(mk x)
|
||||
|
||||
#|
|
||||
(require phc-adt
|
||||
(lib "phc-graph/graph-type.hl.rkt"))
|
||||
(adt-init)
|
||||
|
||||
(define-graph-type g1
|
||||
[City [name : String]
|
||||
[streets : (Listof Street)]
|
||||
[citizens : (Listof Person)]]
|
||||
[Street [name : String]
|
||||
[houses : (Listof House)]]
|
||||
[House [owner : Person]]
|
||||
[Person [name : String]]
|
||||
#:invariant City.citizens._ ∈ City.streets._.houses._.owner
|
||||
#:invariant City.citizens._ ∋ City.streets._.houses._.owner)
|
||||
#;(define-graph-type g1
|
||||
[City [name : String]
|
||||
[streets : (Listof Street)]
|
||||
[citizens : (Listof Person)]]
|
||||
[Street [name : String]
|
||||
[houses : (Listof House)]]
|
||||
[House [owner : Person]]
|
||||
[Person [name : String]]
|
||||
#:invariant City.citizens._ ∈ City.streets._.houses._.owner
|
||||
#:invariant City.citizens._ ∋ City.streets._.houses._.owner)
|
||||
|#
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user