Moved some features out of curnel
* run is user-definable through the existing reflection features; moved to sugar. * define need not have special function support in curnel; moved to sugar. * fixed relevant documentation
This commit is contained in:
parent
2477fe9f4b
commit
bf867bca7f
|
@ -63,8 +63,7 @@
|
||||||
type-infer/syn
|
type-infer/syn
|
||||||
type-check/syn?
|
type-check/syn?
|
||||||
normalize/syn
|
normalize/syn
|
||||||
cur-equal?)
|
cur-equal?))
|
||||||
run)
|
|
||||||
|
|
||||||
(begin-for-syntax
|
(begin-for-syntax
|
||||||
;; TODO: Gamma and Sigma seem to get reset inside a module+
|
;; TODO: Gamma and Sigma seem to get reset inside a module+
|
||||||
|
@ -194,7 +193,10 @@
|
||||||
reified-term)
|
reified-term)
|
||||||
|
|
||||||
;; Reflection tools
|
;; Reflection tools
|
||||||
;; TODO: Why is this not just (define (normalize/syn syn) (denote syn syn))
|
#| TODO:
|
||||||
|
| Why is this not just (define (normalize/syn syn) (denote syn syn))?
|
||||||
|
| Well, because that has a very different meaning. Apparently.
|
||||||
|
|#
|
||||||
(define (normalize/syn syn)
|
(define (normalize/syn syn)
|
||||||
(denote
|
(denote
|
||||||
syn
|
syn
|
||||||
|
@ -227,13 +229,6 @@
|
||||||
(append (syntax-e #'(Type dep-inductive dep-lambda dep-app dep-elim dep-forall dep-top))
|
(append (syntax-e #'(Type dep-inductive dep-lambda dep-app dep-elim dep-forall dep-top))
|
||||||
ls)))))
|
ls)))))
|
||||||
|
|
||||||
;; TODO: Oops, run doesn't return a cur term but a redex term
|
|
||||||
;; wrapped in syntax bla. This is bad.
|
|
||||||
;; TODO: Should be provided by user-land code.
|
|
||||||
(define-syntax (run syn)
|
|
||||||
(syntax-case syn ()
|
|
||||||
[(_ expr) (normalize/syn #'expr)]))
|
|
||||||
|
|
||||||
;; -----------------------------------------------------------------
|
;; -----------------------------------------------------------------
|
||||||
;; Require/provide macros
|
;; Require/provide macros
|
||||||
|
|
||||||
|
@ -456,8 +451,6 @@
|
||||||
|
|
||||||
(define-syntax (dep-define syn)
|
(define-syntax (dep-define syn)
|
||||||
(syntax-parse syn
|
(syntax-parse syn
|
||||||
[(_ (name:id (x:id : t)) e)
|
|
||||||
#'(dep-define name (dep-lambda (x : t) e))]
|
|
||||||
[(_ id:id e)
|
[(_ id:id e)
|
||||||
(let ([e (cur->datum #'e)]
|
(let ([e (cur->datum #'e)]
|
||||||
[id (syntax->datum #'id)])
|
[id (syntax->datum #'id)])
|
||||||
|
|
|
@ -71,19 +71,6 @@ Runs the Cur term @racket[syn] to a value.
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@defform[(run syn)]{
|
|
||||||
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.
|
|
||||||
|
|
||||||
@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
|
|
||||||
(lambda (x : (run (if true Bool Nat))) x)]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@defproc[(cur-equal? [e1 syntax?] [e2 syntax?])
|
@defproc[(cur-equal? [e1 syntax?] [e2 syntax?])
|
||||||
boolean?]{
|
boolean?]{
|
||||||
Returns @racket[#t] if the Cur terms @racket[e1] and @racket[e2] and equivalent according to
|
Returns @racket[#t] if the Cur terms @racket[e1] and @racket[e2] and equivalent according to
|
||||||
|
|
|
@ -104,3 +104,14 @@ defined.
|
||||||
IH: ((_ : Bool))
|
IH: ((_ : Bool))
|
||||||
false])]
|
false])]
|
||||||
}
|
}
|
||||||
|
@defform[(run syn)]{
|
||||||
|
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.
|
||||||
|
|
||||||
|
@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
|
||||||
|
(lambda (x : (run (if true Bool Nat))) x)]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#%app
|
#%app
|
||||||
define
|
define
|
||||||
case
|
case
|
||||||
define-type)
|
define-type
|
||||||
|
run)
|
||||||
|
|
||||||
(require
|
(require
|
||||||
(only-in "../cur.rkt"
|
(only-in "../cur.rkt"
|
||||||
|
@ -99,3 +100,6 @@
|
||||||
#'pf #'t))
|
#'pf #'t))
|
||||||
#'pf)]))
|
#'pf)]))
|
||||||
|
|
||||||
|
(define-syntax (run syn)
|
||||||
|
(syntax-case syn ()
|
||||||
|
[(_ expr) (normalize/syn #'expr)]))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user