Added query-type command to sugar
This commit is contained in:
parent
ff2f052a21
commit
e54c7e5bb5
|
@ -17,6 +17,7 @@
|
||||||
;; Basic syntax
|
;; Basic syntax
|
||||||
for-syntax
|
for-syntax
|
||||||
only-in
|
only-in
|
||||||
|
except-in
|
||||||
all-defined-out
|
all-defined-out
|
||||||
rename-in
|
rename-in
|
||||||
rename-out
|
rename-out
|
||||||
|
@ -44,9 +45,9 @@
|
||||||
[dep-top-interaction #%top-interaction]
|
[dep-top-interaction #%top-interaction]
|
||||||
|
|
||||||
; [dep-datum #%datum]
|
; [dep-datum #%datum]
|
||||||
[dep-define define])
|
[dep-define define]
|
||||||
|
[dep-void void])
|
||||||
begin
|
begin
|
||||||
void
|
|
||||||
Type
|
Type
|
||||||
;; DYI syntax extension
|
;; DYI syntax extension
|
||||||
define-syntax
|
define-syntax
|
||||||
|
@ -415,6 +416,8 @@
|
||||||
(syntax->curnel-syntax
|
(syntax->curnel-syntax
|
||||||
(quasisyntax/loc syn (elim D T)))]))
|
(quasisyntax/loc syn (elim D T)))]))
|
||||||
|
|
||||||
|
(define-syntax-rule (dep-void) (void))
|
||||||
|
|
||||||
;; TODO: Not sure if this is the correct behavior for #%top
|
;; TODO: Not sure if this is the correct behavior for #%top
|
||||||
(define-syntax (dep-top syn)
|
(define-syntax (dep-top syn)
|
||||||
(syntax-case syn ()
|
(syntax-case syn ()
|
||||||
|
|
|
@ -149,10 +149,15 @@ Necessary for more advanced types, like @racket[And], because @racket[case] is n
|
||||||
Like @racket[normalize/syn], but is a syntactic form which allows a Cur term to be written by
|
Like @racket[normalize/syn], but is a syntactic form which allows a Cur term to be written by
|
||||||
computing part of the term from another Cur term.
|
computing part of the term from another Cur term.
|
||||||
|
|
||||||
@margin-note{This one is a real working example, assuming the @racketmodname[cur/stdlib/bool] and
|
|
||||||
@racketmodname[cur/stdlib/nat] are loaded. Also, could be moved outside the privileged code.}
|
|
||||||
|
|
||||||
@examples[#:eval curnel-eval
|
@examples[#:eval curnel-eval
|
||||||
(lambda (x : (run (if true Bool Nat))) x)]
|
(lambda (x : (run (if true Bool Nat))) x)]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@defform[(query-type expr)]{
|
||||||
|
Print the type of @racket[expr], at compile-time. Similar to Coq's @racketfont{Check}.
|
||||||
|
|
||||||
|
@examples[#:eval curnel-eval
|
||||||
|
(query-type Bool)]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#lang s-exp "../cur.rkt"
|
#lang s-exp "../curnel/redex-lang.rkt"
|
||||||
(provide
|
(provide
|
||||||
->
|
->
|
||||||
->*
|
->*
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
case
|
case
|
||||||
case*
|
case*
|
||||||
run
|
run
|
||||||
|
query-type
|
||||||
|
|
||||||
;; don't use these
|
;; don't use these
|
||||||
define-theorem
|
define-theorem
|
||||||
|
@ -122,6 +123,14 @@
|
||||||
(syntax-case syn ()
|
(syntax-case syn ()
|
||||||
[(_ expr) (normalize/syn #'expr)]))
|
[(_ expr) (normalize/syn #'expr)]))
|
||||||
|
|
||||||
|
(define-syntax (query-type syn)
|
||||||
|
(syntax-case syn ()
|
||||||
|
[(_ term)
|
||||||
|
(begin
|
||||||
|
(printf "\"~a\" has type \"~a\"~n" (syntax->datum #'term) (syntax->datum (type-infer/syn #'term)))
|
||||||
|
;; Void is undocumented and a hack, but sort of works
|
||||||
|
#'(void))]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit (submod ".."))
|
(require rackunit (submod ".."))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user