forked from syndicate-lang/preserves
Coerce integers to floats/doubles during unparse
This commit is contained in:
parent
feb6361029
commit
0d4d1e738c
|
@ -14,6 +14,8 @@
|
|||
(match (unwrap pattern)
|
||||
[(NamedSimplePattern_ n p) (pattern->unparser p (escape n))]
|
||||
[(SimplePattern-any) src-stx]
|
||||
[(SimplePattern-atom (AtomKind-Float)) `(->float ,src-stx)]
|
||||
[(SimplePattern-atom (AtomKind-Double)) `(exact->inexact ,src-stx)]
|
||||
[(SimplePattern-atom _) src-stx]
|
||||
[(SimplePattern-embedded _interface) `(embedded ,src-stx)]
|
||||
[(SimplePattern-lit v) `',v]
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
;; precision (de)serialization. In many circumstances, Racket lacks
|
||||
;; 32-bit floating point support, and single-flonum? always yields #f.
|
||||
|
||||
(provide (struct-out float))
|
||||
(provide (struct-out float)
|
||||
->float)
|
||||
|
||||
(struct float (value) #:transparent)
|
||||
|
||||
(define (->float v)
|
||||
(if (float? v)
|
||||
v
|
||||
(float (exact->inexact v))))
|
||||
|
|
Loading…
Reference in New Issue