Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and polish #140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions qi-lib/flow/extended/util.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@
#`(sieve #,@(map prettify-flow-syntax (syntax->list #'(expr ...))))]
[(partition
[e1 e2] ...)
#:with e1-prettified (map prettify-flow-syntax (attribute e1))
#:with e2-prettified (map prettify-flow-syntax (attribute e2))
#`(partition e1-prettified e2-prettified)]
#:with (e1-prettified ...) (map prettify-flow-syntax (attribute e1))
#:with (e2-prettified ...) (map prettify-flow-syntax (attribute e2))
#'(partition [e1-prettified e2-prettified] ...)]
[(try expr
[e1 e2] ...)
#:with expr-prettified (prettify-flow-syntax #'expr)
#:with e1-prettified (map prettify-flow-syntax (attribute e1))
#:with e2-prettified (map prettify-flow-syntax (attribute e2))
#`(try expr-prettified e1-prettified e2-prettified)]
#:with (e1-prettified ...) (map prettify-flow-syntax (attribute e1))
#:with (e2-prettified ...) (map prettify-flow-syntax (attribute e2))
#'(try expr-prettified [e1-prettified e2-prettified] ...)]
[(>>
expr ...)
#`(>> #,@(map prettify-flow-syntax (syntax->list #'(expr ...))))]
Expand Down
18 changes: 11 additions & 7 deletions qi-lib/flow/space.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(provide define-for-qi
define-qi-syntax
define-qi-alias
reference-qi
(for-syntax
introduce-qi-syntax))

Expand Down Expand Up @@ -39,13 +38,18 @@
#:with spaced-name (introduce-qi-syntax #'name)
#'(define-syntax spaced-name transformer)])

;; reference bindings in qi space
(define-syntax-parser reference-qi
[(_ name)
#:with spaced-name (introduce-qi-syntax #'name)
#'spaced-name])

(define-syntax-parser define-qi-alias
[(_ alias:id name:id)
#:with spaced-name (introduce-qi-syntax #'name)
#'(define-qi-syntax alias (make-rename-transformer #'spaced-name))])

;; reference bindings in qi space
;; this is in a submodule since it's only used in testing
;; and we don't provide it publicly
(module+ refer
(provide reference-qi)

(define-syntax-parser reference-qi
[(_ name)
#:with spaced-name (introduce-qi-syntax #'name)
#'spaced-name]))
9 changes: 5 additions & 4 deletions qi-test/tests/expander.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@
(group (#%host-expression a) (esc (#%host-expression b)) (esc (#%host-expression c)))
(if (esc (#%host-expression a)) (esc (#%host-expression f)))
(sieve (esc (#%host-expression a)) (esc (#%host-expression b)) (esc (#%host-expression c)))
(partition ((esc (#%host-expression a)) (esc (#%host-expression b))) ((esc (#%host-expression b)) (esc (#%host-expression c))))
(partition ((esc (#%host-expression a)) (esc (#%host-expression b)))
((esc (#%host-expression c)) (esc (#%host-expression d))))
(try (esc (#%host-expression q))
((esc (#%host-expression a)) (esc (#%host-expression b)))
((esc (#%host-expression a)) (esc (#%host-expression b))))
((esc (#%host-expression c)) (esc (#%host-expression d))))
(>> (esc (#%host-expression f)))
(<< (esc (#%host-expression f)))
(feedback (while (esc (#%host-expression f))))
Expand Down Expand Up @@ -157,8 +158,8 @@
(if a f)
(sieve a b c)
;; partition and try are actually jumbled
(partition (a b) (b c))
(try q (a a) (b b))
(partition (a b) (c d))
(try q (a b) (c d))
(>> f)
(<< f)
;; feedback grammar not handled - it's just a hack anyway
Expand Down
1 change: 1 addition & 0 deletions qi-test/tests/space.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

(require qi
qi/flow/space
(submod qi/flow/space refer)
rackunit
rackunit/text-ui
(only-in math sqr)
Expand Down
Loading