summaryrefslogtreecommitdiff
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
parent431d0cf525f96f00a35a700a5cd5d91990a172e6 (diff)
Fix compatibility with Racket 5.1.
-rwxr-xr-xjson-template.rkt33
-rw-r--r--typed-sequence.rkt7
2 files changed, 25 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
diff --git a/typed-sequence.rkt b/typed-sequence.rkt
new file mode 100644
index 0000000..448410d
--- /dev/null
+++ b/typed-sequence.rkt
@@ -0,0 +1,7 @@
+#lang racket
+
+(provide sequence->sequence)
+
+;; Sequence -> (Sequenceof Any)
+(define (sequence->sequence x)
+ x)