Re: [racket-users] web server: database result paging
On 04/18/2015 12:34 PM, George Neuner wrote: Hi all, I have an web server application in which I need to page results of a database query, but I also have to guarantee *exactly-once* statistical processing of each sent result row regardless of how many times it may be sent. Theresults are from a complex join, howeverthe join is separable into one that gets a list of ids and then another that usesthe ids to get the actual return data.Since the ids are separable (and small), my first thought was to gather the list of ids and then to page through the list separately retrieving theassociated data and doing statistical processing on the rows as necessary. However, to do this, I have to keep the initial id listacross multiple requestsand thatis where I've run into trouble. Thus far, I haven't had to use web server continuations. It seems like send/suspend does not allow the browser to provideadditional arguments (like paging direction). The trick with using the continuations is you don't pass any arguments through the url. All information is stored in local variables that are captured automatically by the continuation. The url will be generated for you, it just points to a continuation stored on the server. Does that make sense? It's hard to wrap your brain around at first. send/suspend/dispatch looks like it will do what I want, however Ineed to communicate the URLs to the browser in JSONand it (superficially) appears as if embed/url is meant to work in generated HTML? Youneed to use a different response function. See theattached codefor an example.Look at the docs for 'response/xexpr' to see what it does. The final problem is how to ensure that I eventually get to send/finishand clean up my thread. This particular function is expected to be executed quite often. Does the browser app have to invoke a URL that deliberately ends the thread or will the thread end if/whenits continuations timeout? What do you need to clean up? To be clear, there isn't a thread that keeps running - the continuation is just some data, and like Jay said, it will eventually be cleaned up. If you want to remove the continuations manually, call send/forward or send/finish. See the attached code. In particular, try running it, and then copying the url to a second browser window. You'll see how two users have different continuations. Apologies if this is rambling - I'm trying to sort out a bunch of things all at once. Thanks, George -- You are asking the right questions. Hope this helps, and keep asking! Thanks, Dave -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. #lang web-server/insta (require json) (define (response/json jsexpr) (response/full 200 #Okay (current-seconds) #application/json (list) (list # (jsexpr-bytes jsexpr (define (start request) ; get ids from database (define ids '(0 1 2 3 4 5 6 7 8 9)) ; idx is the index of the id we are showing (define idx 0) (let loop () ; produce stats to show to user, memoize? (define stats (* 2 (list-ref ids idx))) (send/suspend/dispatch (lambda (embed/url) ; example of json response #;(response/json (hasheq 'id (list-ref ids idx) 'url (embed/url (lambda (req) (set! idx (sub1 idx)) (loop) (response/xexpr `(html (body (p showing id ,(~a (list-ref ids idx))) (a ((href ,(embed/url (lambda (req) (set! idx (sub1 idx)) (loop) show previous id) (br) (a ((href ,(embed/url (lambda (req) (set! idx (add1 idx)) (loop) show next id) (br) (a ((href ,(embed/url (lambda (req) (send/finish (logout-page)) done (define (logout-page) (response/xexpr `(html (body continuations cleared, you're done
[racket-users] generating hyperlinks into Scribble docs
This seems straightforward but I'm getting lost in the weeds: what's the simplest way to generate hyperlinks into Scribble docs on the web (without having to manually copy the URL)? For instance, the URL for `map` looks like this: http://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29 So if I start with this: #lang racket (require scribble/manual) (unknown-function (racket map)) What is the `unknown-function` I need to generate the URL above? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Save as Scribble file extension
A while back, Lei Wang implemented an indentation mode for Scribble and it has been set up in the implementation of the reflow-paragraph keybinding (alt-q / meta-q) but it hadn't been set up for indentation. I've now done that and sorry for the long delay. (The latest snapshots should have this change.) Also, the bug in the extension handling has been fixed, so scribble should offer the extension .scrbl now. (The latest snapshots don't have this change yet.) Robby -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] generating hyperlinks into Scribble docs
Very close, thank you. The optional #:external-root-url argument turns it into an external link. #lang racket (require setup/xref scribble/xref net/url) (define (get-docs-url-string module-path export) (define xref (load-collections-xref)) (define tag (xref-binding-definition-tag xref (list module-path export) #f)) (define-values (path url-tag) (xref-tag-path+anchor xref tag #:external-root-url http://docs.racket-lang.org;)) (format ~a#~a path url-tag)) (get-docs-url-string 'racket 'map) http://docs.racket-lang.org/reference/pairs.html#(def._((lib._racket/private/map..rkt)._map)) On Sun, Apr 19, 2015 at 1:45 PM, Robby Findler ro...@eecs.northwestern.edu wrote: Is this what you're after? Robby #lang racket (require setup/xref scribble/xref net/url) (define (get-docs-url module-path export) (define xref (load-collections-xref)) (define tag (xref-binding-definition-tag xref (list module-path export) #f)) (define-values (path url-tag) (xref-tag-path+anchor xref tag)) (cond [path (define url (path-url path)) (if tag (make-url (url-scheme url) (url-user url) (url-host url) (url-port url) (url-path-absolute? url) (url-path url) (url-query url) url-tag) url)] [else #f])) (get-docs-url 'racket 'map) On Sun, Apr 19, 2015 at 2:10 PM, Matthew Butterick m...@mbtype.com wrote: This seems straightforward but I'm getting lost in the weeds: what's the simplest way to generate hyperlinks into Scribble docs on the web (without having to manually copy the URL)? For instance, the URL for `map` looks like this: http://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29 So if I start with this: #lang racket (require scribble/manual) (unknown-function (racket map)) What is the `unknown-function` I need to generate the URL above? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Save as Scribble file extension
Does this change the default extension for #lang at-exp racket too? Because that would be more confusing. If I want to use at-expressions in a normal racket file, I don’t want it to set the default extension to .scrbl. On Apr 19, 2015, at 4:38 PM, Robby Findler ro...@eecs.northwestern.edu wrote: A while back, Lei Wang implemented an indentation mode for Scribble and it has been set up in the implementation of the reflow-paragraph keybinding (alt-q / meta-q) but it hadn't been set up for indentation. I've now done that and sorry for the long delay. (The latest snapshots should have this change.) Also, the bug in the extension handling has been fixed, so scribble should offer the extension .scrbl now. (The latest snapshots don't have this change yet.) Robby -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] generating hyperlinks into Scribble docs
Is this what you're after? Robby #lang racket (require setup/xref scribble/xref net/url) (define (get-docs-url module-path export) (define xref (load-collections-xref)) (define tag (xref-binding-definition-tag xref (list module-path export) #f)) (define-values (path url-tag) (xref-tag-path+anchor xref tag)) (cond [path (define url (path-url path)) (if tag (make-url (url-scheme url) (url-user url) (url-host url) (url-port url) (url-path-absolute? url) (url-path url) (url-query url) url-tag) url)] [else #f])) (get-docs-url 'racket 'map) On Sun, Apr 19, 2015 at 2:10 PM, Matthew Butterick m...@mbtype.com wrote: This seems straightforward but I'm getting lost in the weeds: what's the simplest way to generate hyperlinks into Scribble docs on the web (without having to manually copy the URL)? For instance, the URL for `map` looks like this: http://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29 So if I start with this: #lang racket (require scribble/manual) (unknown-function (racket map)) What is the `unknown-function` I need to generate the URL above? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] raco make, file permissions, and unstable directories
Thanks Robby and Matthew. I use relative or runtime-computed paths myself so it looks like everything is clear. I do need to consider how to manage different Racket builds, right now I have stuck with the same build but updating Racket is something I will need to manage. Deren On Apr 16, 2015 3:03 AM, Robby Findler ro...@eecs.northwestern.edu wrote: 1) Compilation to .zo files (what raco make does) can theoretically embed absolute paths, but this is something we work hard to avoid, so it shouldn't be happening. We use the ability to move .zo files around when building our distributions, for example, so I think you should be safe. (But there can be bugs, of course.) The theoretical possibility exists because a macro runs arbitrary racket code to compute its output and then can embed arbitrary stuff from the context into the result of its expansion, including information about the path where compilation happens. But I really do think you can rely on this not happening unless you write your own macros that make it happen. 2) no, that seems fine. As long as you have the same version of the racket executable, the .zo files will work. (And if you don't, you'll get an error message pointing out the version mismatch.) Robby On Wed, Apr 15, 2015 at 12:50 PM, Deren Dohoda deren.doh...@gmail.com wrote: Hi group, I use Racket in an embedded linux system. My normal development process is to write Racket code in Windows, transfer this to the embedded computer, and then use raco make in the Debian system. But when the system is powered on, it doesn't boot to Debian, it boots to a busybox OS where the filesystem is read-only, and the paths are not the same. To this end, the busybox OS runs a startup script which calls racket directly to run the main file. This all works fine, but I have started to wonder about two things: 1) does raco make build in any absolute path dependencies? Should I instead remount the filesystem as read/write in busybox and run raco make there, since the busybox filesystem has different paths than the Debian filesystem? 2) suppose I run raco make on a board and copy the result out to a USB stick with a FAT filesystem which can't preserve things like execute permissions, then copy this back to a new board. Should I expect that the racket executable will have some problems with the previously-used compiled folders? Thanks for any insight here. Deren -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] typecheck error with define-namespace-anchor in 6.1.1
Unfortunately, I don't think there's an easy way to fix this in 6.1.1. That program works in current snapshots, so you might try that. Alternatively, you could put the namespace anchor in an untyped module, although that can be inconvenient for namespace anchors in particular. Sam On Sat, Apr 18, 2015 at 8:24 AM, Matthew Butterick m...@mbtype.com wrote: How would I clear this typecheck error under 6.1.1? This code: #lang typed/racket (define-namespace-anchor nsa) Produces this error: Type Checker: missing type for identifier; consider using `require/typed' to import it identifier: make-namespace-anchor from module: namespace.rkt in: #%module-begin The problem is that `make-namespace-anchor` is not an identifier provided by namespace.rkt, so there's no way to add a type using `require/typed`. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Organizing tests
Thank you Matthias This suggestion has enlightened me. I did not figure out a good way to filter tests based on their types. and, Konrad. I have a makefile.rkt to help me (and potential cooperators) build the system. The *scribble/lp* plays an important role in my development process not only because it can produce beautiful test report, but also as a hybrid of natural documentation and formal specification. The entry *scrbl *ensures that all testsuites or testcases are ordered logically. Moreover, to follow the Behavioral driven development (or just Test First) principle, module sources can keep elegant on their own. This does require some additional work to do, but I think it's worth doing. On Thu, Apr 16, 2015 at 11:28 PM, Matthias Felleisen matth...@ccs.neu.edu wrote: Use different names for the various test modules. At the local level, you can use module+ test. For the integration tests, you may wish to use module+ integration. Then run raco test with the parameter that takes the name of the submodule you want. (If you really want to run unit tests together with integration tests, import the former into the latter.) -- Matthias On Apr 16, 2015, at 11:17 AM, Konrad Hinsen wrote: Hi everyone, I want to put some order into my tests, but after looking at various published Racket packages, I am not sure if there any accepted best practices. For a single module, the best approach seems to be a submodule test for the test cases, which are then run by raco test. That's nice and works fine. But what I have is a collection with multiple modules. Each modules has local tests, but there are also tests at a higher level that use code from several modules. I am looking for an approach that lets me run either all tests in my collection, or convenient subsets (e.g. one module), ideally using a single tool such as raco test. Any suggestions? You get bonus points for solutions that integrate well with racket-mode in Emacs. Thanks in advance, Konrad. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Organizing tests
That's the --submodule or -s flag. I did `raco help test` just now and discovered even more options than I remembered. Including fun things like running tests in parallel, printing a summary table, and so on. racket-mode has a couple features related to tests and coverage. They currently assume the module is `test`. That's been sufficient for me so far, and I handle more exotic test things in a Makefile. But feel free to ping me on GitHub Issues if there are enhancements you'd use. On Thu, Apr 16, 2015 at 11:28 AM, Matthias Felleisen matth...@ccs.neu.edu wrote: Use different names for the various test modules. At the local level, you can use module+ test. For the integration tests, you may wish to use module+ integration. Then run raco test with the parameter that takes the name of the submodule you want. (If you really want to run unit tests together with integration tests, import the former into the latter.) -- Matthias On Apr 16, 2015, at 11:17 AM, Konrad Hinsen wrote: Hi everyone, I want to put some order into my tests, but after looking at various published Racket packages, I am not sure if there any accepted best practices. For a single module, the best approach seems to be a submodule test for the test cases, which are then run by raco test. That's nice and works fine. But what I have is a collection with multiple modules. Each modules has local tests, but there are also tests at a higher level that use code from several modules. I am looking for an approach that lets me run either all tests in my collection, or convenient subsets (e.g. one module), ideally using a single tool such as raco test. Any suggestions? You get bonus points for solutions that integrate well with racket-mode in Emacs. Thanks in advance, Konrad. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] receiving a copy of my own mails to racket-users@googlegroups.com
On Thu, Apr 16, 2015 at 04:39:39PM +0200, Jos Koot wrote: I receive e-mails from racket-users@googlegroups.com. However, when I send an e-mail to racket-users@googlegroups.com I don't receive my own e-mail. I'm not using gmail, but I recall hearing about this problem previously. I was able to find: https://support.google.com/mail/answer/6588 Apparently Google considers it a feature. David -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Debugging Clojure in Racket
This is a bit of an anecdote: I've started doing some Clojure and ClojureScript tutorials; the idea being to learn enough ClojureScript to use it with reactjs wrappers on the front-end. So far the experience has been quite pleasant, with my brain wrapping itself around a #lang racket cousin, overall quite similar (at least so far), but with some different design choices. But ... OMG the error messages in Clojure are not good, with abstraction leak into Java. E.g. (+ 1 foo) Clojure: ClassCastException java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add Racket: +: contract violation expected: number? given: foo argument position: 2nd other arguments.: Python (for 1 + foo): TypeError: unsupported operand type(s) for +: 'int' and 'str' This isn't too bad if you can guess the error, but for more involved cases and unfamiliar semantics the Clojure is particularly painful. Which led me to take a mysteriously failing piece of Clojure, hand-translate it to Racket (easy for a few lines), and use the Racket feedback to diagnose the problem in Clojure. Not an ideal workflow! The interesting thing, to me, is that Clojure -- *despite* this shortcoming (which one would think would be quite an obstacle to newcomers) -- is doing rather well in terms of popularity. * * * I'd be interested in hearing from anyone else who's using or has used both. I see that that Asumu has mad a little #lang clojure (couldn't get it to work: collection not found error in 6.1.1.8) and Greg Hendershott has #lang rackjure (which works, but is a hybrid by design). Dan -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Debugging Clojure in Racket
I spent some of my time at Recurse Center (formerly Hacker School) getting hands-on with Clojure. I wrote five blog posts. The first of the series is here: http://www.greghendershott.com/2014/10/hands-on-with-clojure.html -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] [CFP] Scheme and Functional Programming Workshop 2015
Call For Papers: Scheme and Functional Programming Workshop 2015 Vancouver, British Columbia, Canada (Co-located with ICFP 2015) http://andykeep.com/SchemeWorkshop2015/ Submissions related to Scheme, Racket, Clojure, and functional programming are welcome and encouraged. Topics of interest include but are not limited to: * Program-development environments, debugging, testing * Implementation (interpreters, compilers, tools, benchmarks, etc.) * Syntax, macros, hygiene * Distributed computing, concurrency, parallelism * Interoperability with other languages, FFIs * Continuations, modules, object systems, types * Theory, formal semantics, correctness * History, evolution and standardization of Scheme * Applications, experience and industrial uses of Scheme * Education * Scheme pearls (elegant, instructive uses of Scheme) We also welcome submissions related to dynamic or multiparadigmatic languages and programming techniques. Important Dates: May 22nd, 2015 - Paper deadline June 26th, 2015 - Author notification July 19th, 2015 - Camera-ready deadline September 4th, 2015 - Workshop Submissions must be in ACM proceedings format, no smaller than 9-point type (10-point type preferred). Microsoft Word and LaTeX templates for this format are available at: http://www.acm.org/sigs/sigplan/authorInformation.htm Submissions should be in PDF and printable on US Letter. To encourage authors to submit their best work, this year we are encouraging shorter papers (around 6 pages, excluding references). This is to allow authors to submit longer, revised versions of their papers to archival conferences or journals. Longer papers (10--12 pages) are also acceptable, if the extra space is needed. There is no maximum length limit on submissions, but good submissions will likely be in the range of 6 to 12 pages. More information available at: http://andykeep.com/SchemeWorkshop2015/ Organizers: Andy Keep, Cisco Systems Inc. (General Chair) Ryan Culpepper, Northeastern University (Program Chair) (Apologies for duplications from cross-posting.) -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.