typed-work
Matthew Butterick 9 years ago
parent 144536fb27
commit e64469788b

@ -16,6 +16,9 @@
(define (txexpr-tag? x)
(symbol? x))
(define (txexpr-tags? x)
(and (list? x) (andmap txexpr-tag? x)))
(define (txexpr-attr? x)
(match x
[(list (? symbol?) (? string?)) #t]

@ -8,6 +8,7 @@
[txexpr? predicate/c]
[txexpr-short? predicate/c]
[txexpr-tag? predicate/c]
[txexpr-tags? predicate/c]
[txexpr-attr? predicate/c]
[txexpr-attrs? predicate/c]
[txexpr-element? predicate/c]

@ -137,6 +137,11 @@ Predicates for @racket[_txexpr]s that implement this grammar:
@deftogether[(
@defproc[
(txexpr-tags?
[v any/c])
boolean?]
@defproc[
(txexpr-attrs?
[v any/c])
@ -147,7 +152,7 @@ boolean?]
[v any/c])
boolean?]
)]
Shorthand for @code{(listof txexpr-attr?)} and @code{(listof txexpr-element?)}.
Shorthand for @code{(listof txexpr-tag?)}, @code{(listof txexpr-attr?)}, and @code{(listof txexpr-element?)}.

@ -35,6 +35,9 @@
(check-false (txexpr-tag? "foo"))
(check-false (txexpr-tag? 3))
(check-false (txexpr-tags? 'foo))
(check-true (txexpr-tags? '(foo bar)))
(check-true (txexpr-attr? '(key "value")))
(check-false (txexpr-attr? '(key "value" "another")))
(check-false (txexpr-attr? '(key 0 "value")))

Loading…
Cancel
Save