fixes pr1

This is a potentially weird case and decision on what to do about it. In
general, when we print out answers, we try to make sure that they look
like valid datalog. In this case, a Racket value is being used a Datalog
constant (which is legal and part of the #lang datalog embedding), so we
can't know what syntax was used to get it in the first place... so by
using a ~v we get a distinctive printing that shows it isn't datalog.

On the other hand, I could change #lang datalog so that it's environment
is empty and this program wouldn't be referring to '()
This commit is contained in:
Jay McCarthy 2016-02-24 09:38:56 -05:00
parent 437a53717c
commit 84a3b742ae
2 changed files with 19 additions and 1 deletions

View File

@ -14,7 +14,9 @@
[(? string? s)
(text (format "~S" s))]
[(? number? s)
(text (format "~S" s))]))
(text (format "~S" s))]
[x
(text (format "~v" x))]))
(define (format-variable v)
(format-datum (variable-sym v)))
(define (format-constant c)

16
tests/pr/1.rkt Normal file
View File

@ -0,0 +1,16 @@
#lang datalog
type(z, tz).
listof(tz, ez).
int(ez).
casepair(z, za, tza, zb, tzb).
pair(TA, TE, null) :-
casepair(V, VA, TA, VB, TB),
type(V, TV),
listof(TV, TE).
pair(A, B, C)?