summaryrefslogtreecommitdiff
path: root/json-template.rkt
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-08-11 12:18:55 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-08-11 12:18:55 +0200
commitaac8adb2b0848cc80c43c64876d17ede4c30dc27 (patch)
treee1e4a56bef7f8e14f1b66d2fb6c59f428ef22dad /json-template.rkt
parent431d0cf525f96f00a35a700a5cd5d91990a172e6 (diff)
Fix compatibility with Racket 5.1.
Diffstat (limited to 'json-template.rkt')
-rwxr-xr-xjson-template.rkt33
1 files changed, 18 insertions, 15 deletions
diff --git a/json-template.rkt b/json-template.rkt
index f1a1b54..f645206 100755
--- a/json-template.rkt
+++ b/json-template.rkt
@@ -4,13 +4,14 @@
(require/typed racket
[regexp-split (Regexp String -> (Listof String))]
- ;;[sequence->list (All (a) (Sequenceof a) -> (Listof a))]
- [sequence->list (All (a) Any -> (Listof a))] ;FIXME
[regexp-replace (Regexp String String -> String)]
- [sequence? (Any -> Boolean)]
[with-input-from-string (All (a) (String (-> a) -> a))]
- [dict-ref (Any Any Any -> Any)]
- [dict? (Any -> Boolean)])
+ [opaque Dictionary dict?]
+ [dict-ref (Dictionary Any Any -> Any)]
+ [opaque Sequence sequence?])
+
+(require/typed "typed-sequence.rkt"
+ [sequence->sequence (Sequence -> (Sequenceof Any))])
(provide: [make-template (String -> Template)]
[formatters (Parameterof (Listof (Pairof String (String -> String))))]
@@ -273,16 +274,18 @@
(cons context stack)
default-formatter))
(let: ([first-iteration? : Boolean #t])
- (for ([value (in-list context)])
- (when alternates-with
- (if first-iteration?
- (set! first-iteration? #f)
- (expand-template alternates-with
- stack
- default-formatter)))
- (expand-template body
- (cons value stack)
- default-formatter)))))]
+ (if (sequence? context)
+ (for ([value (sequence->sequence context)])
+ (when alternates-with
+ (if first-iteration?
+ (set! first-iteration? #f)
+ (expand-template alternates-with
+ stack
+ default-formatter)))
+ (expand-template body
+ (cons value stack)
+ default-formatter))
+ (error "Repeated context is not a sequence: ~S" context)))))]
[(section name body alternative)
(let ([context (resolve-path stack (name->path name))])
(if context