Re: [racket-users] Should I stop sending packages to the catalog?

2020-06-20 Thread Brian Adkins
On Saturday, June 20, 2020 at 11:35:32 AM UTC-4, Simon Schlee wrote:
>
>
> What I'd like to do is to create a personal catalog that represents the 
>> packages I currently have installed, but it doesn't appear there's a super 
>> easy `raco pkg` command to do that - I still need to research a bit.
>>
>
> raco pkg archive --help
> Create catalog from installed packages
>
> Usage:
> raco pkg archive [  ... ]   [] ...
>  where  is one of
>   --include-deps : Include dependencies of specified packages
> * --exclude  : Exclude  from new catalog
>   --relative : Make source paths relative when possible
>   --help, -h : Show this help
>   -- : Do not treat any remaining argument as a switch (at this level)
>  * Asterisks indicate options allowed multiple times.
>  Multiple single-letter switches can be combined after one `-'; for
>   example: `-h-' is the same as `-h --'
>

Yup. And then either list all the packages individually, or create an uber 
package that lists all the packages individually and archive that. Not very 
convenient, so I may look into adding a flag that creates a catalog from 
*all* of the locally installed packages.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/7744719c-b7c2-4a73-9f90-3acc2ce0a0afo%40googlegroups.com.


Re: [racket-users] Should I stop sending packages to the catalog?

2020-06-19 Thread Brian Adkins
On Friday, June 19, 2020 at 3:36:55 PM UTC-4, Hendrik Boom wrote:
>
> On Fri, Jun 19, 2020 at 07:54:29AM -0700, Brian Adkins wrote: 
> > On Friday, June 19, 2020 at 8:09:04 AM UTC-4, Neil Van Dyke wrote: 
> > > 
> > > For an important production system, you probably want the source of 
> any 
> > > third-party packages on which you depend to be in Git (or another SCM 
> > > system) that you control. 
> > > 
> > > You might also want to audit those packages yourself, as well as audit 
> > > any new version changes to them, before you push to production. 
> > > 
> > > After you do those things in SCM, depending how you do it, you *might* 
> > > find it's more convenient to simply load the third-party code you need 
> > > using the module system `require` only, without an additional package 
> > > system. 
> > > 
> > 
> > While I see some benefits of this approach, I just looked at a typical 
> > Rails project of mine, and it has over 160 packages with some packages 
> > depending on different versions of other packages, etc., so I think 
> > managing all of this myself in git might be overly burdensome. Granted, 
> my 
> > current Racket apps have far fewer dependencies, but I expect that may 
> > increase over time. 
>
> If you want to avoid problems with software you use changing 
> unpredictably, you will have to have use your own copy that does not 
> change at all. 
>
> I don't see another alternative if your upstream source might change at 
> any time. 
>
> And you will likely have to vet any chaanges that appear upstream in 
> case they actually do fix security-related issues that might already 
> be affect you.  It will be up to you to determine the risks of leaving 
> your local copy unchanged. 
>

I'm hoping the main scenario I'm concerned about (a bug is introduced in an 
update of a package) is rare, although that's exactly what motivated Alex 
to create his system. If it is a rare scenario for me, then I'd like to do 
the following:

1) Develop & test locally while updating packages as needed
2) Prior to releasing to production, so *something* that effectively 
snapshots my environment
3) Use the snapshot to deploy to production

Although I have some ideas about the "something" task, I still have to 
finalize the procedure and try it out. One option is to simply use a 
racksnap snapshot. What I'd like to do is to create a personal catalog that 
represents the packages I currently have installed, but it doesn't appear 
there's a super easy `raco pkg` command to do that - I still need to 
research a bit. Either there is a command, or it seems like a relatively 
straightforward thing to add.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/65039c0a-a001-46f6-af24-a9321a5750bao%40googlegroups.com.


Re: [racket-users] Should I stop sending packages to the catalog?

2020-06-19 Thread Brian Adkins
On Friday, June 19, 2020 at 8:09:04 AM UTC-4, Neil Van Dyke wrote:
>
> For an important production system, you probably want the source of any 
> third-party packages on which you depend to be in Git (or another SCM 
> system) that you control. 
>
> You might also want to audit those packages yourself, as well as audit 
> any new version changes to them, before you push to production. 
>
> After you do those things in SCM, depending how you do it, you *might* 
> find it's more convenient to simply load the third-party code you need 
> using the module system `require` only, without an additional package 
> system. 
>

While I see some benefits of this approach, I just looked at a typical 
Rails project of mine, and it has over 160 packages with some packages 
depending on different versions of other packages, etc., so I think 
managing all of this myself in git might be overly burdensome. Granted, my 
current Racket apps have far fewer dependencies, but I expect that may 
increase over time. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/32b8f70a-4033-43db-aca3-b30b9023f3a3o%40googlegroups.com.


Re: [racket-users] Should I stop sending packages to the catalog?

2020-06-18 Thread Brian Adkins
On Thursday, April 30, 2020 at 8:57:45 AM UTC-4, Jay McCarthy wrote:
>
> If you do so, and if your users need to pin themselves to particular 
> versions there are broadly two techniques. First, you can create your 
> own package catalog. Most users typically use two catalogs: the "big" 
> one on pkgs.racket-lang.org and another "small" one for your 
> particular release, where the core racket packages are pinned to 
> particular versions. When we were designing the package system, we 
> imagined that organizations would maintain their own catalogs of 
> audited versions of packages so they would not be surprised by any 
> automatic updates. Second, you can change your package source to pin 
> to a particular git revision/tag. This might be particularly useful if 
> a package relies on erroneous behavior of some package that was 
> otherwise fixed. 
>

I posted a message in Slack about this also, but in case the mailing list 
is preferred for whoever has the info, I'll post here also.

I'm curious about this approach. The scenario that's important to me is 
being able to control the versions of packages that my app uses. If a 
package is updated, and introduces a bug, I don't want that to cause 
failures in my production app i.e. I want the same set of packages (at 
specific versions) that I'm developing and testing with on my laptop to be 
identical to the ones I will eventually install on my servers at a later 
point in time.

Are people using this approach, described by Jay, of hosting their own 
catalogs, to accomplish this? If so, how do you get setup? In other words, 
how do you populate the catalog with the specific versions of packages you 
want? 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ff40b36c-e868-4844-b147-03d2b796f596o%40googlegroups.com.


[racket-users] Re: trying to use futures for some calculations

2020-06-17 Thread Brian Adkins
On Wednesday, June 17, 2020 at 4:50:44 AM UTC-4, Alex Harsanyi wrote:
>
>
> I am trying to speed up an algorithm using futures, but I am getting some 
> unexpected results (and no real speed improvements), and I was wondering if 
> someone more experienced could have a look a the code and tell me what am I 
> doing wrong.
>
> I put up the code in this repository: 
> https://github.com/alex-hhh/cp3-exeriments, unfortunately it is the 
> simplest meaningful example that I can come up with.  Most of the 
> functions, however are just support functions and there are six 
> implementation of the same algorithm.
> [...]
>

This is entirely unrelated to your question, but I'm curious about your 
ranges. Andy Coggan defines the following:

Neuromuscular:  < 30 seconds
Anaerobic:  30 seconds to 3 minutes
VO2max:  3 minutes to 8 minutes
Lactate Threshold: 8 to 30 minutes
Tempo:  60 to 180 minutes
Endurance:  60 to 300 minutes

I'm curious about you using 2 to 5 minutes for anaerobic. In particular, 
because I'm targeting 5 minutes as an important benchmark, and I've 
considered that as high level aerobic w/ a strong anaerobic contribution.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3a54dd48-96f7-4d1e-81e2-f192bf9320e2o%40googlegroups.com.


[racket-users] Re: trying to use futures for some calculations

2020-06-17 Thread Brian Adkins
On Wednesday, June 17, 2020 at 4:50:44 AM UTC-4, Alex Harsanyi wrote:
>
>
> I am trying to speed up an algorithm using futures, but I am getting some 
> unexpected results (and no real speed improvements), and I was wondering if 
> someone more experienced could have a look a the code and tell me what am I 
> doing wrong.
> [...]
>

I would *love* to be proven wrong on this, but I think it's rare to be able 
to get decent parallelization in practice using futures. You may have 
better results using places, but it will depend on how the amount of 
processing for a unit compares to the overhead of communicating with the 
places i.e. you may get better results with 2 places than with 8 due to 
place communication overhead. In your case, if it's easy for the places to 
input their own sets of parameters, then the place overhead may be small 
since I think each place would simply need to communicate its best value.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/633393c0-319c-4d7a-a587-cee2d6ab3eb4o%40googlegroups.com.


[racket-users] Re: current racket dynamic web performance in production?

2020-06-04 Thread Brian Adkins
On Thursday, June 4, 2020 at 1:45:30 AM UTC-4, Neil Van Dyke wrote:
>
> I'm now leading engineering at a startup with an established Python & 
> Flask infrastructure, and happen to urgently need an additional dynamic 
> Web service backend that's separate from the rest of our 
> infrastructure...  While I could do it in Flask, I was thinking that 
> this might also be an opportunity for a Scheme (Racket) pilot project 
> for the company,[1] looking ahead to tech stack selection for some much 
> larger infrastructure expected next year (if the startup survives the 
> virus). 
>
> The problem with this as a pilot project is that this server will see 
> only very light duty, and therefore not good for evaluating real world 
> viability for the expected future high-traffic needs. 
>
> So I was wondering whether anyone (other than HN, and the bespoke 
> framework stuff I worked on atop the `scgi` package) is currently using 
> Racket for dynamic HTTP/S backend in a *high traffic* setup? And if you 
> are handling high traffic, what kinds of performance are you seeing 
> (e.g., request volume, simultaneous requests, latency, GC 
> characteristics), and how have you built it (e.g., which HTTP libraries, 
> what kind of server infrastructure)? 
>

I have two Racket web apps in production, but I wouldn't say they're high 
traffic. I'm also curious about any high volume use of Racket.

As part of my due diligence in choosing Racket, after more a couple decades 
of web development in Java, .NET and Ruby/Rails, I satisfied myself that 
the performance exceeded Ruby/Rails significantly by running a number of 
benchmarks on the typical workloads my apps experience. Using one Racket 
process per core with a thread per request within each process makes *much* 
better use of the CPU for a given amount of RAM than a typical Rails setup 
does.

The current architecture is very simple - I use an nginx web server as both 
a load balancer and to handle SSL. This delegates to two Racket processes 
(managed by systemd) on a two core server. Postgres runs on a separate AWS 
RDS server. Moving to a "real" load balancer in front of multiple EC2 
instances would be trivial, and would handle a tremendous amount of traffic.

I mentioned in another thread that an Apache Bench benchmark showed 350 
requests per second on an AWS EC2 t3.small server w/ both the Apache Bench 
and web app running on the same server. A t3.small is very limited, so ~ 
350 req/s (i.e. roughly a billion req/month) seems like very reasonable 
performance.

As to libraries, etc., I'm using the Axio Web Framework. Unfortunately, 
nothing is yet available publicly since I'm still developing it. The second 
web app allowed me to make significant enhancements, and a third planned 
web app will probably provide a few more unique demands to round out the 
functionality enough to publish a 0.1 version.

An important caveat is that I'm *not* currently developing with a 
complicated ORM setup, and that's an area where Rails has made many 
refinements in terms of both usage & caching. The initial release of Axio 
will *not* contain an ORM, but it will have a number of niceties for 
interacting with the database. After a decade of Rails usage, I was quite 
surprised at how little I was impacted by working more directly with SQL.

Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/088c4a80-93fb-41ec-b61a-a0d7a9b58531%40googlegroups.com.


Re: [racket-users] Re: [racket] Web Framework Benchmarks

2020-06-01 Thread Brian Adkins
I may look into this in more detail later, but I ran a simple benchmark 
comparison on my modest AWS EC2 server (ApacheBench can behave poorly on 
MacOS).

1) I ran ApacheBench w/ 6 processes to fetch a simple "hello world" static 
html file using only nginx. I got roughly 650 requests per second.

2) I then ran ApacheBench w/ 6 processes against one of my Racket web apps 
using a monitoring endpoint that does a simple db query to determine the 
health of the server, so this went from nginx (acting as a load balancer 
and https handler) to the Racket processes via proxy_pass (only 2 running 
in parallel) which exercises my custom dispatching and a simple postgres 
query. No continuations and completely stateless. I got roughly 350 
requests per second.

At first glance, that doesn't appear to be that much overhead when 
comparing the two. In fact, I would've expected the very small static html 
request to be significantly more than double the req/sec of the Racket app 
db request.

I developed Rails apps for over a decade, and I know my Racket web apps are 
significantly faster in similar "database backed web apps" context.

I believe there is something wrong with those benchmarks at the moment.

Brian

On Monday, June 1, 2020 at 3:40:52 PM UTC-4, Sam Tobin-Hochstadt wrote:
>
> I'm skeptical both of the DB explanation and the multi-core 
> explanation. As you say, the difference between something like Django 
> and Racket is much too large to be explained by that. For example, on 
> the "plaintext" benchmark, Racket serves about 700 req/sec (I get 
> similar results on my machine). Many of the benchmarks in languages 
> like Python and Ruby do more than 1000x better, which means that even 
> if we had perfect speedup on 32 cores, we'd be nowhere close. 
> Additionally, the "plaintext" benchmark doesn't touch the DB at all. I 
> tried commenting out all of the DB code entirely, and it did not 
> change the results. 
>
> My guess is that the web server is just doing a lot of per-response 
> work that would need to be optimized. 
>
> Sam 
>
> On Mon, Jun 1, 2020 at 2:12 PM George Neuner  > wrote: 
> > 
> > 
> > On 6/1/2020 1:40 PM, Bogdan Popa wrote: 
> > > I replied earlier today off of my Phone, but, for whatever reason 
> > > (caught in the moderation queue?), it's not showing up in this thread. 
> > > 
> > > Here's what it said: 
> > > 
> > > The reason for poor performance relative to the other 
> > > langs/frameworks is that there is currently no easy way to take 
> > > advantage of multiple cores using the web framework so that's 
> being 
> > > benchmarked is single-core performance. 
> > > 
> > > This is mainly a problem for benchmarks such as this, but not 
> really 
> > > an issue in the real world where you'd just run multiple processes 
> > > with a load balancer in front. 
> > 
> > Single core [by itself] doesn't explain the enormous performance 
> > difference between Racket and Django. 
> > 
> > I haven't looked at the Django submission - Python's (in)comprehensions 
> > give me a headache.  But Python's DB pool is threaded, and Python's 
> > threads are core limited by the GIL in all the major implementations 
> > (excepting Jython). 
> > 
> > There are a few things Python can do faster than Racket, but the VAST 
> > difference in performance shown in the techempower tests isn't explained 
> > by them.  My suspicion is that the Racket application is making too many 
> > database connections and not relying enough on its open connection 
> > pool.  Hundreds of trivial requests can be served in the time it takes 
> > to spin up a new backend process. 
> > 
> > YMMV, 
> > George 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/9236dcff-81df-1db8-c2ef-06b20e4690ec%40comcast.net.
>  
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ce26a93b-e1f2-425a-abc9-be991ff0e4e4%40googlegroups.com.


Re: [racket-users] Re: Practical HTTP requests?

2020-05-17 Thread Brian Adkins
Sorry - missed the fact that you already found the cookie library :)

On Sunday, May 17, 2020 at 5:08:32 PM UTC-4, Brian Adkins wrote:
>
> I spent many years developing in Ruby before switching to Racket, so I 
> understand the appeal of a "batteries included" language. Python excels in 
> this area. If you're weighting the "batteries included" aspect very high, 
> then Racket may not be suitable for you at this time, but in that case, I 
> expect you'd just stick with Python.
>
> If you're patient, I think you may find many compelling reasons to 
> consider Racket. I won't list them here (other than the fact that the 
> community alone is compelling enough to invest more time learning the 
> language), or advocate for the language in general, but if you decide to 
> check it out more thoroughly later, another library that may be of interest 
> is:
>
> https://docs.racket-lang.org/cookies/index.html
>
> I've been developing web applications in Racket for the last year and a 
> half, or so, but I've been focused on server-side functionality, and I've 
> either found a Racket package that does what I need directly, or I've found 
> a set of them that allow me to easily layer the extra code on top that I 
> need. I was used to the Rails framework, so I thought it would be tough 
> switching to Racket, but in hindsight, it was trivial.
>
> I will be doing more web scraping soon for some data science applications, 
> and given what Racket provides currently, it will be easy to write 
> something that fulfills the requirements you listed in your first post, 
> although I have no need for proxy servers personally.
>
> Brian
>
> On Sunday, May 17, 2020 at 4:02:59 PM UTC-4, fixpoint wrote:
>>
>> Thanks, but that library does not support proxies. Oh well, my Racket 
>> adventures have come to an end as I’ll be unable to convince others at work 
>> to try it without a practical, batteries included http library. 
>>
>> On Sunday, May 17, 2020 at 2:14:19 PM UTC-5, Jens Axel Søgaard wrote:
>>>
>>> Take a look at the `http` package.
>>>
>>> https://docs.racket-lang.org/http/index.html
>>>
>>> I believe it can be used to receive and send cookies (and other 
>>> headers), but 
>>> I don't know how much is automatic.
>>>
>>> /Jens Axel
>>>
>>> Racket Stories
>>> https://racket-stories.com
>>>
>>>
>>>
>>> Den søn. 17. maj 2020 kl. 17.51 skrev fixpoint :
>>>
>>>> I was under the incorrect impression that net/url did not support HTTP 
>>>> 1.1. I suspect I stumbled upon some out of date information on 
>>>> stackoverflow. Thanks for pointing me in the right direction. Using 
>>>> net/url, net/cookies, and json, I hacked the following code (please be 
>>>> gentle, it is literally the first lines of Racket I've ever written). 
>>>> There 
>>>> are two key problems with this code:
>>>>
>>>>1. Because cookies handling is not part of net/url, my use of 
>>>>get-pure-port/headers is not able to see cookies, and thus save 
>>>>them, in any of the 3xx redirect responses.
>>>>2. I need a post-pure-port/headers equivalent, so I can post data 
>>>>and reuse the connection. It looks like you can only reuse connections 
>>>> in 
>>>>net/url with only get-pure-port/headers.
>>>>
>>>> Am I missing any other libraries out there?
>>>>
>>>> #lang racket
>>>>
>>>> (require json
>>>>  net/head
>>>>  net/url
>>>>  net/cookies/user-agent)
>>>>
>>>>
>>>> (define (get-json-request url #:connection conn)
>>>>   (define req-headers
>>>> (let ([cookies (cookie-header url)])
>>>>   (cond [(false? cookies) '()]
>>>> [else (list (format "Cookie: ~a" cookies))])))
>>>>   (display (format "Headers sent were:\n ~a\n" req-headers))
>>>>   (define-values
>>>> (in-port resp-headers)
>>>> (get-pure-port/headers url req-headers #:connection conn 
>>>> #:redirections 1))
>>>>   (extract-and-save-cookies! (map string->bytes/utf-8 (string-split 
>>>> resp-headers "\r\n")) url)
>>>>   (display (format "\nReceived headers were:\n ~a" resp-headers))
>>>>   (read-json in-port))
>>>>
>>>>
>>>> ;; Start a session
>>>> (de

Re: [racket-users] Re: Practical HTTP requests?

2020-05-17 Thread Brian Adkins
I spent many years developing in Ruby before switching to Racket, so I 
understand the appeal of a "batteries included" language. Python excels in 
this area. If you're weighting the "batteries included" aspect very high, 
then Racket may not be suitable for you at this time, but in that case, I 
expect you'd just stick with Python.

If you're patient, I think you may find many compelling reasons to consider 
Racket. I won't list them here (other than the fact that the community 
alone is compelling enough to invest more time learning the language), or 
advocate for the language in general, but if you decide to check it out 
more thoroughly later, another library that may be of interest is:

https://docs.racket-lang.org/cookies/index.html

I've been developing web applications in Racket for the last year and a 
half, or so, but I've been focused on server-side functionality, and I've 
either found a Racket package that does what I need directly, or I've found 
a set of them that allow me to easily layer the extra code on top that I 
need. I was used to the Rails framework, so I thought it would be tough 
switching to Racket, but in hindsight, it was trivial.

I will be doing more web scraping soon for some data science applications, 
and given what Racket provides currently, it will be easy to write 
something that fulfills the requirements you listed in your first post, 
although I have no need for proxy servers personally.

Brian

On Sunday, May 17, 2020 at 4:02:59 PM UTC-4, fixpoint wrote:
>
> Thanks, but that library does not support proxies. Oh well, my Racket 
> adventures have come to an end as I’ll be unable to convince others at work 
> to try it without a practical, batteries included http library. 
>
> On Sunday, May 17, 2020 at 2:14:19 PM UTC-5, Jens Axel Søgaard wrote:
>>
>> Take a look at the `http` package.
>>
>> https://docs.racket-lang.org/http/index.html
>>
>> I believe it can be used to receive and send cookies (and other headers), 
>> but 
>> I don't know how much is automatic.
>>
>> /Jens Axel
>>
>> Racket Stories
>> https://racket-stories.com
>>
>>
>>
>> Den søn. 17. maj 2020 kl. 17.51 skrev fixpoint :
>>
>>> I was under the incorrect impression that net/url did not support HTTP 
>>> 1.1. I suspect I stumbled upon some out of date information on 
>>> stackoverflow. Thanks for pointing me in the right direction. Using 
>>> net/url, net/cookies, and json, I hacked the following code (please be 
>>> gentle, it is literally the first lines of Racket I've ever written). There 
>>> are two key problems with this code:
>>>
>>>1. Because cookies handling is not part of net/url, my use of 
>>>get-pure-port/headers is not able to see cookies, and thus save 
>>>them, in any of the 3xx redirect responses.
>>>2. I need a post-pure-port/headers equivalent, so I can post data 
>>>and reuse the connection. It looks like you can only reuse connections 
>>> in 
>>>net/url with only get-pure-port/headers.
>>>
>>> Am I missing any other libraries out there?
>>>
>>> #lang racket
>>>
>>> (require json
>>>  net/head
>>>  net/url
>>>  net/cookies/user-agent)
>>>
>>>
>>> (define (get-json-request url #:connection conn)
>>>   (define req-headers
>>> (let ([cookies (cookie-header url)])
>>>   (cond [(false? cookies) '()]
>>> [else (list (format "Cookie: ~a" cookies))])))
>>>   (display (format "Headers sent were:\n ~a\n" req-headers))
>>>   (define-values
>>> (in-port resp-headers)
>>> (get-pure-port/headers url req-headers #:connection conn 
>>> #:redirections 1))
>>>   (extract-and-save-cookies! (map string->bytes/utf-8 (string-split 
>>> resp-headers "\r\n")) url)
>>>   (display (format "\nReceived headers were:\n ~a" resp-headers))
>>>   (read-json in-port))
>>>
>>>
>>> ;; Start a session
>>> (define conn (make-http-connection))
>>>
>>> ;; Make a request that will force server to set cookies
>>> (displayln (jsexpr->string
>>> (get-json-request
>>>  (string->url "
>>> https://postman-echo.com/cookies/set?foo1=bar1=bar2;)
>>>  #:connection conn)))
>>>
>>> ;; Make another request to see what cookies we sent server
>>> (displayln "\n--\n")
>>> (displayln (jsexpr->string
>>> (get-json-request
>>>  (string->url "https://postman-echo.com/cookies;)
>>>  #:connection conn)))
>>>
>>> ;; Close session
>>> (http-connection-close conn)
>>>
>>>
>>>
>>>  
>>>
>>>
>>>
>>>
>>> On Sunday, May 17, 2020 at 4:44:32 AM UTC-5, evdubs wrote:

 Have you taken a look at net/url 
 ? From there, I 
 see:

- make-http-connection 

 ,
  
which can allow calls to get-pure-port/headers to stay connected if 
the server 

[racket-users] Re: Exception throwing in web-server

2020-05-17 Thread Brian Adkins
On Saturday, May 16, 2020 at 3:16:18 PM UTC-4, Norman Gray wrote:
>
> [...]
> The exception is thrown inside the 'output' procedure 
> that's provided as the last argument to the 'response' constructor (I 
> belatedly realise this is probably a bad idea). 
> [...]
> But (a) what should I be doing? And (b) since that exception is caught 
> in this with-handlers clause, what is it that's producing the (default) 
> exception output message?  And (c) should I expect the client just to 
> hang here? 
>
> I'm guessing that an answer to (a) is 'avoid throwing exceptions inside 
> 'output', but given that that will sometimes happen, is the 
> output-response-body/chunked procedure doing the right thing here?  Am I 
> missing something? 
>

I think you need to decide when to stream, and when not to stream. In my 
web framework, most requests involve computing the entire response string 
prior to calling (response ...), so if an error is encountered, I can send 
an error response instead of a success response.

Currently, the only time I stream a response is when the client is 
downloading CSV output. In that case, there is little chance of an error 
occurring once the streaming begins. I just briefly reviewed some HTTP 
protocol information, and I couldn't find anything that would allow sending 
a 500 response after the 200 response has already be sent i.e. no way to 
switch from success to error mid-stream.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c331d8b9-ce3c-4433-b50f-37432f2a8e3e%40googlegroups.com.


[racket-users] Re: Racket v7.7

2020-05-17 Thread Brian Adkins
On Saturday, May 2, 2020 at 3:03:01 PM UTC-4, johnbclements wrote:
>
> Racket version 7.7 is now available from  

 [...]
>
The following people contributed to this release: 
>
> Alexander Shopov, Ben Greenman, Benjamin Yeung, Brian Adkins, Brian 
> Wignall, Chongkai Zhu, Craig Ferry, David Florness, Fred Fu, Greg 
> Hendershott, Gustavo Massaccesi, Ilnar Salimzianov, Jack Firth, James 
> Bornholt, Jay McCarthy, Jens Axel Søgaard, Jesse Alama, John Clements, 
> Jon Zeppieri, Kartik Singhal, Laurent Orseau, Leo Shen, Luka 
> Hadži-Đokić, Matthew Butterick, Matthew Flatt, Matthias Felleisen, Mike 
> Sperber, Noah W M, Paulo Matos, Philip McGrath, Philippe Meunier, 
> Ricardo Herdt, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, 
> Sorawee Porncharoenwase, Spencer Florence, Stephen Chang, 
> Syntacticlosure, Thaddäus Töppen, Tom Gillespie, Xu Chunyang, ZHUO 
> Qingliang, kryptine, mehlon, muzimuzhi, redwyn, and Štěpán Němec 
>

So embarrassing - not only is my first contribution to my favorite 
programming language a typo fix, it was a typo in an easter egg!  I hope to 
do better with future contributions :)
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c7ac1bcf-edb7-4c06-9ee1-e416134ce29f%40googlegroups.com.


Re: [racket-users] Examples of sending HTML email w/ Racket?

2020-04-09 Thread Brian Adkins
On Thursday, April 9, 2020 at 8:47:09 AM UTC-4, Matthew Flatt wrote:
>
> At Wed, 8 Apr 2020 21:28:11 -0400, George Neuner wrote: 
> > There's nothing in Racket for MIME that I'm aware of 
>
> There's a `net/mime` library. 
>
> I'm replying with an attachment so you can see what it generates, since 
> my email client uses that library. 
>
>
> Matthew 
>

I looked at the net/mime library, but, as the title of the doc page 
suggests, it seemed to only be about decoding, not creating:

https://docs.racket-lang.org/net/mime.html?q=net%2Fmime

Are the functions for creating multipart email messages documented 
elsewhere?

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a80d82e5-17f4-4e5e-b41b-4a809a6bd954%40googlegroups.com.


Re: [racket-users] Examples of sending HTML email w/ Racket?

2020-04-08 Thread Brian Adkins
On Wednesday, April 8, 2020 at 6:09:14 PM UTC-4, Brian Adkins wrote:
>
> On Wednesday, April 8, 2020 at 1:46:43 PM UTC-4, gneuner2 wrote:
>>
>>
>> On 4/8/2020 12:54 PM, Brian Adkins wrote: 
>> > I was able to write a simple wrapper around smtp-send-message and get 
>> > it working through SendGrid in a few minutes (see below), but I wasn't 
>> > able to find any examples of sending emails containing both a plain 
>> > text version and HTML version. Can anyone point me to some examples? 
>> > 
>> > Thanks, 
>> > Brian Adkins 
>>
>> You done the hard part.  Once you can send a plain text message, HTML is 
>> not much harder. 
>>
>> You have to construct a MIME multipart message, which has a particular 
>> internal structure. 
>> See: 
>>
>> https://stackoverflow.com/questions/10631856/mime-type-to-satisfy-html-email-images-and-plain-text
>>  
>> http://www.enewsletterpro.com/articles/multi_part_mime_messages.asp 
>> https://www.ietf.org/rfc/rfc1521.txt 
>>
>>
>> My solution is to use message templates like the attached - which shows 
>> using not just multipart but also embedded graphics.  My program 
>> customizes the message by substituting for the '@' preceded "variables" 
>> in the template.  Feel free to (ab)use the same style or adapt it for 
>> your needs. 
>>
>> George 
>>
>>
> Thanks for the info George. Are you feeding that entire template (after 
> substituting the @ variables) into the smtp-send-message function as the 
> message argument i.e. a list of lines? I'm also curious about having 
> "subject" in the template vs. the header.
>
> I take it from your reply there isn't already something in existence that 
> streamlines this process in a similar way to a framework such as Rails.
>

I got it to work by stuffing the right values into the header - thanks!
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/bbd7b148-4530-4b92-9f5c-2698a0709845%40googlegroups.com.


Re: [racket-users] Examples of sending HTML email w/ Racket?

2020-04-08 Thread Brian Adkins
On Wednesday, April 8, 2020 at 1:46:43 PM UTC-4, gneuner2 wrote:
>
>
> On 4/8/2020 12:54 PM, Brian Adkins wrote: 
> > I was able to write a simple wrapper around smtp-send-message and get 
> > it working through SendGrid in a few minutes (see below), but I wasn't 
> > able to find any examples of sending emails containing both a plain 
> > text version and HTML version. Can anyone point me to some examples? 
> > 
> > Thanks, 
> > Brian Adkins 
>
> You done the hard part.  Once you can send a plain text message, HTML is 
> not much harder. 
>
> You have to construct a MIME multipart message, which has a particular 
> internal structure. 
> See: 
>
> https://stackoverflow.com/questions/10631856/mime-type-to-satisfy-html-email-images-and-plain-text
>  
> http://www.enewsletterpro.com/articles/multi_part_mime_messages.asp 
> https://www.ietf.org/rfc/rfc1521.txt 
>
>
> My solution is to use message templates like the attached - which shows 
> using not just multipart but also embedded graphics.  My program 
> customizes the message by substituting for the '@' preceded "variables" 
> in the template.  Feel free to (ab)use the same style or adapt it for 
> your needs. 
>
> George 
>
>
Thanks for the info George. Are you feeding that entire template (after 
substituting the @ variables) into the smtp-send-message function as the 
message argument i.e. a list of lines? I'm also curious about having 
"subject" in the template vs. the header.

I take it from your reply there isn't already something in existence that 
streamlines this process in a similar way to a framework such as Rails.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/420bc8df-b72f-43d9-9bf4-b5dbf2dad6ed%40googlegroups.com.


[racket-users] Examples of sending HTML email w/ Racket?

2020-04-08 Thread Brian Adkins
I was able to write a simple wrapper around smtp-send-message and get it 
working through SendGrid in a few minutes (see below), but I wasn't able to 
find any examples of sending emails containing both a plain text version 
and HTML version. Can anyone point me to some examples?

Thanks,
Brian Adkins


#lang racket/base

(require net/head
 net/smtp
 openssl
 racket/contract)
(require "./axio-env.rkt")

;; (module+ main
;;   (send-email "Fred Flintstone "
;;   '("Barney Rubble ")
;;   "Test message subject"
;;   (list
;;"Message line one"
;;"line two"
;;""
;;"line four")))
(define/contract (send-email from to subject message-lines)
  (-> string? (listof string?) string? (listof (or/c string? bytes?)) any)
  (smtp-send-message smtp-server
 from
 to
 (standard-message-header from to '() '() subject)
 message-lines
 #:port-no smtp-port
 #:auth-user   smtp-username
 #:auth-passwd smtp-password
 #:tls-encode  ports->ssl-ports))

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/7dd13674-5f20-4e4d-92de-0da0e2bc7c95%40googlegroups.com.


Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Brian Adkins
On Monday, December 3, 2018 at 10:49:40 AM UTC-5, Jay McCarthy wrote:
>
> > I don't know if the Racket web server (or related libraries) currently 
> provide a way to stream data in the response, but that is something I'll 
> definitely need relatively soon (primarily for streaming large CSV/JSON 
> files). If it doesn't exist, I don't mind writing it, but I also don't want 
> to begin with an approach now that might make adding that capability more 
> difficult later. From my brief research, given the output field of the 
> response struct is a lambda, I think I can stream using that (i.e. return a 
> lambda in the response immediately that begins writing the data as it 
> retrieves it) - hopefully the infrastructure doesn't buffer the entire 
> output. Other than something like that, I'm happy to work mostly at the 
> level of functions from requests to responses. 
>
> The reason why responses have the lambda rather than a byte string is 
> specifically for streaming like you want. Make sure you specify the 
> correct response size in the headers. 


Jay, are you sure it's necessary to specify the correct response size in 
the headers? This would be extremely inconvenient in a streaming response 
scenario. I looked at some similar code in a Rails project, and it appears 
I'm only setting Last-Modified, Content-Disposition and Content-Type 
headers.

Yes, I know this is an old thread, but I'm just now having to stream some 
CSV files from the web app :) 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/995deb39-16f7-432e-8931-3bbae4d86bb7%40googlegroups.com.


Re: [racket-users] How to stream file uploads with the Racket web server?

2020-02-14 Thread Brian Adkins
Hmm... I don't see a new message in the thread, so I'm not sure what you 
approved. No worries though.

On Friday, February 14, 2020 at 7:36:26 AM UTC-5, Robby Findler wrote:
>
> It is possible that your post wasn't deleted but got held up in 
> google's spam traps. I just approved a message from you (that I was 
> alerted to only this morning). Was that the message? 
>
> Robby 
>
> On Thu, Feb 13, 2020 at 2:57 PM Brian Adkins  > wrote: 
> > 
> > I tried replying earlier today, but somehow the post got deleted - 
> could've been user error I suppose. 
> > 
> > Anyway, the gist of the response was how I continue to be amazed by how 
> often I get pleasant surprises with Racket - either there is some facility 
> to do what I want that I just haven't found yet, or in this case where 
> there soon will be :) 
> > 
> > I have a couple Racket web apps in production now, so I think I have 
> enough real world examples to begin extracting code into a web framework. 
> Although it will look significantly different than Rails (more functional, 
> less object oriented), I'm hoping to achieve similar ease-of-use 
> functionality. I first viewed the Rails "weblog in 15 minutes" video 
> fourteen years ago, and it had a significant impact on my professional life 
> (at the time I was working in Java w/ Spring & Hibernate, etc.). The video 
> is dated now & has some annoying idiosyncrasies, but if you haven't seen 
> it, and you're interested in web development (in any language), it's worth 
> viewing just to get the overview of Rails ease of use: 
> > 
> > https://www.youtube.com/watch?v=Gzj723LkRJY=youtu.be 
> > 
> > On Thursday, February 13, 2020 at 11:02:33 AM UTC-5, bogdan wrote: 
> >> 
> >> The version of the web-server that will be included with Racket 7.6 
> >> changes the way file uploads are handled so that they get offloaded to 
> >> disk after a certain threshold (similar to how that nginx module you 
> >> linked to works). 
> >> 
> >> You can check out the pre-release docs for details: 
> >> 
> >> * 
> https://pre-release.racket-lang.org/doc/web-server/http.html?q=binding%3Afile#%28def._%28%28lib._web-server%2Fhttp%2Frequest-structs..rkt%29._make-binding~3afile%2Fport%29%29
>  
> >> * 
> https://pre-release.racket-lang.org/doc/web-server-internal/dispatch-server-unit.html#%28part._safety-limits%29
>  
> >> 
> >> To get these changes ahead of the release, you should be able to 
> install 
> >> an updated version of `web-server-lib' from the package server or from 
> git. 
> >> 
> >> Hope that helps! 
> >> 
> >> - Bogdan 
> >> 
> >> Brian Adkins writes: 
> >> 
> >> > I'm posting a file to my web app using the following form: 
> >> > 
> >> >  >> >   method="post" *enctype="multipart/form-data"* 
> >> > class="file-upload-form"> 
> >> > ... 
> >> >  
> >> > 
> >> > I use a simple function to create a hashtable of attributes: 
> >> > 
> >> > (define (form-values req) 
> >> >   (for/hash ([ b (in-list (request-bindings/raw req)) ]) 
> >> > (cond [ (binding:form? b) (values 
> >> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >> >(bytes->string/utf-8 
> (binding:form-value b) 
> >> > #\space)) ] 
> >> >   [ (binding:file? b) (values 
> >> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >> >(binding:file-content b)) ]))) 
> >> > 
> >> > It appears that the entire file contents are in the binding by the 
> time the 
> >> > request is available to me. This is fine for "small enough" files, 
> but for 
> >> > larger files, it would be great to be able to stream the file 
> contents. The 
> >> > solution may be to use something like nginx's upload module: 
> >> > 
> >> > https://www.nginx.com/resources/wiki/modules/upload/ 
> >> > 
> >> > But before I go down that route, I thought I'd ask if the Racket web 
> server 
> >> > provides a more direct way to accomplish this. 
> >> > 
> >> > Thanks, 
> >> > Brian 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/6a3298ff-a40c-4a6e-9f16-b1c95144e482%40googlegroups.com.
>  
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/278f757e-1965-4298-a3e1-6483f06e7d14%40googlegroups.com.


Re: [racket-users] How to stream file uploads with the Racket web server?

2020-02-14 Thread Brian Adkins
Will Racket's pleasant surprises never end? :) This is great news! 

I've had a blast coding web applications in Racket over the last 15 months. 
I now understand "The Lisp Curse" a bit more :)

http://winestockwebdesign.com/Essays/Lisp_Curse.html

In other words, developing web apps with what is already provided by 
Racket, and a few packages, has been easy & enjoyable enough that it's 
delayed my work on a web framework. That's probably been for the best 
because now I have a few real world examples from which I can begin to 
extract the code that belongs in a general framework. I'll be resuming that 
work this month.

I watched the "how to create a blog in 15 minutes w/ Rails" video 14 years 
ago, and it had a huge impact on my work. There are still some very nice 
things to steal from Rails, and a whole lot of things to leave :) If you're 
interested in web development, and you haven't seen this video, I highly 
recommend it. There are some annoyances for sure, but be patient.

https://www.youtube.com/watch?v=Gzj723LkRJY=youtu.be


On Thursday, February 13, 2020 at 11:02:33 AM UTC-5, bogdan wrote:
>
> The version of the web-server that will be included with Racket 7.6 
> changes the way file uploads are handled so that they get offloaded to 
> disk after a certain threshold (similar to how that nginx module you 
> linked to works). 
>
> You can check out the pre-release docs for details: 
>
> * 
> https://pre-release.racket-lang.org/doc/web-server/http.html?q=binding%3Afile#%28def._%28%28lib._web-server%2Fhttp%2Frequest-structs..rkt%29._make-binding~3afile%2Fport%29%29
>  
> * 
> https://pre-release.racket-lang.org/doc/web-server-internal/dispatch-server-unit.html#%28part._safety-limits%29
>  
>
> To get these changes ahead of the release, you should be able to install 
> an updated version of `web-server-lib' from the package server or from 
> git. 
>
> Hope that helps! 
>
> - Bogdan 
>
> Brian Adkins writes: 
>
> > I'm posting a file to my web app using the following form: 
> > 
> >  >   method="post" *enctype="multipart/form-data"* 
> > class="file-upload-form"> 
> > ... 
> >  
> > 
> > I use a simple function to create a hashtable of attributes: 
> > 
> > (define (form-values req) 
> >   (for/hash ([ b (in-list (request-bindings/raw req)) ]) 
> > (cond [ (binding:form? b) (values 
> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >(bytes->string/utf-8 (binding:form-value 
> b) 
> > #\space)) ] 
> >   [ (binding:file? b) (values 
> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >(binding:file-content b)) ]))) 
> > 
> > It appears that the entire file contents are in the binding by the time 
> the 
> > request is available to me. This is fine for "small enough" files, but 
> for 
> > larger files, it would be great to be able to stream the file contents. 
> The 
> > solution may be to use something like nginx's upload module: 
> > 
> > https://www.nginx.com/resources/wiki/modules/upload/ 
> > 
> > But before I go down that route, I thought I'd ask if the Racket web 
> server 
> > provides a more direct way to accomplish this. 
> > 
> > Thanks, 
> > Brian 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d9c81358-1e32-438e-88cb-433bdd71ebd2%40googlegroups.com.


Re: [racket-users] How to stream file uploads with the Racket web server?

2020-02-13 Thread Brian Adkins
I tried replying earlier today, but somehow the post got deleted - could've 
been user error I suppose.

Anyway, the gist of the response was how I continue to be amazed by how 
often I get pleasant surprises with Racket - either there is some facility 
to do what I want that I just haven't found yet, or in this case where 
there soon will be :)

I have a couple Racket web apps in production now, so I think I have enough 
real world examples to begin extracting code into a web framework. Although 
it will look significantly different than Rails (more functional, less 
object oriented), I'm hoping to achieve similar ease-of-use functionality. 
I first viewed the Rails "weblog in 15 minutes" video fourteen years ago, 
and it had a significant impact on my professional life (at the time I was 
working in Java w/ Spring & Hibernate, etc.). The video is dated now & has 
some annoying idiosyncrasies, but if you haven't seen it, and you're 
interested in web development (in any language), it's worth viewing just to 
get the overview of Rails ease of use:

https://www.youtube.com/watch?v=Gzj723LkRJY=youtu.be 

On Thursday, February 13, 2020 at 11:02:33 AM UTC-5, bogdan wrote:
>
> The version of the web-server that will be included with Racket 7.6 
> changes the way file uploads are handled so that they get offloaded to 
> disk after a certain threshold (similar to how that nginx module you 
> linked to works). 
>
> You can check out the pre-release docs for details: 
>
> * 
> https://pre-release.racket-lang.org/doc/web-server/http.html?q=binding%3Afile#%28def._%28%28lib._web-server%2Fhttp%2Frequest-structs..rkt%29._make-binding~3afile%2Fport%29%29
>  
> * 
> https://pre-release.racket-lang.org/doc/web-server-internal/dispatch-server-unit.html#%28part._safety-limits%29
>  
>
> To get these changes ahead of the release, you should be able to install 
> an updated version of `web-server-lib' from the package server or from 
> git. 
>
> Hope that helps! 
>
> - Bogdan 
>
> Brian Adkins writes: 
>
> > I'm posting a file to my web app using the following form: 
> > 
> >  >   method="post" *enctype="multipart/form-data"* 
> > class="file-upload-form"> 
> > ... 
> >  
> > 
> > I use a simple function to create a hashtable of attributes: 
> > 
> > (define (form-values req) 
> >   (for/hash ([ b (in-list (request-bindings/raw req)) ]) 
> > (cond [ (binding:form? b) (values 
> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >(bytes->string/utf-8 (binding:form-value 
> b) 
> > #\space)) ] 
> >   [ (binding:file? b) (values 
> >(bytes->string/utf-8 (binding-id b) 
> #\space) 
> >(binding:file-content b)) ]))) 
> > 
> > It appears that the entire file contents are in the binding by the time 
> the 
> > request is available to me. This is fine for "small enough" files, but 
> for 
> > larger files, it would be great to be able to stream the file contents. 
> The 
> > solution may be to use something like nginx's upload module: 
> > 
> > https://www.nginx.com/resources/wiki/modules/upload/ 
> > 
> > But before I go down that route, I thought I'd ask if the Racket web 
> server 
> > provides a more direct way to accomplish this. 
> > 
> > Thanks, 
> > Brian 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6a3298ff-a40c-4a6e-9f16-b1c95144e482%40googlegroups.com.


[racket-users] How to stream file uploads with the Racket web server?

2020-02-13 Thread Brian Adkins
I'm posting a file to my web app using the following form:


...


I use a simple function to create a hashtable of attributes:

(define (form-values req)
  (for/hash ([ b (in-list (request-bindings/raw req)) ])
(cond [ (binding:form? b) (values
   (bytes->string/utf-8 (binding-id b) #\space)
   (bytes->string/utf-8 (binding:form-value b) 
#\space)) ]
  [ (binding:file? b) (values
   (bytes->string/utf-8 (binding-id b) #\space)
   (binding:file-content b)) ])))

It appears that the entire file contents are in the binding by the time the 
request is available to me. This is fine for "small enough" files, but for 
larger files, it would be great to be able to stream the file contents. The 
solution may be to use something like nginx's upload module:

https://www.nginx.com/resources/wiki/modules/upload/

But before I go down that route, I thought I'd ask if the Racket web server 
provides a more direct way to accomplish this.

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/97fe4333-5778-4c47-94e0-1e5713e54b22%40googlegroups.com.


[racket-users] Persistent job queue

2019-08-26 Thread Brian Adkins
I haven't been able to find a persistent job queue for Racket, so I thought 
I'd ask if one exists before writing a simple one. I did see Jay's job 
queue package, but it doesn't appear to persist to disk, and that is a 
requirement.

I typically use Postgres for my apps, and I would prefer to also use 
Postgres for the persistence of the job queue to avoid introducing 
something new (e.g. Redis) to my server setup. Amazon RDS provides great 
multi-site availability, so I want to continue to leverage that.

Thanks,
Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8a87e815-0519-47bf-b04b-93c9be3487f5%40googlegroups.com.


[racket-users] Re: The future of current language Racket

2019-08-26 Thread Brian Adkins
On Monday, August 26, 2019 at 4:45:44 AM UTC-4, Arie van Wingerden wrote:
>
> When Racket2 was announced, I got really upset, being afraid that all what 
> I like about (the old) Racket would be at stake. Also it was mentioned that 
> the docs would be based on Racket2 syntax, which probably would hamper 
> using them for old school Racket. 
>
> I really think that old school Racket should be saved for the future, 
> because it is the Scheme to go for many reasons e.g. superb IDE + debugging 
> and many good packages and of course the whole creative eco system. 
>
> Question 1: 
> Please can you explicitly guarantee that Racket (#lang racket) will be 
> available for the future? 
>
> Question 2: 
> Can you explicitely guarantee that the documentation for #lang racket will 
> be available in the future? 
>
> Please know that I love DrRacket as a whole and that I am not against 
> Racket2 at all. I just like my favorite old Racket language to be available 
> forever 
>
> Many thx for DrRacket and keep up the good work! 
>
> Best wishes.


The Racket project leadership will be offering clarification once they're 
able to meet together, see the following:

https://groups.google.com/d/msg/racket-users/9Eh9H1Jt28Q/2Wx7xopIDAAJ

I can empathize with your concern, but I am no longer concerned about the 
future of #lang racket. There are simply too many great things about it for 
it not to continue, and in a very unlikely worst case scenario, in my 
opinion, it would be easier to fork the software and continue to 
maintain/enhance it then it would be to bring another Scheme, such as Chez, 
up to the same productivity level. And to be clear, I do *not* at all 
expect the worst case scenario :)

Since my post (referenced above), I have decided to not wait for the Racket 
project leadership, and have gone "all in" with #lang racket, and I plan on 
continuing with that attitude for the foreseeable future. I expect to be 
able to add some new packages to the great set we already have before the 
new syntax is completed :)

Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ac9c845d-ea8d-47a2-94d5-1a3a21687f80%40googlegroups.com.


Re: [racket-users] Splicing the result of one macro into another

2019-08-20 Thread Brian Adkins
On Tuesday, August 20, 2019 at 9:11:54 PM UTC-4, Brian Adkins wrote:
>
> On Tuesday, August 20, 2019 at 8:43:07 PM UTC-4, Sorawee Porncharoenwase 
> wrote:
>>
>>
>>1. You will need a cooperation of phone-numbers macro. There are two 
>>ways I am aware of
>>1.1 You could hard code in phone-numbers to deal with add-prefix 
>>directly.
>>1.2 A more general approach is to use local-expand in phone-numbers 
>>to partially expand macros in the body of phone-numbers. In this 
>>case, this is to partially expand add-prefix to something that 
>>phone-numbers can recognize and deal with. 
>>2. The macro add-prefix is weird. It doesn’t expand to the 
>>compile-time macro number. Instead, it expands to a runtime function 
>>application (to construct a list of lists) and perform the 
>>string-append at runtime. This means it would be really hard for 
>>phone-numbers to process the partially expanded syntax if you were to 
>>use approach 1.2. Are you sure that this behavior of add-prefix is 
>>what you want? 
>>
>> Here’s my attempt to solve this problem, while trying to maintain the 
>> external behavior you described.
>>
>> #lang racket
>>
>> (require (for-syntax syntax/parse))
>>
>> ;; number macro is needed so that "bare" add-prefix works correctly
>>
>> (define-syntax (number stx)
>>   (syntax-parse stx
>> [(_ x:string) #'(list 'number x)]))
>>
>> (number "123") ; ==> '(number "123")
>>
>> ;; - if the immediate macro is `number`, don't partially expand it, because
>> ;;   `phone-numbers` know how to deal with it already. Note that
>> ;;   the result attribute should be of ellipsis depth 1, so we need to do
>> ;;   some normalization here.
>> ;;
>> ;; - otherwise, partially expand the immediate macro. The protocol is that 
>> ;;   the immediate macro should expand to (list (number xxx) ...).
>> ;;   We then extract the result from it.
>>
>> (begin-for-syntax
>>   (define-syntax-class do-expand
>> #:attributes ([result 1])
>> (pattern ({~literal number} _)
>>  #:with (result ...) (list this-syntax))
>> (pattern _
>>  #:with ({~literal list} result ...)
>> (local-expand this-syntax 'expression #f
>>
>> (define-syntax (phone-numbers stx)
>>   (syntax-parse stx
>> [(_ :do-expand ...)
>>  (syntax-parse #'((~@ result ...) ...)
>>[(((~literal number) phone) ...)
>> #'(list phone ...)])]))
>>
>> (phone-numbers
>>  (number "1212")
>>  (number "2121")) ; ==> '("1212" "2121")
>>
>> ;; add-prefix computes at compile-time. It abides the protocol described 
>> above.
>>
>> (define-syntax (add-prefix stx)
>>   (syntax-parse stx
>> [(_ prefix ((~literal number) str) ...)
>>  #:with (prefixed ...) (map (λ (s)
>>   (datum->syntax
>>this-syntax
>>(string-append (syntax-e #'prefix)
>>   (syntax-e s
>> (attribute str))
>>  #'(list (number prefixed) ...)]))
>>
>> (add-prefix "555"
>> (number "1212")
>> (number "2121")) ; ==> '((number "5551212") (number "5552121"))
>>
>> ;; add-suffix computes at compile-time. It abides the protocol described 
>> above.
>>
>> (define-syntax (add-suffix stx)
>>   (syntax-parse stx
>> [(_ prefix ((~literal number) str) ...)
>>  #:with (suffixed ...) (map (λ (s)
>>   (datum->syntax
>>this-syntax
>>(string-append (syntax-e s)
>>   (syntax-e #'prefix
>> (attribute str))
>>  #'(list (number suffixed) ...)]))
>>
>> (add-suffix "555"
>> (number "1212")
>> (number "2121")) ; ==> '((number "1212555") (number "2121555"))
>>
>> ;;;
>>
>> (phone-numbers
>>  (add-prefix "555"
>>  (number "1212")
>>  (number

Re: [racket-users] Splicing the result of one macro into another

2019-08-20 Thread Brian Adkins
On Tuesday, August 20, 2019 at 8:43:07 PM UTC-4, Sorawee Porncharoenwase 
wrote:
>
>
>1. You will need a cooperation of phone-numbers macro. There are two 
>ways I am aware of
>1.1 You could hard code in phone-numbers to deal with add-prefix 
>directly.
>1.2 A more general approach is to use local-expand in phone-numbers to 
>partially expand macros in the body of phone-numbers. In this case, 
>this is to partially expand add-prefix to something that phone-numbers 
>can recognize and deal with. 
>2. The macro add-prefix is weird. It doesn’t expand to the 
>compile-time macro number. Instead, it expands to a runtime function 
>application (to construct a list of lists) and perform the 
>string-append at runtime. This means it would be really hard for 
>phone-numbers to process the partially expanded syntax if you were to 
>use approach 1.2. Are you sure that this behavior of add-prefix is 
>what you want? 
>
> Here’s my attempt to solve this problem, while trying to maintain the 
> external behavior you described.
>
> #lang racket
>
> (require (for-syntax syntax/parse))
>
> ;; number macro is needed so that "bare" add-prefix works correctly
>
> (define-syntax (number stx)
>   (syntax-parse stx
> [(_ x:string) #'(list 'number x)]))
>
> (number "123") ; ==> '(number "123")
>
> ;; - if the immediate macro is `number`, don't partially expand it, because
> ;;   `phone-numbers` know how to deal with it already. Note that
> ;;   the result attribute should be of ellipsis depth 1, so we need to do
> ;;   some normalization here.
> ;;
> ;; - otherwise, partially expand the immediate macro. The protocol is that 
> ;;   the immediate macro should expand to (list (number xxx) ...).
> ;;   We then extract the result from it.
>
> (begin-for-syntax
>   (define-syntax-class do-expand
> #:attributes ([result 1])
> (pattern ({~literal number} _)
>  #:with (result ...) (list this-syntax))
> (pattern _
>  #:with ({~literal list} result ...)
> (local-expand this-syntax 'expression #f
>
> (define-syntax (phone-numbers stx)
>   (syntax-parse stx
> [(_ :do-expand ...)
>  (syntax-parse #'((~@ result ...) ...)
>[(((~literal number) phone) ...)
> #'(list phone ...)])]))
>
> (phone-numbers
>  (number "1212")
>  (number "2121")) ; ==> '("1212" "2121")
>
> ;; add-prefix computes at compile-time. It abides the protocol described 
> above.
>
> (define-syntax (add-prefix stx)
>   (syntax-parse stx
> [(_ prefix ((~literal number) str) ...)
>  #:with (prefixed ...) (map (λ (s)
>   (datum->syntax
>this-syntax
>(string-append (syntax-e #'prefix)
>   (syntax-e s
> (attribute str))
>  #'(list (number prefixed) ...)]))
>
> (add-prefix "555"
> (number "1212")
> (number "2121")) ; ==> '((number "5551212") (number "5552121"))
>
> ;; add-suffix computes at compile-time. It abides the protocol described 
> above.
>
> (define-syntax (add-suffix stx)
>   (syntax-parse stx
> [(_ prefix ((~literal number) str) ...)
>  #:with (suffixed ...) (map (λ (s)
>   (datum->syntax
>this-syntax
>(string-append (syntax-e s)
>   (syntax-e #'prefix
> (attribute str))
>  #'(list (number suffixed) ...)]))
>
> (add-suffix "555"
> (number "1212")
> (number "2121")) ; ==> '((number "1212555") (number "2121555"))
>
> ;;;
>
> (phone-numbers
>  (add-prefix "555"
>  (number "1212")
>  (number "2121"))
>  (number "1234"))
>
> ;; similar to typing
>
> (phone-numbers
>  (list (number "5551212") (number "5552121"))
>  (number "1234"))
>
> ;; ==> '("5551212" "5552121" "1234")
>
>
Thanks. 

The reason the add-prefix macro is weird is because I have no idea what I'm 
doing with respect to macros, so I'm currently grasping at straws and 
experimenting :) I appreciate all of the Racket documentation, but I think 
there is a need for a much better presentation of the material in a 
graduated way. Racket School was great, but we jumped into the deep end 
pretty quickly, and the techniques seem "hacky" with odd idiosyncrasies and 
clever tricks vs. proceeding from a solid foundation and building upon that.

I'm kind of wondering if it wouldn't be easier to just process the syntax 
object directly - at least then, I'd be in a realm I'm very familiar with.

I'll review the code you've provided.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe 

[racket-users] Splicing the result of one macro into another

2019-08-20 Thread Brian Adkins
Consider the following two macros:

(require (for-syntax syntax/parse))

(define-syntax (phone-numbers stx)
  (syntax-parse stx
[(_ ((~literal number) phone) ...)
 #'(list phone ...)]))

(define x (phone-numbers
   (number "1212")
   (number "2121"))) ; ==> '("1212" "2121")

(define-syntax (add-prefix stx)
  (syntax-parse stx
[(_ prefix ((~literal number) str) ...)
 #'(list (list 'number (string-append prefix str)) ...)]))

(define y (add-prefix "555"
  (number "1212")
  (number "2121"))) ; ==> '((number "5551212") (number 
"5552121"))

I would like to be able to do the following:

(phone-numbers
 (add-prefix "555"
 (number "1212")
 (number "2121"))
 (number "1234")) ; ==> '("5551212" "5552121" "1234")

I was hoping it would be possible to do this without modifying the 
phone-numbers macro. In other words, to have the result of expanding 
add-prefix macro call be:

(number "5551212") (number "5552121")

So that it would appear to the phone-numbers macro as if the user had 
actually typed:

(phone-numbers
  (number "5551212")
  (number "5552121")
  (number "1234"))

Is it possible to do this w/o the explicit cooperation of the phone-numbers 
macro?

Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e6e5a407-7547-44f1-b8c2-bbe7906ed6f5%40googlegroups.com.


Re: [racket-users] Re: Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Brian Adkins
On Monday, August 19, 2019 at 5:48:29 PM UTC-4, Sorawee Porncharoenwase 
wrote:
>
> You could use (splicing) syntax class to help with normalization:
>
> #lang racket
>
> (require syntax/parse/define
>  (for-syntax syntax/parse
>  racket/syntax))
>
> (begin-for-syntax
>   (define-splicing-syntax-class methods-cls
> #:attributes (methods)
> (pattern (~seq #:methods (method:expr ...))
>  #:with methods #'(list 'method ...))
> (pattern (~seq #:method method:expr)
>  #:with methods #'(list 'method)))
>
>   (define-syntax-class route-cls
> (pattern (route:string
>   handler:id
>   (~alt (~optional ms:methods-cls
>#:name "#:method, or #:methods option")
> (~optional (~seq #:when guard-e:expr)
>#:name "#:when option")) ...)
>  #:with methods #`#,(or (attribute ms.methods) #'(list))
>  #:with guard #`#,(attribute guard-e
>
> (define-simple-macro (routes :route-cls ...)
>   #:with name (format-id this-syntax "axio-routes")
>   (define name (list (list route handler methods guard) ...)))
>
> (define (foo-handler) 0)
> (define (bar-handler) 0)
> (define (baz-handler) 0)
> (define (use-bar-handler?) 0)
>
> (routes
>  ("/foo" foo-handler #:method put)
>  ("/bar" bar-handler #:methods (put update) #:when use-bar-handler?)
>  ("/baz" baz-handler))
>
> axio-routes
>
>
Thanks your idea cleans it up nicely!  I've broken up the code into 4 file 
and placed them in a gist:

https://gist.github.com/lojic/842619ab2c59a2c96960f9ccd30bc136

I'm not thrilled with the fact that the routes macro has to export the 
axio-routes binding. I expect there is a better way to communicate between 
the routes macro and find-route function.

I'll add interpolation to the URL paths next e.g.  (route "/user/~id" ...) 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f7238c4b-6d4c-431c-a305-c4d2d7bdbfb5%40googlegroups.com.


[racket-users] Re: Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Brian Adkins
(define-syntax (routes stx)
  (syntax-parse stx
[ (routes (element ...) ...)
  (with-syntax ([ name  (format-id stx "axio-routes") ])
#'(define name (list (route-element element ...) ...)))]))

(define-syntax (route-element stx)
  (syntax-parse stx
[ (route-element route:string
 handler:id
 (~alt (~optional (~or* (~seq #:methods (methods:expr 
...))
(~seq #:method method:expr))
  #:name "#:method, or #:methods 
option")
   (~optional (~seq #:when guard:expr)
  #:name "#:when option"))
 ...)
  (with-syntax ([ method-list (let ([ m  (attribute method)  ]
[ ms (attribute methods) ])
(cond [ m(list m) ]
  [ ms   ms   ]
  [ else '()  ]))]
[ guard-func (let ([ fun (attribute guard) ])
   (if fun
   fun
   #f)) ])
#'(list route handler 'method-list guard-func))]))

(routes
 ("/foo" foo-handler #:method put)
 ("/bar" bar-handler #:methods (put update) #:when use-bar-handler?)
 ("/baz" baz-handler))

axio-routes

==>  '(("/foo" # (put) #f) ("/bar" 
# (put update) #) 
("/baz" # () #f))

I know it ain't pretty yet, but it works now, so I can enhance it later. I 
should probably use a struct for each route vs. a list.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ffc7ec25-f663-4d1d-a3d6-d3097d9c3963%40googlegroups.com.


[racket-users] Re: Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Brian Adkins
On Monday, August 19, 2019 at 3:35:00 PM UTC-4, Brian Adkins wrote:
>
> I'm working on a macro to allow the following:
>
> (routes
>  ("/foo" foo-handler #:method put)
>  ("/bar" bar-handler #:methods (put update))
>  ("/baz" baz-handler))
>
> The idea is that you could restrict a route based on the HTTP method 
> either for one method using #:method or for a list of methods using 
> #:methods. I tried using some ideas from the following examples:
>
> https://docs.racket-lang.org/syntax/Optional_Keyword_Arguments.html
>
> https://docs.racket-lang.org/syntax/More_Keyword_Arguments.html
>
> The attempt below does not work, and from my debugging I think it's 
> probably the wrong approach. If there are examples of this sort of thing, 
> I'd love to see them.
>
> Thanks,
> Brian Adkins
>
> (define-syntax (routes stx)
>   (syntax-parse stx
> [ (routes (route:string
>handler:id
>(~alt (~optional (~or* (~seq #:methods (methods:expr ...))
>   (~seq #:method method:expr))
> #:name "#:method, or #:methods option")
>  (~optional (~seq #:when guard:expr)
> #:name "#:when option"))
>...)
>   ...)
>   (with-syntax ([ name  (format-id stx "axio-routes") ])
> #'(define name (list (list route handler 'method (list 'methods 
> ...)) ...)))]))
>
>
The following got me over the main hurdle:

(define-syntax (routes stx)
  (syntax-parse stx
[ (routes (element ...) ...)
  (with-syntax ([ name  (format-id stx "axio-routes") ])
#'(define name (list (route-element element ...) ...)))]))

(define-syntax (route-element stx)
  (syntax-parse stx
[ (route-element route:string
 handler:id
 (~alt (~optional (~or* (~seq #:methods (methods:expr 
...))
(~seq #:method method:expr))
  #:name "#:method, or #:methods 
option")
   (~optional (~seq #:when guard:expr)
  #:name "#:when option"))
 ...)
  (with-syntax ([ m  (or (attribute method)  #'#f) ]
[ ms (or (attribute methods) #'#f) ])
#'(list route handler 'm 'ms))]))

(routes
 ("/foo" foo-handler #:method put)
 ("/bar" bar-handler #:methods (put update))
 ("/baz" baz-handler))

axio-routes

==> '(("/foo" # put #f) ("/bar" 
# #f (put update)) ("/baz" # 
#f #f))

Now I just need to normalize to a list of HTTP methods vs. having separate 
fields. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0e3bd33f-9666-4f3f-800e-1ccd7f6a2dee%40googlegroups.com.


[racket-users] Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Brian Adkins
I'm working on a macro to allow the following:

(routes
 ("/foo" foo-handler #:method put)
 ("/bar" bar-handler #:methods (put update))
 ("/baz" baz-handler))

The idea is that you could restrict a route based on the HTTP method either 
for one method using #:method or for a list of methods using #:methods. I 
tried using some ideas from the following examples:

https://docs.racket-lang.org/syntax/Optional_Keyword_Arguments.html

https://docs.racket-lang.org/syntax/More_Keyword_Arguments.html

The attempt below does not work, and from my debugging I think it's 
probably the wrong approach. If there are examples of this sort of thing, 
I'd love to see them.

Thanks,
Brian Adkins

(define-syntax (routes stx)
  (syntax-parse stx
[ (routes (route:string
   handler:id
   (~alt (~optional (~or* (~seq #:methods (methods:expr ...))
  (~seq #:method method:expr))
#:name "#:method, or #:methods option")
 (~optional (~seq #:when guard:expr)
#:name "#:when option"))
   ...)
  ...)
  (with-syntax ([ name  (format-id stx "axio-routes") ])
#'(define name (list (list route handler 'method (list 'methods 
...)) ...)))]))

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8d801f42-fc63-47fb-ab0a-80a1fc905d4d%40googlegroups.com.


Re: [racket-users] Re: Improved synchronous concurrency example for rosettacode.org ?

2019-08-17 Thread Brian Adkins
On Saturday, August 17, 2019 at 6:56:29 AM UTC-4, Stephen De Gabrielle 
wrote:
>
> Thanks Brian 
> This is great!
>
> Stephen
>
>
My pleasure. By the way, here are unimplemented tasks for Racket if people 
want to contribute solutions:

http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_Racket 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/11e3bf55-c02e-4110-a37e-a9933b1524d6%40googlegroups.com.


[racket-users] Re: Improved synchronous concurrency example for rosettacode.org ?

2019-08-16 Thread Brian Adkins
On Friday, August 16, 2019 at 6:46:14 PM UTC-4, Brian Adkins wrote:
>
> I went ahead and added my version to the Racket section w/ some subtle 
> changes from my original post. I'm happy to edit it if necessary.
>
> https://rosettacode.org/wiki/Synchronous_concurrency#Racket
>
> I added a note above my entry re: using thread mailboxes, and I added a 
> note above the existing entry re: using channels.
>
> Brian Adkins
>
>>
>>
Thanks to Matthew Butterick, the printer function is much nicer now :)

https://rosettacode.org/wiki/Synchronous_concurrency#Racket 

This latest version compares very favorably with a lot of other languages 
now. Racket continues to pleasantly surprise me - just keep those beautiful 
parens coming :)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/808f7243-7bbc-4f18-9e8b-e88b90e1dda2%40googlegroups.com.


[racket-users] Re: Improved synchronous concurrency example for rosettacode.org ?

2019-08-16 Thread Brian Adkins
I went ahead and added my version to the Racket section w/ some subtle 
changes from my original post. I'm happy to edit it if necessary.

https://rosettacode.org/wiki/Synchronous_concurrency#Racket

I added a note above my entry re: using thread mailboxes, and I added a 
note above the existing entry re: using channels.

Brian Adkins

>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1733f179-bd48-46ae-87d1-8263cfd8c177%40googlegroups.com.


[racket-users] Improved synchronous concurrency example for rosettacode.org ?

2019-08-16 Thread Brian Adkins
The current Racket example for Synchronous Concurrency seems a little 
verbose and overly complicated:

https://rosettacode.org/wiki/Synchronous_concurrency#Racket

What do you think of the following example instead?

Brian Adkins

--- snip ---
(define (reader)
  (for ([line (in-lines (open-input-file "input.txt"))])
   (thread-send printer-thread line))
  (thread-send printer-thread eof)
  (printf "Number of lines: ~a\n" (thread-receive)))

(define (printer)
  (let loop ([line (thread-receive)][count 0])
(if (eof-object? line)
(thread-send reader-thread count)
(begin
  (printf "~a\n" line)
  (loop (thread-receive)
(add1 count))

(define printer-thread (thread printer))
(define reader-thread  (thread reader))
(thread-wait printer-thread)
--- snip ---

or the following (using a macro probably just muddies the waters, but I 
didn't like the (thread (thunk ... nesting ) :)

--- snip ---
(require syntax/parse/define)

(define-simple-macro (thread-start thread-name:id rhs:expr ...)
  (define thread-name (thread (thunk rhs ...

(thread-start printer-thread
   (let loop ([line (thread-receive)][count 0])
 (if (eof-object? line)
 (thread-send reader-thread count)
 (begin
   (printf "~a\n" line)
   (loop (thread-receive)
 (add1 count))

(thread-start reader-thread
   (for ([line (in-lines (open-input-file "input.txt"))])
(thread-send printer-thread line))
   (thread-send printer-thread eof)
   (printf "Number of lines: ~a\n" (thread-receive)))

(thread-wait printer-thread)
--- snip ---

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/cb2751e8-f0cb-492d-bffb-d2b0f994210a%40googlegroups.com.


Re: [racket-users] Clarify project policy on racket2 syntax

2019-08-14 Thread Brian Adkins
On Wednesday, August 14, 2019 at 10:39:52 AM UTC-4, Matthew Flatt wrote:
>
> The Racket project leadership [see signature at end] hasn't had a 
> chance to meet and discuss since RacketCon. When it does meet, we 
> should be able to offer a plan for both the future development of 
> Racket and the process of involving everyone in that development. 
>
> [...]
>
> - Jay, Matthew, Matthias, Robby, and Sam 
>

Thank you for that preliminary statement; I look forward to hearing the 
plan after the project leadership has had a chance to meet.

I want to offer just one suggestion for consideration when you meet. I've 
talked to a number of people from various language backgrounds and 
practices to (hopefully) balance my own biases on this matter, and I think 
it's possible that the syntax experiment may be unique with respect to the 
types of changes one might expect in a language community. My suggestion is 
that if the syntax experiment is successful, and the new syntax is chosen 
as the default language for the Racket community, the existing s-expression 
syntax of #lang racket may need to be treated in such a way as to avoid all 
appearances of deprecation. This might include, for example:

* Not using adjectives such as "deprecated", "legacy", "unstable", etc.

* Not putting the link to #lang racket documentation at the very bottom of 
this page: https://docs.racket-lang.org/ where R5RS, Scheme, MZScheme are 
located.

* Not using phrases such as: "Do not use #lang racket to start new 
projects; #lang racket2 is the preferred language" which can be seen here: 
https://docs.racket-lang.org/scheme/index.html

I understand that, if the new syntax is successful, you will want to 
promote it as the default/main language, and that you'll want to spend most 
of your resources on the new language; however, I don't think it's a 
foregone conclusion that #lang racket would then need to go the way of the 
other legacy languages which, while they may not have "gone away", and 
there may be programs that "still run", are certainly not viewed as 
attractive languages with which to use for an ambitious new project.


However, if after meeting together, the project leadership does not feel 
this way, then please be direct in your communication so those of us who 
have invested much in a #lang racket codebase can make an informed decision 
about how to proceed.

Thanks,
Brian Adkins

 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/48a41a0a-d30a-4bae-8f67-7a2213584f62%40googlegroups.com.


Re: [racket-users] Clarify project policy on racket2 syntax

2019-08-12 Thread Brian Adkins
On Monday, August 12, 2019 at 10:50:03 AM UTC-4, Neil Van Dyke wrote:
>
> Robby, I'm still not certain we all have a shared understanding of some 
> of the concerns and where we all stand, so please let me try to get at 
> that some of that: 
>
> > As for adopting-new-syntax vs backwards-compatibility, does it help if I 
> were to tell you that anything new will always be "opt in", in the sense 
> that existing programs will continue to work completely unchanged with no 
> special annotations or anything else like that required? 
>
> I suspect, to many industry software engineers, this phrasing sounds 
> like "deprecated", which is something we understand.  It's not something 
> anyone likes to hear, unless we've already moved away from it, and we 
> think that deprecating that is a positive sign. 
>
> > There are piles of lecture notes (in the form of slide presentations 
> written in Racket) from the late 90s (so not in any continuous integration 
> system anywhere, as far as I know) that still run fine in today's Racket 
> for example. 
>
> I think this argument doesn't address the concerns of software engineers 
> who know the history of Racket (and of countless possible parallels 
> elsewhere). 
>
> For one example, from Racket specifically, how the change to pair 
> mutability was done meant that some of those modules in "compatibility" 
> dialects no longer interoperate well with modern modules.  That's a big 
> one. 
>
> For a lesser example, which nevertheless was a problem in real-world 
> practice: one of the changes to C extensions meant being locked to the 
> old, non-default GC (missing out on enhancements, and concern it was 
> more likely to break in the future, since most people had been pushed 
> along to using the new thing, until that scary C extension code could be 
> disturbed again). 
>
> Another example was people who were using PLaneT's 
> multiple-installed-package versions and SemVer-like updating, when that 
> was deprecated and the functionality lost. 
>
>  From an engineering perspective, over the last couple decades, Racket 
> has done a good job, overall.  And an outstanding job, as academic-led 
> projects go.  But, at this point, I think software engineers should want 
> a clear understanding of top-level requirements for Racket, so they have 
> an idea of what to expect. 
>
> Some degree of trust factors into assessments of whether adopting or 
> staying with such-and-such tech makes sense, and I'd think that arguing 
> "some old CS101 lecture slides probably still work" is going to increase 
> concern rather than reduce it. :) 
>
> Some people (here, and in other venues) are skittish or turned off by 
> various recent commotion.  At this point I could allay some of their 
> concerns by mentioning multiple mitigation/transition options to them, 
> but I'd prefer to keep all the value of the community we've built around 
> Racket. 
>
> Moving forward... Software engineers have learned to expect modern 
> platform pitchers to often be disingenuous, or at least 
> over-enthusiastic.  If core states, utterly unambiguously, and speaking 
> as one, the top-level requirements that will guide Racket, and 
> everything else clearly follows from those requirements, then I think 
> that will increase confidence.  (Even if some of the articulated 
> priorities are not ideal for our needs, we know what to plan with, with 
> some confidence.) 
>

Thank you Neil for articulating concerns that I feel are common to a larger 
number of people than it may seem. As the old saying goes, "the difference 
between practice and theory is much greater in practice than in theory".

I'm hopeful that we will receive clarification soon. If not, despite all 
the wonderful things that Racket provides over other Scheme implementations 
currently, it will become increasingly difficult for me to continue 
investing in a Racket codebase if I need to wait N years for a concrete 
implementation of Racket2 before really knowing the subtle consequences.

The fact that I'm currently a full-time Racket developer should indicate 
that I don't need the same stability/predictability that's provided by 
mainstream languages, but I do need _enough_ stability/predictability :)

It might be an attractive option for the core team to have the community 
wait for N years while Racket2 is built before coming to any conclusions, 
but I really don't think that's a viable option.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e870eb77-83fb-4328-ac4c-083a8244e620%40googlegroups.com.


Re: [racket-users] Here are many examples for learning Racket for new folks

2019-08-05 Thread Brian Adkins
On Sunday, August 4, 2019 at 7:35:00 PM UTC-4, Stephen De Gabrielle wrote:
>
> Awesome!
>
> You should post this on https://www.reddit.com/r/Racket/ the facebook 
> page, twitter, etc.
>
> s.
>

I don't have a reddit account; if someone else wants to post it, that's 
fine w/ me. Does anyone have a good idea of how participation is 
distributed across this mailing list, reddit, slack, etc.? I'd prefer to 
focus my efforts on one channel of communication.

Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0cb738a3-bbe8-4214-be97-5f22da3a46b2%40googlegroups.com.


[racket-users] Here are many examples for learning Racket for new folks

2019-08-04 Thread Brian Adkins
Here is a github repository of many examples of Racket code including:

* "Exercises for Programmers" by Brian P. Hogan
* exercism.io
* Project Euler
* Puzzles e.g. n-queens, parallel n-queens, Cracker Barrel pegboard, etc.
* etc.

https://github.com/lojic/LearningRacket

If you're new to Racket, and you like to learn from examples (like me), 
this may be of value to you. I'm working through SICP (sorry die-hard htdp 
fans :), so I may add a directory for those solutions also. 

I coded up most of these a few years or more ago, so I expect there are 
much better ways to implement them, and with a more idiomatic Racket style, 
but they should provide some nice exposure into various Rackety things. 

I'm happy to update them with better code, and now that I've been using 
rackunit daily, I may go back and add a bunch of tests which could be 
instructive.

Brian Adkins

P.S. I don't think I've posted this before, but if I have, excuse me

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2024a62b-3b90-44bc-afd2-dcd78bcc220e%40googlegroups.com.


[racket-users] Andy Keep's "Writing a Nanopass Compiler" talk

2019-07-26 Thread Brian Adkins
I found Andy Keep's 2013 talk about writing a nanopass compiler super 
interesting:

https://www.youtube.com/watch?v=Os7FE3J-U5Q

Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/58402fc2-db59-4d50-86a4-a91a1bc947d8%40googlegroups.com.


Re: [racket-users] Criteria for selecting Chez Scheme as the runtime for Racket

2019-07-25 Thread Brian Adkins
On Thursday, July 25, 2019 at 12:45:36 PM UTC-4, Matthew Flatt wrote:
>
> Reordered slightly: 
>
> At Thu, 25 Jul 2019 09:04:29 -0700 (PDT), Brian Adkins wrote: 
> > I know Chez had a reputation for being a fast implementation - was 
> > performance the main criteria? 
> > [...] 
> > Were there other factors, in addition to 
> > performance, that uniquely qualified Chez? 
>
> Good performance was an enabler. The way that Chez Scheme is put 
> together --- a minimal C kernel and otherwise written in Scheme --- was 
> important, and several Scheme implementations share that approach. A 
> native-code compiler and especially good support for delimited 
> continuations were important, and those requirements would rule out 
> some candidate Schemes. Finally, the core constructs of Chez Scheme are 
> the closest fit for Racket among Scheme implementations, because Racket 
> has historically taken cues from Chez Scheme. 
>
> > Were other Scheme implementations considered & rejected? If so, why? 
> > [...] 
> > If Chez was not open sourced, 
> > would another implementation have been considered instead, or would we 
> have 
> > stayed with the C runtime? 
>
> If Chez Scheme were not available at the time that we were ready to 
> consider big changes, we would have looked at other options. But most 
> likely we would have built the same Racket layers (threads, I/O, 
> regexp) as for Racket-on-Chez and used them to reduce the amount of C 
> in the old runtime system. We would also have modified or rewritten 
> parts of the runtime system to use different internal calling 
> conventions, a Chez-like implementation of continuations, and better 
> back-end compilation; that's what we got by using Chez Scheme. Also, it 
> would have taken us much longer to move those parts out of C. 
>

Awesome - thanks! 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ecdb7033-fb8b-4e68-922b-ee8989505617%40googlegroups.com.


[racket-users] Criteria for selecting Chez Scheme as the runtime for Racket

2019-07-25 Thread Brian Adkins
I'm curious about the process that resulted in selecting Chez Scheme as the 
runtime for Racket. 

I know Chez had a reputation for being a fast implementation - was 
performance the main criteria? Were other Scheme implementations considered 
& rejected? If so, why? Were there other factors, in addition to 
performance, that uniquely qualified Chez? If Chez was not open sourced, 
would another implementation have been considered instead, or would we have 
stayed with the C runtime?

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f5d1fbf2-c4ce-4423-b8de-f0b8003a92cb%40googlegroups.com.


Re: [racket-users] Message in the meantime?

2019-07-24 Thread Brian Adkins
On Wednesday, July 24, 2019 at 5:26:55 PM UTC-4, David Storrs wrote:
>
> There have been multiple threads going around about this change, so maybe 
> this has been answered and I've just missed it; if so, apologies.  Still, I 
> would love the answer to this:
>
>What value are we trying to capture by changing the syntax?
>
> So far, my understanding for the change is "Some people dislike 
> parentheses, therefore getting rid of them will help Racket gain more 
> users."
>
> Is this in fact the sole reason for the change?
>

See: https://groups.google.com/d/msg/racket-users/ewWuCvbe93k/n4i_OxdpCAAJ 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/790c1287-c75a-45ce-987e-0f1f3767f92b%40googlegroups.com.


[racket-users] Re: Message in the meantime?

2019-07-23 Thread Brian Adkins
On Tuesday, July 23, 2019 at 9:28:53 PM UTC-4, Alex Harsanyi wrote:
>
>
> On Wednesday, July 24, 2019 at 12:55:40 AM UTC+8, Greg Hendershott wrote:
>>
>> Although I'm still skeptical that changing the surface syntax will be a 
>> sufficiently big net gain, and ought to be the next, highest priority? 
>> I'm running with that idea for the following. 
>>
>
> I had a look at the proposals at 
> https://github.com/racket/racket2-rfcs/issues, and they seem reasonable 
> changes which, in my opinion, would improve the Racket language.  Most of 
> these changes, if they are implemented, would also allow a relatively easy 
> transition of existing Racket code.
>
> I can see only one proposal for changing the syntax and it is no more 
> radical than "#lang at-exp", which is already part of Racket, and seems to 
> be popular.
>
> On the other hand, anyone who is reading the posts on racket-users list, 
> would think that the Racket is a risky language to learn and use at this 
> time.  Perhaps it is time to stop the speculation and comment on the actual 
> proposals being made?
>
> Alex.
>

Alex:

Given that options being considered include converting official 
documentation over to the as-yet-to-be-defined new syntax and relegating 
#lang racket to a similar status as #lang mzscheme or #lang scheme, I don't 
think it's unreasonable to feel there is some risk as things stand 
*currently*. 

I expect more clarity to come which may reduce the risk, but it does seem 
like the majority of people who are downplaying the risk (or the perception 
of risk) are those in favor of the proposed changes. I suppose that's a 
natural response.

Brian 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/56faf557-a627-4856-b030-effca5700fee%40googlegroups.com.


Re: [racket-users] Interoperability between Racket & Chez Scheme

2019-07-23 Thread Brian Adkins
On Tuesday, July 23, 2019 at 8:52:36 PM UTC-4, Matthew Flatt wrote:
>
> At Tue, 23 Jul 2019 17:14:56 -0700 (PDT), Brian Adkins wrote: 
> > With the Racket on Chez Scheme implementation, how interoperable are 
> Racket 
> > and Chez? Is it possible for Racket functions to call Chez functions (or 
> > vice versa) directly w/o using a FFI? If so, can you point me to some 
> > documentation? If not, how difficult would it be to make this happen? 
>
> Chez Scheme functions work as Racket functions. A Racket function works 
> as a Chez Scheme function unless it accepts keyword arguments, is an 
> impersonator, or is an instance of a structure type that implemented 
> `prop:procedure`. 
>
> The easiest way to get a Chez Scheme primitive is to use the 
> `get-primitive` function from Sam's `get-primitive` package: 
>
>  https://github.com/samth/get-primitive 
>
>
> Racket pairs, symbols, etc., are Chez Scheme pairs, symbols, etc., so 
> you can get Chez Scheme's `eval` and easily start evaluating Chez 
> Scheme expressions. 
>

Thanks. I just realized I wasn't very clear. 

I was primarily referring to user defined functions. For example, if I 
wrote a Chez Scheme library, how would I use that from w/in some Racket 
code I wrote?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/68ae09e0-7f39-41cd-9c44-77d222b560c0%40googlegroups.com.


[racket-users] Re: Message in the meantime?

2019-07-23 Thread Brian Adkins
On Tuesday, July 23, 2019 at 12:55:40 PM UTC-4, Greg Hendershott wrote:
>
> Although I'm still skeptical that changing the surface syntax will be a 
> sufficiently big net gain, and ought to be the next, highest priority? 
> I'm running with that idea for the following. 
>
> It seems like there are at least two "flavors" or "strengths", of giving 
> Racket a non-sexpr syntax someday: 
>
> 1. The new syntax will be a choice, fully co-equal with sexprs. Both are 
>"first class", "forever". Any great new Racket features work with 
>either. 
>
> 2. The new syntax will become the preferred syntax, used in 
>documentation and advocacy. ("Change the culture" is the phrase I 
>thought Matthew used initially -- but I welcome him 
>clarifying/correcting/revising.) Sexprs and #lang racket will get a 
>status that's not as weak as "deprecated", but not really as strong 
>as co-equal with the new syntax. 
>

Option #1 is the only viable option from a community perspective. And I 
think it will demonstrate the value of language oriented programming more 
clearly.

I chose Racket for many reasons, but one important reason was that the age 
of the language allowed me to examine the history of how the community 
operated over a *long* period of time to get an idea of what I might expect 
in the future. I didn't even consider languages that I felt were too young.

If anything other than option #1 is our course of action, then any 
(current, or hypothetical future) users would be right in assuming the 
possibility that sometime later, the new official language might also be 
deprecated for something very different than what they expect. This is how 
*not* to build a community.

I'm sure people disagree with this line of reasoning, and I respect your 
different perspective, but hopefully we can all at least agree that 
expectation management is important, and that expectations a currently a 
bit muddled.

If the core team and/or community wants something other than option #1, I 
would much prefer to know sooner rather than later. It would make me sad, 
disappointed, frustrated, etc., but I suppose I would then reluctantly take 
a cue to consider Chez Scheme given it was chosen by Racket people I 
respect to be their foundation, just as I considered (and eventually chose) 
Racket, via PLT Scheme, when I discovered Paul Graham chose it for the 
foundation of Arc (after he abandoned his language community).

Brian
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e286c725-0f3e-4a94-ab89-589667d0cf3b%40googlegroups.com.


[racket-users] Interoperability between Racket & Chez Scheme

2019-07-23 Thread Brian Adkins
With the Racket on Chez Scheme implementation, how interoperable are Racket 
and Chez? Is it possible for Racket functions to call Chez functions (or 
vice versa) directly w/o using a FFI? If so, can you point me to some 
documentation? If not, how difficult would it be to make this happen?

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/260df3d6-f6f8-4bec-a653-a3bef82ae6c9%40googlegroups.com.


[racket-users] Re: Racket2 possibilities

2019-07-22 Thread Brian Adkins
On Monday, July 22, 2019 at 6:17:47 PM UTC-4, Zelphir Kaltstahl wrote:
>
> I just want to give one thought as input to this discussion and will 
> admit, that I did not read every (but some) of the posts above.
>
> When I write code in Racket or Scheme, I mostly like the parentheses, as 
> they make writing the code easy. I can very easily select a block and move 
> it around, without introducing any syntax errors. I can also quickly see 
> what the scope of something is, what other expression it is in. I don't get 
> these things from languages without this many parentheses or without 
> s-expression syntax. I need my parentheses as markers for my cursor to 
> quickly jump around. It is the most pleasant code typing experience I've 
> ever had. So when considering to move away from parentheses, please also 
> consider the burden that those parentheses take away from the person 
> writing the code. When I edit for example Python code, things are not clear 
> when moving around code. This is worse in Python than in other languages, 
> which at least have curly braces (but usually some other annoying 
> deficiencies). If there was a move away from this many parentheses (read 
> markers for my cursor), it would have to provide equal editability, for it 
> to be attractive to me. A design based on indentation or something like 
> that is not going to cut it for me. And what else would be used as start 
> and end markers for expressions? Wouldn't that in essence just be another 
> form of "parentheses", just looking different? How would any editor know, 
> where an expression starts and ends for easy selection and moving around, 
> if there were no such markers? So far I got no idea how that could be done 
> without introducing loads of new constraints about how you can nest 
> expressions into the language. So it beats me. Maybe my imagination in this 
> area is still somewhat limited.
>
> Just my 2c.
>

 Zelphir:

Since you mentioned you haven't read all the posts (and who could blame 
you, there's a lot!), I wanted to mention that the core team has stated you 
will continue to be able to program in #lang racket with s-expressions, and 
it will continue to be "well supported."

If Racket, with it's Scheme heritage, can't continue to support a 
Scheme-like programming experience, what that would say about language 
oriented programming?

As Matthew said, "Don't Panic" :)

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2f538039-5d73-4273-ae9d-d1dd0febdef4%40googlegroups.com.


Re: [racket-users] on reducing barriers in the Racket community

2019-07-22 Thread Brian Adkins
On Monday, July 22, 2019 at 1:07:21 PM UTC-4, Caleb Allen wrote:
>
> As an additional data point, I can share my very fast introduction into 
> Racket and the community. You asked for experiences where the community may 
> have made people feel unwelcome, but mine is a positive experience. I share 
> it to perhaps give an angle of what *is* right, and the parts of the 
> racket community which helped me go from an "outsider" to feeling welcome 
> and secure. My brief experience with this community has been wonderful, and 
> I want to contribute to making that experience the norm, if it is not 
> already. [...]
>

Thanks for articulating your thoughts so well Caleb.

Although my recent comments have probably focused more on technical 
aspects, the Racket community was *very* high on my priority list when I 
was looking for my next language. I was appreciative of answers I received 
to questions on the mailing list and/or IRC channel, and it was clear that 
top contributors were (and are) willing to take the time to deal with my 
newbie questions, and that, in turn, inspired me to want to get to the 
point where I could give back in a similar fashion (not quite there yet!).

>From *my* perspective, the Racket community has good *and* long track 
record, and I don't expect the current *hiccup* to change that :) And, if 
others have unfortunately had a worse experience, my sense is that we as a 
community are motivated to change that.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/11612770-b1be-4fc1-9304-a9125e000ca5%40googlegroups.com.


Re: Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-22 Thread Brian Adkins
On Monday, July 22, 2019 at 9:53:35 AM UTC-4, Greg Hendershott wrote:
>
> > Improved tooling also seems high-effort -- medium-risk -- 
> > medium-reward. I'll defer to those who concentrate more on tools, 
> > including the author of Racket mode for Emacs, to suggest a priority 
> > for this one. 
>
> Speaking of that, I had some plans what to do next. Even explore some 
> modest open-source funding. But Sunday morning hit the Pause button. 
>
> On Twitter I'm seeing some parody of old, sour, inflexible lispers who 
> only love sexprs. You know, fighting the inevitable electric car, which 
> is apparently on their lawn. Funny and unfair, both. 
>

Yup, saw the same thing, but, heh, the internet is nothing if not a 
fantastic straw man factory :)
 

> Although there are many ways and reasons to caricature me -- and I 
> heartily encourage anyone to do so, it's great fun! -- this doesn't 
> happen to be one of them. I spent a couple decades with C/C++. As my 
> mid-life crisis, instead of buying a sports car I learned Racket and 
> Emacs. Sexprs weren't a big deal; the new (to me) concepts were. Yes, 
> I've grown to really enjoy sexprs for editing (paredit), richer 
> identifier names, and not needing to check the tiresome board game rules 
> for operator precedence. But it's not like I can't use C or JS or Rust 
> or Haskell or Python or whatever syntax productively, especially when 
> not creating macros. In fact I can use those syntaxes by, say, using 
> those languages. 
>
> So for me, it's more like, "Well. If Racket will change that way, and 
> I'm skeptical it will help adoption, that feels like an inflection 
> point; a nudge to look around. Maybe spend more time with Rust or 
> Haskell or X, for the next ~10 years." 
>

Very astute observation re: the motivation for some to start looking 
around. 

I think I've personally made this a "tempest in a tea pot", and I now feel 
much better about continuing to be able to develop in #lang racket for a 
long, long time. However, one of my past frustrations is how good the lisp 
community has been at dividing and conquering itself. Being unfamiliar with 
some of Racket's unique benefits, I initially felt it was simply the best 
Scheme I could choose for professional development. Being 8 months into a 
large project in Racket, and seeing some of Racket's unique benefits more 
clearly now, I already know there are no other lisps that could currently 
lure me away, but folks who are just now looking may be getting a sense of 
some identity confusion. And I admit checkout out Chez Scheme a little more 
recently, but it would be too painful to give up Racket's benefits over 
Chez.

I already spent 10 years with SML, Haskell, OCaml, Rust, Julia, among 
others, and concluded Racket was the best for me, so I really, *really* 
don't want to start that process again!
 

> I'm not saying this is strictly logical. It's how I feel now. I'm also 
> not claiming it should be any input whatsoever into decisions made, 
> except maybe to the extent I'm representative of more people (and maybe 
> not even then). 
>
> Even if I decided to spend less time with Racket, I expect it would be 
> more like a slow cross-fade. This is not an abrupt, "So Long and Thanks 
> for All the Standard-Fish" announcement. :) 
>
> But seriously I feel like I need to wait for the dust to settle, digest, 
> understand where things will be in a couple years. 
>

Please don't wait for the dust to settle Greg! 

While I think the Racket core team did a pretty poor job of communicating 
(only partly due to my ignorance) how someone who is primarily interested 
in using #lang racket should feel about continuing with #lang racket, my 
current (possibly naive?) sense is that I shouldn't be concerned. However, 
how I personally feel is irrelevant if enough other folks start looking 
around for lispier pastures :(

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/78d3b84c-9e96-40f9-bc0c-56fb8befce3e%40googlegroups.com.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-19 Thread Brian Adkins
This may seem like a nitpick, but I think there would be a *huge* shift in 
attitudes if the suggestion for an infix syntax was framed in a similar 
manner to Typed Racket as opposed to Racket 2. The latter seems to imply a 
premature conclusion, where the former proposes a question to be answered 
by the community i.e. if people do flock to #lang infix, then the people 
will have spoken. Let #lang infix win by merit, not by decree!

Required re-reading: "The Evolution of Lisp" 
https://www.dreamsongs.com/Files/HOPL2-Uncut.pdf

Thanks to @rplevy for the reminder of that paper.

Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6c9ef7be-6172-4bfb-b5ac-5a2064921325%40googlegroups.com.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-18 Thread Brian Adkins
On Thursday, July 18, 2019 at 3:47:51 PM UTC-4, Justin Zamora wrote:
>
> On Thu, Jul 18, 2019 at 1:48 PM Brian Adkins  > wrote: 
> > I think more people (both existing users and new users) could get 
> > excited about Racket2 if it was primarily about making Racket 
> > objectively better and only secondarily about overcoming the 
> > aesthetic objection to parens. The message of "After years of effort, 
> > now you can program in Racket without using so many parens!" does not 
> > seem compelling to me. 
>
> The discussions about changing syntax are not about aesthetics. There are 
> some 
> genuine pain points in Racket that could be fixed with alternate 
> syntax. For instance, 
> it's easy for structure and array access to become unwieldy in 
> practice. Even a simple 
> example can show how awkward it can be. Suppose you have: 
>
> (struct person (first middle last)) 
> (define john (person "John" "Allen" "Smith")) 
>
> Now you want the person's initials. In Racket, the code is: 
>
> (string (string-ref (person-first john) 0) 
> (string-ref (person-middle john) 0) 
> (string-ref (person-last john) 0)) 
>
> There's a load of cognitive and syntactic overhead compared to something 
> like: 
>
> john.first[0] + john.middle[0] + john.last[0] 
>
> Even as someone who has programmed in Scheme for 30 years, I have to spend 
> a couple seconds to grasp what the Racket code is doing, while the 
> alternative 
> syntax is almost instantly understandable. 
>
> Making changes to eliminate such pain points may help new users to 
> consider Racket, 
> but even if they don't, there is still plenty of benefit to existing 
> Racket programmers. 
>
> Justin 
>

You bring up an excellent point, but it does seem to beg the question of 
why use Scheme given there are numerous other languages with a similar 
syntax to what you described?

I'm not trying to be argumentative - as a relatively new lisper, it was my 
understanding that while adding some verbosity, s-expressions enabled macro 
writing, and in turn, macros can eliminate some of the "cognitive and 
syntactic overhead". Also, "cognitive and syntactic overhead" may be 
somewhat subjective (ever waste time looking up operator precedence?), for 
example, I like the ubiquity of the pattern (operator operand1 operand2 
...) - it's simple to understand vs. many, context-sensitive constructs.

If it weren't for the promised value of language extension functionality 
provided by Racket, I *may* have been satisfied with a strict, dynamically 
typed version of Haskell :)  However, I'm not really sure about that - I 
think I weight simplicity & orthogonality *much* more than most 
programmers, so Scheme makes me happy. I think I would rather "clean up" 
your Racket example with syntax extension than use infix expressions with 
dot and [ ] operators, but that's just due to my subjective, aesthetic 
preferences.

We all have a unique perspective on what makes code beautiful; I'll keep an 
open mind that Racket2 may allow me to continue to write beautiful code.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8364a781-168b-47df-8ece-740d6afa8d50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-18 Thread Brian Adkins
One thing that's still bothering me is the admission that if Racket
was already popular enough we wouldn't be considering the syntax
change. This was an answer to a question in a live setting, and I am
prone to mis-interpreting/understanding, so I very much want to cut
Matthew some slack since he only had a few seconds to reply.

I feel framing the purpose (i.e. primarily to gain more users) of
Racket2 in this manner is problematic. One reason is that the ultimate
end (without some arbitrary limit) seems like it would have to be
similar to existing popular languages since that's clearly what more
programmers want - exactly how popular do we want to be? Another is
that it feels like a marketing driven effort vs. an engineering driven
effort i.e. prioritizing psychological appeasement over technical
excellence. I believe marketing is important, but I prioritize it
below technical excellence in this context.

My vague understanding of the idea of Racket2 (prior to Sunday) was
that it was a chance to make changes based on decades of learning by
allowing backward compatibility to be broken if it made the resulting
language better. After Sunday, I was left with the feeling that the
Racket developers were considering a huge & risky undertaking in which
the end result may not be better (objectively) than the current
language with the hope that people who rejected Racket previously will
now respect us for bending over backward to accommodate them, and join
us. I think it would be difficult for me to respect a programming
language community that invested such a huge effort for a lateral
move.

I think more people (both existing users and new users) could get
excited about Racket2 if it was primarily about making Racket
objectively better and only secondarily about overcoming the
aesthetic objection to parens. The message of "After years of effort,
now you can program in Racket without using so many parens!" does not
seem compelling to me.

My hope is that the primary goal of Racket2 is to provide objective
improvements to the language, and that a secondary goal of
attracting more users helps in deciding between similar means of
accomplishing the primary goal.

If the primary goal of Racket2 truly is to attract more programmers to 
Racket,
I think it would be valuable to take a step back and consider various
means to that end. While syntax may be important in accomplishing that
goal, I don't think it's clear that it's the most important.

Maybe the core team can take some time and clearly articulate the
goal(s) for Racket2 from which everything else flows?



-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/679e332b-146f-4636-9ca1-f06614c1158a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-17 Thread Brian Adkins
At this point, I'm a little less unsettled about a possible new syntax. I 
(naively?) think the Racket core team & wider community probably have a 
fairly large intersection of shared aesthetics that values elegance, 
expressive power, conciseness, ease of language extension, etc. I lean 
strongly toward minimalism, and, as an example, despite Haskell being a 
huge language from one perspective, it does allow for elegant and concise 
code.

I'm skeptical of the value of an infix syntax for reaching the stated goal, 
but as a newcomer, I feel that the folks who have invested years of their 
lives in developing Racket should certainly feel free to ask, and try to 
answer, the question.

Having said that, I can almost assure you that if this current discussion 
was happening when I was considering Racket initially, I would not have 
felt comfortable choosing it (possibly for irrational reasons), and I think 
it's clear that this type of change will result in both the loss of 
existing users and the gain of new users, and it's not at all clear to me 
which will be greater.

However, I can't *unsee* what I've seen with language oriented programming 
(and the downsides to running on the JVM are too great ;), so I'm happily 
"stuck" for the time being :)

Brian Adkins

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/93157f78-446c-4bd7-a5c4-c48e7e014621%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Racket Week 2019 was amazing!

2019-07-15 Thread Brian Adkins
A sincere "thank you" to everyone who was involved in creating Racket Week 
2019 as well as to the other participants who helped make the week an 
amazing experience!

I had high expectations, and they were all exceeded - by far. I'll be 
returning home tomorrow with fond memories of my time here in Utah, some 
new Racket friends and a ton of information to work through and internalize 
over the next few weeks & months. I can't wait to start applying what I 
learned here in my Racket code, and to hopefully give back to the Racket 
community in the form of some useful packages.

Thanks,
Brian

P.S. please don't take away my parens ;)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a70ab50c-28df-472c-9c5c-3bc6d8ade8ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] What is the address of the venue for RacketCon ?

2019-05-09 Thread Brian Adkins
Since The City Library has multiple locations, it would be helpful to 
simply list on the website the address of the specific location at which 
we'll be meeting.

Thanks,
Brian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b51e0fdb-d189-40b8-901b-6feb45663ff0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: What is the best way to "raco make" all *.rkt files in a directory tree?

2019-03-18 Thread Brian Adkins
Hmm... for some reason, I thought there were some "loopholes" where this 
wouldn't work, but I just modified an HTML template that is included by 
another template that is rendered by a function in a file included by my 
main app, and it worked as expected.

However, I did lose the -j 8 parallel aspect. I used --vv and it only 
reported one process. For my main use case of changing a few files and 
needing to compile them, it works great though. I'd only need the -j 8 
benefit if compiling many more files.

On Monday, March 11, 2019 at 8:34:59 PM UTC-4, Alex Harsanyi wrote:
>
> To add one more answer to this thread :-)
>
> In addition to compiling files specified on the command line, `raco make` 
> will recursively compile all files referenced via `require`.  This means 
> that if you have a top level file for your application, you can tell `raco 
> make` to compile that file, and it will compile all the files that it 
> references, the will be compiled only if they have changed.  There is also 
> a `-j` option which allows compiling in parallel.  So, for example, if the 
> toplevel file in your application is main.rkt you can do:
>
> raco make -j 8 main.rkt
>
> and all your project files will be updated.
>
> Alex.
>
> On Tuesday, March 12, 2019 at 3:00:34 AM UTC+8, Brian Adkins wrote:
>>
>> I looked over the documentation for raco make, and I didn't see anything 
>> about how to recursively make all *.rkt files in a directory tree. I 
>> suppose I could use something like:  find . -name \*.rkt | xargs raco make, 
>> but I like being able to use all 8 "cores" with -j 8, and I *think* I'd 
>> lose that with xargs.
>>
>> What is the best practice for making a tree of Racket code?
>>
>> Thanks,
>> Brian
>>
>

-- 
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] Re: Simple conditional in web template

2019-03-18 Thread Brian Adkins
Thanks, once I removed the initial , it worked fine. Way too much extra 
punctuation for my taste, but it's a good workaround for now until I can 
come up with something more concise.

  @(if #t
  @`{
  
This will be displayed if true
  
  }
  @`{
  
This will be displayed if false
  
  })


On Monday, March 18, 2019 at 11:56:25 AM UTC-4, Philip McGrath wrote:
>
> I don't use `include-template` (I've come to love x-expressions), but I 
> believe this would work:
> @,(if #true
>   @`{
>  This will be displayed if true
>  }
>   @`{
>  This will be displayed if false
>  })
>
> -Philip
>
>
> On Mon, Mar 18, 2019 at 11:48 AM Jérôme Martin  > wrote:
>
>>
>> On Monday, March 18, 2019 at 4:45:19 PM UTC+1, Brian Adkins wrote:
>>>
>>> Yes, using code would certainly make some things easier, but for the 
>>> moment, I'm looking for a template solution.
>>>
>>
>> Oh sorry, I didn't quite catch that! I never used templates, so I don't 
>> know.
>>
>> -- 
>> 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...@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.


[racket-users] Re: Simple conditional in web template

2019-03-18 Thread Brian Adkins
Yes, using code would certainly make some things easier, but for the 
moment, I'm looking for a template solution.

On Monday, March 18, 2019 at 11:41:41 AM UTC-4, Jérôme Martin wrote:
>
> (define (my-server-response show-cat?)
>   (response/xexpr
> `(div ([class "my-content"])
>   ,(if show-cat?
>(p "Welcome to my blog about cats!")
>(p "This blog is definitely not about cats.")
>
> On Monday, March 18, 2019 at 4:26:16 PM UTC+1, Brian Adkins wrote:
>>
>> How would one translate the following Ruby template into a Racket web 
>> template (including multiple lines for the if and else clauses) ?
>>
>> <% if true %>
>>   
>>  This will be displayed if true
>>   
>> <% else %>
>>   
>> This will be displayed if false
>>   
>> <% end %>
>>
>> I've read a fair amount of doc and was unable to find a simple example 
>> like the above. I think this is a pretty common need, so an example in the 
>> docs would be awesome. The "for" example with the recommendation to use 
>> "in" was helpful.
>>
>> Thanks,
>> Brian
>>
>

-- 
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] Simple conditional in web template

2019-03-18 Thread Brian Adkins
How would one translate the following Ruby template into a Racket web 
template (including multiple lines for the if and else clauses) ?

<% if true %>
  
 This will be displayed if true
  
<% else %>
  
This will be displayed if false
  
<% end %>

I've read a fair amount of doc and was unable to find a simple example like 
the above. I think this is a pretty common need, so an example in the docs 
would be awesome. The "for" example with the recommendation to use "in" was 
helpful.

Thanks,
Brian

-- 
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] Re: What is the best way to "raco make" all *.rkt files in a directory tree?

2019-03-11 Thread Brian Adkins
On Monday, March 11, 2019 at 3:00:34 PM UTC-4, Brian Adkins wrote:
>
> I looked over the documentation for raco make, and I didn't see anything 
> about how to recursively make all *.rkt files in a directory tree. I 
> suppose I could use something like:  find . -name \*.rkt | xargs raco make, 
> but I like being able to use all 8 "cores" with -j 8, and I *think* I'd 
> lose that with xargs.
>
> What is the best practice for making a tree of Racket code?
>
> Thanks,
> Brian
>

Hmm...  maybe the problem was just my lack of shell skills. I think the 
following works:

raco make -j 8 */*.rkt 

-- 
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] What is the best way to "raco make" all *.rkt files in a directory tree?

2019-03-11 Thread Brian Adkins
I looked over the documentation for raco make, and I didn't see anything 
about how to recursively make all *.rkt files in a directory tree. I 
suppose I could use something like:  find . -name \*.rkt | xargs raco make, 
but I like being able to use all 8 "cores" with -j 8, and I *think* I'd 
lose that with xargs.

What is the best practice for making a tree of Racket code?

Thanks,
Brian

-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Brian Adkins
On Monday, March 11, 2019 at 1:22:48 PM UTC-4, Matthias Felleisen wrote:
>
>
>
> > On Mar 11, 2019, at 1:18 PM, Brian Adkins  > wrote: 
> > 
> > I want let semantics, but I've been using define more because it's 
> preferred in the Racket style guide. I don't want the behavior of define 
> above, so using letrec to get a runtime error instead of compile time error 
> doesn't make sense. 
> > 
> > Oops - I should've used let* in my example. 
>
>
> That wouldn’t change a thing in your example. 


My only point was that when using let, it fails even when ordered 
correctly, but with let* it succeeds when ordered correctly.
 

> If you meant you want a let* semantics for sequences of define, I think 
> that’s a good idea. And as the author of the Style Guide, I wholeheartedly 
> agree with this desire. When I replace let-s with define-s, I have gotten 
> used to checking for identifier sequencing and such. But perhaps a newbie 
> shouldn’t have to think that way. 


I would argue that *nobody* should have to think that way when we can have 
the compiler do it for us :) Obviously, I'm happy with a dynamically typed 
language, as I've chosen Racket over OCaml & Haskell, but I'm still happy 
to delegate some things to the compiler. 


-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Brian Adkins
Yes, I hadn't really thought through the semantics of define (i.e. whether 
it had let or letrec semantics). So, in my case, since I want let 
semantics, I will use let. I'm happy to follow the Racket style guide when 
I get to the point of contributing code that is covered by it, but I think 
I will use let, when I want let semantics, for my own code.

On Monday, March 11, 2019 at 1:17:47 PM UTC-4, Greg Hendershott wrote:
>
> To be fair: 
>
> As a new user, it's possible to have the intuition that `define` is 
> just a way to avoid indentation -- that it "writes a `let` for you, 
> from the point of the define to 'the end of the enclosing scope'". 
>
> And it's possible for that intuition to seem correct for a very long 
> time -- until you hit an example like Brian did. And then you need to 
> learn about `letrec`. 
>
> (As a non-new user, 99.9% of the time that I use a local `define` I 
> actually wish it were "like `let`" not `letrec`, but I use it anyway 
> and try to be careful.) 
>
>
> On Mon, Mar 11, 2019 at 12:29 PM Matthias Felleisen 
> > wrote: 
> > 
> > 
> > 
> > > On Mar 11, 2019, at 11:21 AM, Brian Adkins  > wrote: 
> > > 
> > > I just discovered that define will fail at runtime, where let would 
> fail at compile time. Besides helping to keep the indentation level from 
> marching to the right "too much", what are the benefits of define over let? 
> > > 
> > > --- snip --- 
> > > #lang racket 
> > > 
> > > (define (f n) (+ n 1)) 
> > > 
> > > (define (foo) 
> > >   (define b (f a)) 
> > >   (define a 7) 
> > > 
> > >   b) 
> > > 
> > > (define (bar) 
> > >   (let ([b (f a)] 
> > > [a 7]) 
> > > 
> > > b)) 
> > > --- snip --- 
> > 
> > 
> > 
> > I think your characterization is a bit misleading here. 
> > 
> > In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly 
> signal at compile time. 
> > 
> > In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive 
> scope. But, when Racket evaluates (foo) it notices that ‘a’ is bound but 
> uninitialized, which is two different things. 
> > 
> > If you want to compare apples to apples, use a ‘letrec' instead of a 
> ‘let' in ‘bar'. Then you have (1) the same semantics and (2) the same 
> error. 
> > 
> > — Matthias 
> > 
> > -- 
> > 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...@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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Brian Adkins


On Monday, March 11, 2019 at 1:13:30 PM UTC-4, Brian Adkins wrote:
>
>
>
> On Monday, March 11, 2019 at 12:29:40 PM UTC-4, Matthias Felleisen wrote:
>>
>>
>>
>> > On Mar 11, 2019, at 11:21 AM, Brian Adkins  wrote: 
>> > 
>> > I just discovered that define will fail at runtime, where let would 
>> fail at compile time. Besides helping to keep the indentation level from 
>> marching to the right "too much", what are the benefits of define over let? 
>> > 
>> > --- snip --- 
>> > #lang racket 
>> > 
>> > (define (f n) (+ n 1)) 
>> > 
>> > (define (foo) 
>> >   (define b (f a)) 
>> >   (define a 7) 
>> >   
>> >   b) 
>> > 
>> > (define (bar) 
>> >   (let ([b (f a)] 
>> > [a 7]) 
>> > 
>> > b)) 
>> > --- snip --- 
>>
>>
>>
>> I think your characterization is a bit misleading here. 
>>
>> In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly 
>> signal at compile time. 
>>
>> In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive 
>> scope. But, when Racket evaluates (foo) it notices that ‘a’ is bound but 
>> uninitialized, which is two different things. 
>>
>> If you want to compare apples to apples, use a ‘letrec' instead of a 
>> ‘let' in ‘bar'. Then you have (1) the same semantics and (2) the same 
>> error. 
>>
>> — Matthias 
>>
>>
> I want let semantics, but I've been using define more because it's 
> preferred in the Racket style guide. I don't want the behavior of define 
> above, so using letrec to get a runtime error instead of compile time error 
> doesn't make sense.
>

Oops - I should've used let* in my example. 

-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Brian Adkins


On Monday, March 11, 2019 at 12:29:40 PM UTC-4, Matthias Felleisen wrote:
>
>
>
> > On Mar 11, 2019, at 11:21 AM, Brian Adkins  > wrote: 
> > 
> > I just discovered that define will fail at runtime, where let would fail 
> at compile time. Besides helping to keep the indentation level from 
> marching to the right "too much", what are the benefits of define over let? 
> > 
> > --- snip --- 
> > #lang racket 
> > 
> > (define (f n) (+ n 1)) 
> > 
> > (define (foo) 
> >   (define b (f a)) 
> >   (define a 7) 
> >   
> >   b) 
> > 
> > (define (bar) 
> >   (let ([b (f a)] 
> > [a 7]) 
> > 
> > b)) 
> > --- snip --- 
>
>
>
> I think your characterization is a bit misleading here. 
>
> In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly 
> signal at compile time. 
>
> In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive scope. 
> But, when Racket evaluates (foo) it notices that ‘a’ is bound but 
> uninitialized, which is two different things. 
>
> If you want to compare apples to apples, use a ‘letrec' instead of a ‘let' 
> in ‘bar'. Then you have (1) the same semantics and (2) the same error. 
>
> — Matthias 
>
>
I want let semantics, but I've been using define more because it's 
preferred in the Racket style guide. I don't want the behavior of define 
above, so using letrec to get a runtime error instead of compile time error 
doesn't make sense.

-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Brian Adkins
I just discovered that define will fail at runtime, where let would fail at 
compile time. Besides helping to keep the indentation level from marching 
to the right "too much", what are the benefits of define over let?

--- snip ---
#lang racket

(define (f n) (+ n 1))

(define (foo)
  (define b (f a))
  (define a 7)
  
  b)

(define (bar)
  (let ([b (f a)]
[a 7])

b))
--- snip ---

-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-25 Thread Brian Adkins
On Friday, February 22, 2019 at 4:00:11 PM UTC-5, Jon Zeppieri wrote:
>
>
>
> On Fri, Feb 22, 2019 at 11:36 AM Brian Adkins  > wrote:
>
>>
>> It seems that not short circuiting would be a good idea regardless of 
>> other changes. It's not urgent for me, because the code in question won't 
>> run late in the evening where the problem occurs.
>>
>>
> I have a proposed fix, if you care (or anyone else cares) to take a look 
> and comment: https://github.com/97jaz/tzinfo/pull/7
>
>
Thanks for the fix Jon. I'm still a relative Racket newbie - I'd like to be 
able to install your package from the new branch, but I'd also like to be 
able to go back to the way things are now. As far as I know, I didn't 
install tzinfo explicitly, so I expect maybe the gregor package has it as a 
dependency. If that's the case, will gregor just happily use the new 
package from your branch? 

-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-22 Thread Brian Adkins
On Friday, February 22, 2019 at 11:23:10 AM UTC-5, Jon Zeppieri wrote:
>
>
> On Fri, Feb 22, 2019 at 10:44 AM Brian Adkins  > wrote:
>
>>
>> Yes, I think we found the problem:
>>
>> $ ls -l /etc/localtime
>> lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
>> /usr/share/zoneinfo/America/New_York
>> deploy@ip-172-31-10-34:~$ ls -l /usr/share/zoneinfo/America/New_York
>> lrwxrwxrwx 1 root root 13 Jan  1 00:05 
>> /usr/share/zoneinfo/America/New_York -> ../posixrules
>>  
>>
>> $ racket
>> Welcome to Racket v7.1.
>> > (require racket/enter)
>> > (require tzinfo/private/zoneinfo)
>> > (enter! tzinfo/private/zoneinfo)
>> /tzinfo/tzinfo/private/zoneinfo> (define zi (make-zoneinfo-source))
>> /tzinfo/tzinfo/private/zoneinfo> (tzinfo-has-tzid? zi 
>> "America/New_York")
>> #t
>> /tzinfo/tzinfo/private/zoneinfo> (find-zoneinfo-directory 
>> default-zoneinfo-search-path)
>> "/usr/share/zoneinfo"
>> /tzinfo/tzinfo/private/zoneinfo> (detect-tzid/unix (zoneinfo-dir zi)
>>   
>>  (find-zoneinfo-directory default-zoneinfo-search-path)
>>   
>>  (tzinfo->all-tzids zi))
>> "posixrules"
>>
>>
> Well, that's one I haven't seen before -- a file that actually names a 
> time zone is a symlink to another file. (I see we're not the only people 
> who have run afoul of this [
> https://github.com/HowardHinnant/date/issues/252] 
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FHowardHinnant%2Fdate%2Fissues%2F252%255D=D=1=AFQjCNEAZDH1-NNFyKjuxBMiG3wRHM8IDw>
> ).
>
> We have a few options here.
> - Simply putting the /etc/timezone check before the /etc/localtime check 
> would solve the problem for you, though not for systems that use 
> /etc/localtime as a symlink but do not use /etc/timezone.
> - Similarly, not short-circuiting the various checks and only looking for 
> valid values after we've accumulated all the results of the tests would 
> work in your case, assuming that (tzid-from-/etc/timezone) returns the 
> right answer for you (which I assume it does).
> - Changing the implementation of the /etc/localtime check to use 
> readlink(2) to follow the symlink a single step is an option, though it 
> wouldn't help if someone linked directly from /etc/localtime to posixrules. 
> That sounds like a crazy scenario, but I would have said that linking 
> America/New_York to posixrules is unlikely. (I'd expect it to be the other 
> way around.) I guess the more general approach would be to use readlink(2) 
> until we find a path that names a time zone.
> - I could also abandon the symlink check altogether and always use the 
> slow path, which checks for file _content_ identity between /etc/timezone 
> and any file that names an IANA time zone in the zoneinfo tree.
>
> (Of course, all of this would be unnecessary if the tzid were actually 
> somewhere _in_ the tzfile(5) format somewhere.)
>
> If you need an immediate workaround, you can launch racket with the TZ 
> environment variable set to the contents of /etc/timezone. But I'll fix 
> this just as soon as I decide what the best approach is.
>
>
> By the way (and this question is for everyone), am I right that 
> readlink(2) functionality isn't already in the Racket standard library 
> anywhere? (I don't know if it has an analogue on Windows.)
>
>  - Jon
>
>
Yes, (tzid-from-/etc/timezone) returns the correct value:

/tzinfo/tzinfo/private/os/unix> (tzid-from-/etc/timezone)
"America/New_York" 

It seems that not short circuiting would be a good idea regardless of other 
changes. It's not urgent for me, because the code in question won't run 
late in the evening where the problem occurs.


-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-22 Thread Brian Adkins
On Thursday, February 21, 2019 at 11:16:00 PM UTC-5, Jon Zeppieri wrote:
>
>
>
> On Thu, Feb 21, 2019 at 10:12 PM Brian Adkins  > wrote:
>
>> On Thursday, February 21, 2019 at 9:54:23 PM UTC-5, Jon Zeppieri wrote:
>>>
>>>
>>>
>>> On Thu, Feb 21, 2019 at 9:48 PM Brian Adkins  wrote:
>>>
>>>> On Thursday, February 21, 2019 at 9:35:58 PM UTC-5, Brian Adkins wrote:
>>>>>
>>>>> On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>>>>>>
>>>>>> I'm using the (today) function from the gregor library. It was 
>>>>>> returning tomorrow instead of today, so I thought the problem was the 
>>>>>> timezone on my Ubuntu server. I configured the timezone to be US/Eastern 
>>>>>> via: sudo dpkg-reconfigure tzdata
>>>>>>
>>>>>> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as 
>>>>>> expected.
>>>>>>
>>>>>> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>>>>>>
>>>>>> So, gregor's (today) still returns tomorrow (since it's so late).
>>>>>>
>>>>>> Anyone know how to get (system-tzid) to return the correct value on 
>>>>>> Ubuntu?
>>>>>>
>>>>>
>>>>> Some more info:
>>>>>
>>>>> /etc/localtime is linked as:  localtime -> 
>>>>> /usr/share/zoneinfo/US/Eastern 
>>>>>
>>>>
>>>> I reinvoked sudo dpkg-reconfigure tzdata  and chose America/New_York  
>>>> instead of  US/Eastern, but I still get the default "Etc/UTC" from 
>>>> (system-tzid) 
>>>>
>>>
>>>
>>> Huh. Could you do the following and tell me what you get?
>>>
>>> > (require tzinfo/private/generics)
>>> > (require tzinfo/private/zoneinfo)
>>> > (define zi (make-zoneinfo-source))
>>> > (zoneinfo-dir zi)
>>> "/usr/share/zoneinfo"
>>> > (detect-system-tzid zi)
>>> "America/New_York"
>>>
>>
>> > (require tzinfo/private/generics)
>> > (require tzinfo/private/zoneinfo)
>> > (define zi (make-zoneinfo-source))
>> > (zoneinfo-dir zi)
>> "/usr/share/zoneinfo"
>> > (detect-system-tzid zi)
>> #f
>>
>> Also:
>>
>> $ ls -l /etc/localtime
>> lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
>> /usr/share/zoneinfo/America/New_York
>>
>> $ cat /etc/timezone
>> America/New_York
>>  
>>
>
> Thanks.
>
> Okay, so first I figured that the problem was probably due to the weird 
> way that I try to discover the target of an /etc/timezone symlink. (Racket 
> doesn't provide that functionality, as far as I could tell at the time, and 
> I guess I wanted to avoid the FFI? Even though I used it for Windows? My 
> memory fails me.)
>
> But, if that method fails, it also tries getting the value from 
> /etc/timezone, which you noted, is set correctly. And that method of 
> getting the timezone is really simple. It just reads the file. So... hmm. 
> Okay, let's do this exhaustively.
>
> 1. Verify that (system-type) is 'unix. (Just to make sure we check 
> everything.)
>
> 2. In DrRacket, in the definitions window, put the following:
> ```
> #lang racket/base
>
> (require tzinfo/private/zoneinfo)
> ```
> 3. Right click on `tzinfo/private/zoneinfo` and select "Open zoneinfo.rkt."
>
> 4. In the new DrRacket window that contains the source of zoneinfo.rkt, 
> click "Run."
>
> 5. Then, in the interaction pane, do:
> > (define zi (make-zoneinfo-source))
> > (tzinfo-has-tzid? zi "America/New_York")
> #t
>
> If this is #f, that would be bad, and you can stop right there.
>
> 6. Next:
> > (find-zoneinfo-directory default-zoneinfo-search-path)
> "/usr/share/zoneinfo"
>
> If you don't get the same values for this, that would be odd.
>
> 7.
> > (detect-tzid/unix (zoneinfo-dir zi)
> (find-zoneinfo-directory default-zoneinfo-search-path)
> (tzinfo->all-tzids zi))
> "America/New_York"
>
> I expect you'll either get #f here or else you'll get a string but it 
> won't be a valid IANA time zone name.
>
> 8. Near the top of zoneinfo.rkt, you'll see a require line for 
> "os/unix.rkt." Right click that and open the file. Run it.
>
> 9. In the interactions pane:
>

Re: [racket-users] Re: How do I get (system-tzid) to return the correct value?

2019-02-21 Thread Brian Adkins


On Thursday, February 21, 2019 at 10:12:02 PM UTC-5, Brian Adkins wrote:
>
> On Thursday, February 21, 2019 at 9:54:23 PM UTC-5, Jon Zeppieri wrote:
>>
>>
>>
>> On Thu, Feb 21, 2019 at 9:48 PM Brian Adkins  wrote:
>>
>>> On Thursday, February 21, 2019 at 9:35:58 PM UTC-5, Brian Adkins wrote:
>>>>
>>>> On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>>>>>
>>>>> I'm using the (today) function from the gregor library. It was 
>>>>> returning tomorrow instead of today, so I thought the problem was the 
>>>>> timezone on my Ubuntu server. I configured the timezone to be US/Eastern 
>>>>> via: sudo dpkg-reconfigure tzdata
>>>>>
>>>>> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as 
>>>>> expected.
>>>>>
>>>>> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>>>>>
>>>>> So, gregor's (today) still returns tomorrow (since it's so late).
>>>>>
>>>>> Anyone know how to get (system-tzid) to return the correct value on 
>>>>> Ubuntu?
>>>>>
>>>>
>>>> Some more info:
>>>>
>>>> /etc/localtime is linked as:  localtime -> 
>>>> /usr/share/zoneinfo/US/Eastern 
>>>>
>>>
>>> I reinvoked sudo dpkg-reconfigure tzdata  and chose America/New_York  
>>> instead of  US/Eastern, but I still get the default "Etc/UTC" from 
>>> (system-tzid) 
>>>
>>
>>
>> Huh. Could you do the following and tell me what you get?
>>
>> > (require tzinfo/private/generics)
>> > (require tzinfo/private/zoneinfo)
>> > (define zi (make-zoneinfo-source))
>> > (zoneinfo-dir zi)
>> "/usr/share/zoneinfo"
>> > (detect-system-tzid zi)
>> "America/New_York"
>>
>
> > (require tzinfo/private/generics)
> > (require tzinfo/private/zoneinfo)
> > (define zi (make-zoneinfo-source))
> > (zoneinfo-dir zi)
> "/usr/share/zoneinfo"
> > (detect-system-tzid zi)
> #f
>
> Also:
>
> $ ls -l /etc/localtime
> lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
> /usr/share/zoneinfo/America/New_York
>
> $ cat /etc/timezone
> America/New_York
>  
>
>>  
>>
>
I gotta hit the sack, but a couple more pieces of info:

Racket v7.1
Ubuntu 18.04 running on Amazon EC2

$ raco pkg show
Installation-wide:
 PackageChecksum Source
 main-distribution  107e1b59943f693b...  catalog...tribution
 racket-lib 21fbc2a1a2972f1f...  catalog racket-lib
 [194 auto-installed packages not shown]
User-specific for installation "7.1":
 PackageChecksumSource
 gregor 3b4acc9b41806091b0f...  catalog...?path=gregor
 libuuid4bead1a3ccfc1714c1c...  catalog...buuid/master
 soundexb870344d2cae6764234...  catalog soundex
 threading  de68f80c91b47b58607...  catalog...th=threading
 [13 auto-installed packages not shown]
 

-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-21 Thread Brian Adkins
On Thursday, February 21, 2019 at 9:54:23 PM UTC-5, Jon Zeppieri wrote:
>
>
>
> On Thu, Feb 21, 2019 at 9:48 PM Brian Adkins  > wrote:
>
>> On Thursday, February 21, 2019 at 9:35:58 PM UTC-5, Brian Adkins wrote:
>>>
>>> On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>>>>
>>>> I'm using the (today) function from the gregor library. It was 
>>>> returning tomorrow instead of today, so I thought the problem was the 
>>>> timezone on my Ubuntu server. I configured the timezone to be US/Eastern 
>>>> via: sudo dpkg-reconfigure tzdata
>>>>
>>>> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as 
>>>> expected.
>>>>
>>>> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>>>>
>>>> So, gregor's (today) still returns tomorrow (since it's so late).
>>>>
>>>> Anyone know how to get (system-tzid) to return the correct value on 
>>>> Ubuntu?
>>>>
>>>
>>> Some more info:
>>>
>>> /etc/localtime is linked as:  localtime -> 
>>> /usr/share/zoneinfo/US/Eastern 
>>>
>>
>> I reinvoked sudo dpkg-reconfigure tzdata  and chose America/New_York  
>> instead of  US/Eastern, but I still get the default "Etc/UTC" from 
>> (system-tzid) 
>>
>
>
> Huh. Could you do the following and tell me what you get?
>
> > (require tzinfo/private/generics)
> > (require tzinfo/private/zoneinfo)
> > (define zi (make-zoneinfo-source))
> > (zoneinfo-dir zi)
> "/usr/share/zoneinfo"
> > (detect-system-tzid zi)
> "America/New_York"
>

> (require tzinfo/private/generics)
> (require tzinfo/private/zoneinfo)
> (define zi (make-zoneinfo-source))
> (zoneinfo-dir zi)
"/usr/share/zoneinfo"
> (detect-system-tzid zi)
#f

Also:

$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
/usr/share/zoneinfo/America/New_York

$ cat /etc/timezone
America/New_York
 

>  
>

-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-21 Thread Brian Adkins
On Thursday, February 21, 2019 at 9:35:58 PM UTC-5, Brian Adkins wrote:
>
> On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>>
>> I'm using the (today) function from the gregor library. It was returning 
>> tomorrow instead of today, so I thought the problem was the timezone on my 
>> Ubuntu server. I configured the timezone to be US/Eastern via: sudo 
>> dpkg-reconfigure tzdata
>>
>> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as expected.
>>
>> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>>
>> So, gregor's (today) still returns tomorrow (since it's so late).
>>
>> Anyone know how to get (system-tzid) to return the correct value on 
>> Ubuntu?
>>
>
> Some more info:
>
> /etc/localtime is linked as:  localtime -> /usr/share/zoneinfo/US/Eastern 
>

I reinvoked sudo dpkg-reconfigure tzdata  and chose America/New_York  
instead of  US/Eastern, but I still get the default "Etc/UTC" from 
(system-tzid) 

-- 
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] Re: How do I get (system-tzid) to return the correct value?

2019-02-21 Thread Brian Adkins
On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>
> I'm using the (today) function from the gregor library. It was returning 
> tomorrow instead of today, so I thought the problem was the timezone on my 
> Ubuntu server. I configured the timezone to be US/Eastern via: sudo 
> dpkg-reconfigure tzdata
>
> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as expected.
>
> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>
> So, gregor's (today) still returns tomorrow (since it's so late).
>
> Anyone know how to get (system-tzid) to return the correct value on Ubuntu?
>

Some more info:

/etc/localtime is linked as:  localtime -> /usr/share/zoneinfo/US/Eastern 

-- 
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] How do I get (system-tzid) to return the correct value?

2019-02-21 Thread Brian Adkins
I'm using the (today) function from the gregor library. It was returning 
tomorrow instead of today, so I thought the problem was the timezone on my 
Ubuntu server. I configured the timezone to be US/Eastern via: sudo 
dpkg-reconfigure tzdata

Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as expected.

Unfortunately, (system-tzid) returns:  "Etc/UTC"

So, gregor's (today) still returns tomorrow (since it's so late).

Anyone know how to get (system-tzid) to return the correct value on Ubuntu?

Thanks,
Brian

-- 
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] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Brian Adkins
On Tuesday, February 19, 2019 at 5:06:32 PM UTC-5, Matthew Butterick wrote:
>
>
>
> On Feb 19, 2019, at 1:28 PM, Brian Adkins  > wrote:
>
> Oops - I spoke too soon. It appears the lexical context is unavailable to 
> the template when include-template is used in this manner. 
>
>
> Ah right, one has to inject STR into the same lexical context, like so:
>
>
> #lang racket
> (require web-server/templates)
>
> (define-syntax (include-template/named stx)
>   (syntax-case stx ()
> [(_ NAME)
>  (with-syntax ([STR (datum->syntax #'NAME (string-append 
> "../views/authentication/" (symbol->string (syntax-e #'NAME)) ".html"))]) 
>#'(include-template STR))]))
>
> (define (login request)
>   (include-template/named login))
>


Awesome - that did the trick. I'm confused as to why it helped to inject 
STR into the lexical context - it ends up being just a string, and it was 
working fine with respect to loading the template. I would think the fix 
would be to inject include-template into the lexical context. I suppose it 
must have something to do with how the include-template macro is dealing 
with that argument. 

-- 
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] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Brian Adkins


On Tuesday, February 19, 2019 at 4:03:02 PM UTC-5, Brian Adkins wrote:
>
> On Tuesday, February 19, 2019 at 1:45:43 PM UTC-5, Matthew Butterick wrote:
>>
>>
>> On Feb 19, 2019, at 8:25 AM, Brian Adkins  wrote:
>>
>> But, I'm guessing that the include-template macro is unable to consume 
>> the output of my view macro. Is there anything I can do to get (view login) 
>> to be expanded prior to when include-template needs it?
>>
>>
>> Wrap `include-template` with your own macro that generates the string you 
>> want?
>>
>> #lang racket
>> (require web-server/templates)
>>
>> (define-syntax (include-template/named stx)
>>   (syntax-case stx ()
>> [(_ NAME)
>>  (with-syntax ([STR (string-append "../views/authentication/" 
>> (symbol->string (syntax-e #'NAME)) ".html")]) 
>>#'(include-template STR))]))
>>
>> (define (login request)
>>   (include-template/named login))
>>
>>
> That's perfect Matthew - thanks! 
>

Oops - I spoke too soon. It appears the lexical context is unavailable to 
the template when include-template is used in this manner. 

-- 
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] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Brian Adkins
On Tuesday, February 19, 2019 at 1:45:43 PM UTC-5, Matthew Butterick wrote:
>
>
> On Feb 19, 2019, at 8:25 AM, Brian Adkins  > wrote:
>
> But, I'm guessing that the include-template macro is unable to consume the 
> output of my view macro. Is there anything I can do to get (view login) to 
> be expanded prior to when include-template needs it?
>
>
> Wrap `include-template` with your own macro that generates the string you 
> want?
>
> #lang racket
> (require web-server/templates)
>
> (define-syntax (include-template/named stx)
>   (syntax-case stx ()
> [(_ NAME)
>  (with-syntax ([STR (string-append "../views/authentication/" 
> (symbol->string (syntax-e #'NAME)) ".html")]) 
>#'(include-template STR))]))
>
> (define (login request)
>   (include-template/named login))
>
>
That's perfect Matthew - thanks! 

-- 
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] Bending use of include-template to my needs (or, macro results as macro arguments)

2019-02-19 Thread Brian Adkins
I would like to take the following web request handler:

(define (login request)
  (render-string
   (include-template "../views/authentication/login.html")))

and eventually get to something like:

(define (login request)
  (render login))

My current lack of understanding with respect to macros is limiting me :) 
For now, I'd be content with the following:

(define (login request)
  (render-string
   (include-template (view login

which I tried to get to work with this macro:

(define-syntax-rule (view name)
  (string-append "../views/authentication/" (symbol->string (quote name)) 
".html"))

But, I'm guessing that the include-template macro is unable to consume the 
output of my view macro. Is there anything I can do to get (view login) to 
be expanded prior to when include-template needs it?

Thanks,
Brian


-- 
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] Re: Execution ends before log message is displayed

2019-01-24 Thread Brian Adkins
On Thursday, January 24, 2019 at 12:44:51 AM UTC-5, gneuner2 wrote:
>
>
>
> On 1/23/2019 12:02 PM, Brian Adkins wrote: 
> > It looks like you're still using an arbitrary wait time to assume the 
> > logging event queue is empty. I like it much better than my sleep 
> > idea, but it seems like there is still the problem of choosing between 
> > 1) using a timeout value to short and missing a log message, or 2) 
> > using a timeout value too long and wasting time waiting. 
> > 
>
> I am relying on all posts to the queue having been made *before* the 
> stop event is sent.  I am NOT relying on wait time - there just has to 
> be some timeout specified so the sync call returns when the queue is 
> empty. 
>
> George 
>
> Thanks for the clarification - I missed that important detail! 

I'm not familiar with the implementation of Racket's logging, but it seems 
reasonable that once (log-message) returns the log message would be 
immediately available for sync'ing i.e. it's not arriving asynchronously.

 

-- 
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] Re: Execution ends before log message is displayed

2019-01-23 Thread Brian Adkins
Thanks. 

It looks like you're still using an arbitrary wait time to assume the 
logging event queue is empty. I like it much better than my sleep idea, but 
it seems like there is still the problem of choosing between 1) using a 
timeout value to short and missing a log message, or 2) using a timeout 
value too long and wasting time waiting.

On Sunday, January 20, 2019 at 9:47:34 PM UTC-5, gneuner2 wrote:
>
>
> On 1/20/2019 6:34 PM, Brian Adkins wrote:
>
> Thanks.  
>
> I do use dynamic-wind in various ways now, but I'm not sure how it would 
> help me in this particular scenario. My log receiver thread is simply in a 
> loop sync'ing on the logger, so I can't wait for my thread. I don't know 
> how to determine when all the log messages have been received. Sleeping for 
> a second would probably do it, but that seems pretty kludgy :)
>
>
> You make the the logging thread wait for either a message or a stop event, 
> and once it receives the 'stop' event, have it empty the message queue 
> before exiting.  E.g.,
>
>:
> ; loop until stop-evt
> (do [
> (event (sync receiver stop-evt)
>(sync receiver stop-evt))
> ]
>  ((equal? event stop-evt) 'flush_queue)
>  (write-one-event event))
>
> ; loop until queue empty
> (do [
> (event (sync/timeout 0.01 receiver)
>(sync/timeout 0.01 receiver))
> ]
>  ((equal? event #f) 'stop)
>  (write-one-event event))
> :
> ;end of logging thread
>
>
> At the point you send the stop event, all the messages should have been 
> posted even if not yet printed.
>
> In the main thread you [call some function to  send the stop event and 
> wait for the logger thread to finish.  Where you want to use dynamic-wind 
> is if the main [or other processing] thread can be interrupted (Ctrl-C, 
> etc.) - you want to make sure the logger gets shut down cleanly no matter 
> how the main thread ends.
>
>
> This is mainly a problem for logging in tests because they can finish so 
> quickly. For my main application, I don't think it will be much of an 
> issue. For my tests, I just created a wrapper that uses the default logger, 
> and I'll control the amount of output with a PLTSTDERR env variable.
>
>
> Tests can be a problem anyway because the tests may need significant setup 
> just like the real program.  I pretty much always wrap my code in a 
> dynamic-wind:  regardless of setup, I want to be sure I can clean up 
> afterwards even if I had to break it.
>
> George
>

-- 
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] Re: Execution ends before log message is displayed

2019-01-20 Thread Brian Adkins
Thanks. 

I do use dynamic-wind in various ways now, but I'm not sure how it would 
help me in this particular scenario. My log receiver thread is simply in a 
loop sync'ing on the logger, so I can't wait for my thread. I don't know 
how to determine when all the log messages have been received. Sleeping for 
a second would probably do it, but that seems pretty kludgy :)

This is mainly a problem for logging in tests because they can finish so 
quickly. For my main application, I don't think it will be much of an 
issue. For my tests, I just created a wrapper that uses the default logger, 
and I'll control the amount of output with a PLTSTDERR env variable.

On Friday, January 18, 2019 at 9:28:26 PM UTC-5, gneuner2 wrote:
>
> On Thu, 17 Jan 2019 18:08:00 -0800 (PST), Brian Adkins 
> > wrote: 
>
> >Aha! Thanks for the quick reply. I'll have to rethink how I'm handling 
> >logging. 
>
> One thing you might try is to use dynamic-wind in your main thread, so 
> you can cleanly end loggin and shut down your logging thread even if 
> the main thread dies (or is killed). 
>
> George 
>
>

-- 
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] Execution ends before log message is displayed

2019-01-17 Thread Brian Adkins
Aha! Thanks for the quick reply. I'll have to rethink how I'm handling 
logging.

On Thursday, January 17, 2019 at 9:03:39 PM UTC-5, Matthew Flatt wrote:
>
> Yes, the default logger cheats. When you log a relevant message, it's 
> written immediately to stdout/stderr/syslog instead of being posted to 
> a receiver that is later polled. 
>
> At Thu, 17 Jan 2019 17:59:30 -0800 (PST), Brian Adkins wrote: 
> > I've created my own logger via make-logger, and I started a thread with 
> a 
> > loop that sync's on the log receiver I created via make-log-receiver. 
> I'm 
> > logging some messages in a test, and it appears that the test completes 
> > (and presumably kills the log receiver thread) before the log message is 
> > displayed. I'm calling (flush-output) after printf'ing the message to 
> > standard out. 
> > 
> > The default logger does not have this problem. Is that because it 
> doesn't 
> > use a separate thread to sync on the log messages and display them? Or 
> am I 
> > misunderstanding how to best utilize a custom logger? 
> > 
> > I've copy/pasted some code below for specifics. 
> > 
> > Thanks, 
> > Brian 
> > 
> > (define axio-logger (make-logger 'axio)) 
> > 
> > (define/contract (axio-log-debug str) 
> >   (-> string? any) 
> >   (log-message axio-logger 'debug str #f)) 
> > 
> > ... 
> > 
> > (define/contract (axio-init-logger level) 
> >   (-> symbol? any) 
> >   (define axio-log-receiver (make-log-receiver axio-logger level)) 
> >   
> >   (thread 
> >(λ () 
> >  (let loop () 
> >(define v (sync axio-log-receiver)) 
> >(printf "[~a] ~a\n" 
> >(vector-ref v 0) 
> >(vector-ref v 1)) 
> >(flush-output) 
> >(loop) 
> > 
> > 
> > (axio-log-debug "my log message") 
> > 
> > -- 
> > 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...@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.


[racket-users] Execution ends before log message is displayed

2019-01-17 Thread Brian Adkins
I've created my own logger via make-logger, and I started a thread with a 
loop that sync's on the log receiver I created via make-log-receiver. I'm 
logging some messages in a test, and it appears that the test completes 
(and presumably kills the log receiver thread) before the log message is 
displayed. I'm calling (flush-output) after printf'ing the message to 
standard out.

The default logger does not have this problem. Is that because it doesn't 
use a separate thread to sync on the log messages and display them? Or am I 
misunderstanding how to best utilize a custom logger?

I've copy/pasted some code below for specifics.

Thanks,
Brian

(define axio-logger (make-logger 'axio))

(define/contract (axio-log-debug str)
  (-> string? any)
  (log-message axio-logger 'debug str #f))

...

(define/contract (axio-init-logger level)
  (-> symbol? any)
  (define axio-log-receiver (make-log-receiver axio-logger level))
  
  (thread
   (λ ()
 (let loop ()
   (define v (sync axio-log-receiver))
   (printf "[~a] ~a\n" 
   (vector-ref v 0)
   (vector-ref v 1))
   (flush-output)
   (loop)


(axio-log-debug "my log message")

-- 
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] Self reference in struct-copy ?

2018-12-12 Thread Brian Adkins
Rather than the following:

(struct descriptive-name (a b))
(define my-instance (descriptive-name 7 8))
(define y (struct-copy descriptive-name my-instance [a (+ 1 
(descriptive-name-a my-instance))]))

Would it be better to allow referring to struct fields as in the following?

(define y (struct-copy descriptive-name my-instance [a (+ 1 a)]))

Brian

-- 
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] JSON vs. normal Racket for simple serialization to database

2018-12-12 Thread Brian Adkins
In this particular case, the only purpose is saving/loading data to/from a 
db column. I have plenty of other uses for JSON, so I'm thankful for the 
Racket JSON library, but I lean toward simplicity when possible.

On Wednesday, December 12, 2018 at 10:35:24 AM UTC-5, Jon Zeppieri wrote:
>
> Postgres can index jsonb column data. Also, other languages will have an 
> easier time reading it. If neither of those matter for your case, then no.
>
> - Jon
>
>
> On Wed, Dec 12, 2018 at 10:26 AM Brian Adkins  > wrote:
>
>> I have some simple serialization needs. In Ruby, I would always serialize 
>> an object to JSON and store in a postgres text column. However, w/ Racket, 
>> it appears another option is to simply use read/write. Any reason not to 
>> use read/write for serialization instead of JSON?
>>
>> -- 
>> 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...@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.


[racket-users] JSON vs. normal Racket for simple serialization to database

2018-12-12 Thread Brian Adkins
I have some simple serialization needs. In Ruby, I would always serialize 
an object to JSON and store in a postgres text column. However, w/ Racket, 
it appears another option is to simply use read/write. Any reason not to 
use read/write for serialization instead of JSON?

-- 
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] Implications of stateless servlets & how/whether to avoid them

2018-11-30 Thread Brian Adkins
a function 
> from request to response, with some resource control. It doesn't 
> impose any programming style or other costs on you. I get the 
> impression from your comments that you are really nervous about some 
> sort of costs imposed by using Racket libraries and think you will get 
> some benefit by being "low-level". This is probably misguided and just 
> based on some misunderstandings. 
>
> Jay 
>
> 1. 
> https://github.com/racket/web-server/blob/master/web-server-lib/web-server/servlet-env.rkt#L156
>  
>
> On Fri, Nov 30, 2018 at 4:30 PM Brian Adkins  > wrote: 
> > 
> > I could be misreading the information in "3.2 Usage Considerations", but 
> it seemed like the modifications to my program were automatic, but maybe 
> that only happens when using #lang web-server or #lang web-server/base ? 
> > 
> > Regardless, I'm wondering if maybe I should just use (serve) instead of 
> (serve/servlet) since I'll likely be working at that level later anyway. In 
> that case, it looks like dispatch-lift:make is the main thing I need to get 
> things rolling. As a simple example: 
> > 
> > #lang racket 
> > (require web-server/web-server) 
> > (require web-server/http/response-structs) 
> > (require (prefix-in log: web-server/dispatchers/dispatch-log)) 
> > (require (prefix-in lift: web-server/dispatchers/dispatch-lift)) 
> > (require (prefix-in seq: web-server/dispatchers/dispatch-sequencer)) 
> > (require (prefix-in stat: web-server/dispatchers/dispatch-stat)) 
> > 
> > (define (controller request) 
> >   (response 
> >200 
> >#"OK" 
> >(current-seconds) 
> >TEXT/HTML-MIME-TYPE 
> >empty 
> >(λ (op) (write-bytes #"Hello, World!" 
> op 
> > 
> > (serve 
> >  #:dispatch (seq:make (log:make #:format log:extended-format 
> > #:log-path "development.log") ; log 
> request 
> >   (stat:make) ; print memory usage 
> >   (lift:make controller)) 
> >  #:port 8080) 
> > 
> > To be clear, it's not just continuations that I want to avoid, I'd also 
> like to avoid the changes that are described in section 3.2 above. 
> > 
> > 
> > On Friday, November 30, 2018 at 3:20:39 PM UTC-5, Jay McCarthy wrote: 
> >> 
> >> There's nothing wrong with ignoring the continuation support in the 
> >> Web server, either the native ones or stateless ones. If you do, I 
> >> recommend using something like `create-none-manager` [1]  as the 
> >> `#:manager` argument to `serve/servlet` so that you don't accidentally 
> >> start using them. The "too far" line is that you can't use 
> >> `send/suspend`. In the web-server/servlet/web [2] module, you just 
> >> want to use `send/back` and `with-errors-to-browser`, and no other 
> >> functions. 
> >> 
> >> Jay 
> >> 
> >> 1. 
> https://docs.racket-lang.org/web-server/servlet.html?q=none-manager#%28def._%28%28lib._web-server%2Fmanagers%2Fnone..rkt%29._create-none-manager%29%29
>  
> >> 2. 
> https://docs.racket-lang.org/web-server/servlet.html?q=send%2Fsuspend#%28part._web%29
>  
> >> On Fri, Nov 30, 2018 at 2:17 PM Brian Adkins  
> wrote: 
> >> > 
> >> > A while ago, I read Jay's response about how to use the Racket web 
> server w/o continuations here: 
> >> > 
> >> > 
> https://groups.google.com/forum/#!msg/racket-users/bTBj-RbMLDA/k80HNazuFAAJ 
> >> > 
> >> > At the time, I didn't dig very deeply into it and just assumed 
> avoiding web-server/servlet would be sufficient, but I just read through 
> the documentation on stateless servlets here: 
> >> > 
> >> > https://docs.racket-lang.org/web-server/stateless.html 
> >> > 
> >> > In particular, section 3.2, where it states things like: 
> >> > 
> >> > "All uses of letrec are removed and replaced with equivalent uses of 
> let and imperative features." 
> >> > 
> >> > "The program is defunctionalized with a serializable data-structure 
> for each lambda" 
> >> > 
> >> > "First, this process drastically changes the structure of your 
> program. It will create an immense number of lambdas and structures your 
> program did not normally contain. The performance implication of this has 
> not been studied with Racket." 
> >> > 
> >> > It seems like there is quite a bit of stuff going on to support 
> continuations with sta

Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2018-11-30 Thread Brian Adkins
I could be misreading the information in "3.2 Usage Considerations", but it 
seemed like the modifications to my program were automatic, but maybe that 
only happens when using #lang web-server or #lang web-server/base ?

Regardless, I'm wondering if maybe I should just use (serve) instead of 
(serve/servlet) since I'll likely be working at that level later anyway. In 
that case, it looks like dispatch-lift:make is the main thing I need to get 
things rolling. As a simple example:

#lang racket
(require web-server/web-server)
(require web-server/http/response-structs)
(require (prefix-in log: web-server/dispatchers/dispatch-log))
(require (prefix-in lift: web-server/dispatchers/dispatch-lift))
(require (prefix-in seq: web-server/dispatchers/dispatch-sequencer))
(require (prefix-in stat: web-server/dispatchers/dispatch-stat))

(define (controller request)
  (response
   200
   #"OK"
   (current-seconds)
   TEXT/HTML-MIME-TYPE
   empty
   (λ (op) (write-bytes #"Hello, World!" op

(serve
 #:dispatch (seq:make (log:make #:format log:extended-format
#:log-path "development.log") ; log request
  (stat:make) ; print memory usage
  (lift:make controller))
 #:port 8080)

To be clear, it's not just continuations that I want to avoid, I'd also 
like to avoid the changes that are described in section 3.2 above.


On Friday, November 30, 2018 at 3:20:39 PM UTC-5, Jay McCarthy wrote:
>
> There's nothing wrong with ignoring the continuation support in the 
> Web server, either the native ones or stateless ones. If you do, I 
> recommend using something like `create-none-manager` [1]  as the 
> `#:manager` argument to `serve/servlet` so that you don't accidentally 
> start using them. The "too far" line is that you can't use 
> `send/suspend`. In the web-server/servlet/web [2] module, you just 
> want to use `send/back` and `with-errors-to-browser`, and no other 
> functions. 
>
> Jay 
>
> 1. 
> https://docs.racket-lang.org/web-server/servlet.html?q=none-manager#%28def._%28%28lib._web-server%2Fmanagers%2Fnone..rkt%29._create-none-manager%29%29
>  
> 2. 
> https://docs.racket-lang.org/web-server/servlet.html?q=send%2Fsuspend#%28part._web%29
>  
> On Fri, Nov 30, 2018 at 2:17 PM Brian Adkins  > wrote: 
> > 
> > A while ago, I read Jay's response about how to use the Racket web 
> server w/o continuations here: 
> > 
> > 
> https://groups.google.com/forum/#!msg/racket-users/bTBj-RbMLDA/k80HNazuFAAJ 
> > 
> > At the time, I didn't dig very deeply into it and just assumed avoiding 
> web-server/servlet would be sufficient, but I just read through the 
> documentation on stateless servlets here: 
> > 
> > https://docs.racket-lang.org/web-server/stateless.html 
> > 
> > In particular, section 3.2, where it states things like: 
> > 
> > "All uses of letrec are removed and replaced with equivalent uses of let 
> and imperative features." 
> > 
> > "The program is defunctionalized with a serializable data-structure for 
> each lambda" 
> > 
> > "First, this process drastically changes the structure of your program. 
> It will create an immense number of lambdas and structures your program did 
> not normally contain. The performance implication of this has not been 
> studied with Racket." 
> > 
> > It seems like there is quite a bit of stuff going on to support 
> continuations with stateless servlets. Since I'm not planning on using 
> continuations at all, I'm not sure I want the changes to my code described 
> in section 3.2. 
> > 
> > I'm coming from an entirely stateless architecture w/ Ruby/Rails, and I 
> was planning on using a similar style w/ Racket, so I'm just trying to get 
> a feel for how low in the stack I need to be to avoid the extra 
> functionality that I don't want/need. Eventually, I'm planning on resuming 
> work on a web app framework in Racket that steals my favorite things from 
> Rails & other frameworks, and leaves out the cruft. For that, I expect I'll 
> need to base my code on lower levels, but for my current app, I don't have 
> time to create too much infrastructure, so I'd like to leverage basic 
> things from built-in Racket functionality without going "too far", and I'm 
> not even able to articulate well where the "too far" line is. 
> > 
> > Thanks, 
> > Brian 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more op

Re: [racket-users] Re: Signal handling (or alternative)

2018-11-30 Thread Brian Adkins
Awesome - thanks! I wonder if using serve, instead of serve/servlet, may 
also avoid the extra functionality described in "Stateless Servlets" that I 
mentioned in another thread here:

https://groups.google.com/forum/#!topic/racket-users/fc0mRI-empE

On Friday, November 30, 2018 at 1:57:00 PM UTC-5, Bogdan Popa wrote:
>
>
> Brian Adkins writes: 
>
> > I just did a quick test, and "kill " will stop the Racket web 
> server, 
> > but not gracefully. In other words, it doesn't allow the current request 
> to 
> > finish. Maybe another signal will gracefully stop it? 
>
> I personally run the server with serve[1] which runs it in a background 
> thread and I keep a reference to the returned stopper function and 
> finally do something along the lines of 
>
> (with-handlers ([exn:break? (lambda (e) (stopper))]) 
>   (sync/enable-break never-evt)) 
>
> in my main thread.  As I understand it[2], exn:break? will be truthy for 
> SIGINT, SIGTERM and SIGHUP (though there are also the exn:break:hang-up? 
> and exn:break:terminate? predicates) on UNIX, so this should "catch" all 
> of those and gracefully terminate my server. 
>
> [1]: 
> https://docs.racket-lang.org/web-server-internal/web-server.html?q=serve#%28def._%28%28lib._web-server%2Fweb-server..rkt%29._serve%29%29
>  
> [2]: https://docs.racket-lang.org/reference/breakhandler.html?q=breaks 
>

-- 
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] Implications of stateless servlets & how/whether to avoid them

2018-11-30 Thread Brian Adkins
A while ago, I read Jay's response about how to use the Racket web server 
w/o continuations here:

https://groups.google.com/forum/#!msg/racket-users/bTBj-RbMLDA/k80HNazuFAAJ

At the time, I didn't dig very deeply into it and just assumed avoiding 
web-server/servlet would be sufficient, but I just read through the 
documentation on stateless servlets here:

https://docs.racket-lang.org/web-server/stateless.html

In particular, section 3.2, where it states things like:

"All uses of letrec are removed and replaced with equivalent uses of let 
and imperative features."

"The program is defunctionalized with a serializable data-structure for 
each lambda"

"First, this process drastically changes the structure of your program. It 
will create an immense number of lambdas and structures your program did 
not normally contain. The performance implication of this has not been 
studied with Racket."

It seems like there is quite a bit of stuff going on to support 
continuations with stateless servlets. Since I'm not planning on using 
continuations at all, I'm not sure I want the changes to my code described 
in section 3.2.

I'm coming from an entirely stateless architecture w/ Ruby/Rails, and I was 
planning on using a similar style w/ Racket, so I'm just trying to get a 
feel for how low in the stack I need to be to avoid the extra functionality 
that I don't want/need. Eventually, I'm planning on resuming work on a web 
app framework in Racket that steals my favorite things from Rails & other 
frameworks, and leaves out the cruft. For that, I expect I'll need to base 
my code on lower levels, but for my current app, I don't have time to 
create too much infrastructure, so I'd like to leverage basic things from 
built-in Racket functionality without going "too far", and I'm not even 
able to articulate well where the "too far" line is.

Thanks,
Brian

-- 
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] Re: Signal handling (or alternative)

2018-11-30 Thread Brian Adkins
I just did a quick test, and "kill " will stop the Racket web server, 
but not gracefully. In other words, it doesn't allow the current request to 
finish. Maybe another signal will gracefully stop it?

On Friday, November 30, 2018 at 1:36:04 PM UTC-5, Brian Adkins wrote:
>
> The Unicorn app server uses signals to perform a graceful restart of the 
> worker processes. For example: "kill -USR2 ". This seems like a 
> reasonable approach, so my first though was to use something similar for my 
> Racket app server processes.
>
> I found Tony's unix-signals package, but the introduction states, "Be 
> warned that attempting to receive certain signals used by the Racket 
> runtime is dangerous, as the code here will conflict with the code in 
> Racket itself." I'm guessing this does not apply to SIGUSR2. I guess the 
> idea would be to start a thread & block on (read-signal).
>
> Are there alternatives I should consider for this functionality? Given the 
> Racket app server processes are listening for HTTP requests, I could use 
> HTTP to accomplish this. The Racket app server processes are not exposed to 
> the internet, from the internet, they're only accessible via nginx.
>
> Can I use signals and handle them via Racket's exception mechanism? For 
> example, will "kill -HUP " result in an exn:break:hang-up exception 
> being raised?
>
> Thanks,
> Brian
>

-- 
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] Signal handling (or alternative)

2018-11-30 Thread Brian Adkins
The Unicorn app server uses signals to perform a graceful restart of the 
worker processes. For example: "kill -USR2 ". This seems like a 
reasonable approach, so my first though was to use something similar for my 
Racket app server processes.

I found Tony's unix-signals package, but the introduction states, "Be 
warned that attempting to receive certain signals used by the Racket 
runtime is dangerous, as the code here will conflict with the code in 
Racket itself." I'm guessing this does not apply to SIGUSR2. I guess the 
idea would be to start a thread & block on (read-signal).

Are there alternatives I should consider for this functionality? Given the 
Racket app server processes are listening for HTTP requests, I could use 
HTTP to accomplish this. The Racket app server processes are not exposed to 
the internet, from the internet, they're only accessible via nginx.

Can I use signals and handle them via Racket's exception mechanism? For 
example, will "kill -HUP " result in an exn:break:hang-up exception 
being raised?

Thanks,
Brian

-- 
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] Re: What is the best way to daemonize a Racket program on linux?

2018-11-29 Thread Brian Adkins
I really appreciate all the help I've received on this thread! The Racket 
community has been fantastic.

I have my proof-of-concept working for the web infrastructure - no need for 
a Unicorn/Puma-like app, no need for monit, no need to daemonize - just 
systemd to manage N Racket processes, and nginx in front to reverse proxy 
to the Racket workers.

I ended up with this systemd service file:

--- snip ---
[Unit]
Description=Racket hello world %i

[Service]
WorkingDirectory=/home/deploy/appname/current/
ExecStart=/usr/local/bin/racket /home/deploy/appname/current/hello.rkt %i
Restart=always

[Install]
WantedBy=multi-user.target
--- snip ---

Enable 2 workers:  sudo systemctl enable hello@{1..2}
Start them: sudo systemctl start hello\@{1..2}
Check status:  sudo systemctl status hello\@{1..2}

They auto start at boot time, and they auto restart if killed or they crash.

I hacked up a quick test using a command line argument to specify the port 
and log file (I know there are more elegant solutions, but I was in a hurry 
to verify it).  It's possible that using a single log file for all the 
workers will "just work", but I wasn't sure, so I use one log file per 
process for now. I suppose there are pros/cons to each approach.

(module+ main
(define instance-id (string->number (vector-ref 
(current-command-line-arguments) 0)))
(define port (+ 8000 instance-id))
(serve/servlet
  dispatcher
  #:log-file (format "hello~a.log" instance-id)
  #:stateless? #t
  #:port port
  #:command-line? #t
  #:file-not-found-responder not-found
  #:launch-browser? #f
  #:servlet-regexp #rx""))

nginx config includes:

--- snip ---
...
  upstream racket {
least_conn;
server localhost:8001;
server localhost:8002;
  }
...
proxy_pass http://racket;
--- snip ---

Now I can get on to the fun part of porting my Ruby/Rails app, and then 
extending it.


On Thursday, November 29, 2018 at 5:17:38 PM UTC-5, Philip McGrath wrote:
>
> To give you an example, here's a very basic systemd file that I use to run 
> a Racket web server: 
>
> /etc/systemd/system/ricoeur-portal.service
> [Unit]
> Description=Digital Ricoeur portal web server
>
> [Service]
> User=ricoeurd
> Group=ricoeurd
> AmbientCapabilities=CAP_NET_BIND_SERVICE
> WorkingDirectory=/home/ubuntu/ricoeur-portal/
> ExecStart=/usr/local/bin/ricoeur-portal --production
>
> [Install]
> WantedBy=multi-user.target
>
> It's particularly nice from a security perspective that 
> `CAP_NET_BIND_SERVICE` makes it easy to run as a user with minimal 
> privileges and still be able to bind to ports 80 and 443.
>
> -Philip
>
>
> On Thu, Nov 29, 2018 at 5:09 PM Alex Harsanyi  > wrote:
>
>>
>>
>> On Thursday, November 29, 2018 at 11:17:38 PM UTC+8, Brian Adkins wrote:
>>>
>>> I'm running Ubuntu 18.04 LTS, so I do have systemd. Just to clarify, are 
>>> you stating that systemd will take a program designed to run as a 
>>> foreground process and run it in the background automatically? 
>>>
>>
>> Yes.
>>  
>>
>>> I was planning on using monit to monitor/restart/etc. a set of Racket 
>>> processes, but maybe systemd will do everything I need such as restarting 
>>> one if it crashes.
>>>
>>> On Wednesday, November 28, 2018 at 10:45:59 PM UTC-5, Alex Harsanyi 
>>> wrote:
>>>>
>>>>
>>>> If your Linux installation has systemd, you can create a service file 
>>>> for your application -- this way, systemd will manage the application as a 
>>>> server or daemon.  Systemd will even redirect stderr messages to the 
>>>> system 
>>>> log.
>>>>
>>>> Alex.
>>>>
>>>> On Thursday, November 29, 2018 at 10:56:25 AM UTC+8, Brian Adkins wrote:
>>>>>
>>>>> I briefly looked at the daemonize package on Ubuntu linux, but 
>>>>> couldn't get it to work properly. I found the following Rosetta Code page:
>>>>>
>>>>> https://rosettacode.org/wiki/Run_as_a_daemon_or_service#Racket
>>>>>
>>>>> So, I just tried the code in that example, and it seems to work fine:
>>>>>
>>>>> (module+ main
>>>>> * ((get-ffi-obj 'daemon #f (_fun _int _int -> _int)) 0 0)*
>>>>>  (serve/servlet
>>>>>   dispatcher
>>>>>   #:log-file "hello.log"
>>>>>   #:stateless? #t
>>>>>   #:port 6995
>>>>>   #:command-line? #t
>>>>>   #:file-not-found-responder not-fou

Re: [racket-users] Re: What is the best way to daemonize a Racket program on linux?

2018-11-29 Thread Brian Adkins
Thanks. I think that's the approach I'll take. I don't think I'll need to 
use monit at all then. I will need to start N Racket processes though. I 
found this article that may work for me:

https://serverfault.com/questions/730239/start-n-processes-with-one-systemd-service-file

I don't think I'll try the SO_REUSEPORT idea at this point, so I'll need 
each of the N Racket servers to listen on a different port and have nginx 
reverse proxy to them.

I think by having systemd manage the N processes separately, I can get 
auto-restart etc. for free w/o having to code up a master Racket process 
supervising N worker processes.

On Thursday, November 29, 2018 at 5:17:38 PM UTC-5, Philip McGrath wrote:
>
> To give you an example, here's a very basic systemd file that I use to run 
> a Racket web server: 
>
> /etc/systemd/system/ricoeur-portal.service
> [Unit]
> Description=Digital Ricoeur portal web server
>
> [Service]
> User=ricoeurd
> Group=ricoeurd
> AmbientCapabilities=CAP_NET_BIND_SERVICE
> WorkingDirectory=/home/ubuntu/ricoeur-portal/
> ExecStart=/usr/local/bin/ricoeur-portal --production
>
> [Install]
> WantedBy=multi-user.target
>
> It's particularly nice from a security perspective that 
> `CAP_NET_BIND_SERVICE` makes it easy to run as a user with minimal 
> privileges and still be able to bind to ports 80 and 443.
>
> -Philip
>
>
> On Thu, Nov 29, 2018 at 5:09 PM Alex Harsanyi  > wrote:
>
>>
>>
>> On Thursday, November 29, 2018 at 11:17:38 PM UTC+8, Brian Adkins wrote:
>>>
>>> I'm running Ubuntu 18.04 LTS, so I do have systemd. Just to clarify, are 
>>> you stating that systemd will take a program designed to run as a 
>>> foreground process and run it in the background automatically? 
>>>
>>
>> Yes.
>>  
>>
>>> I was planning on using monit to monitor/restart/etc. a set of Racket 
>>> processes, but maybe systemd will do everything I need such as restarting 
>>> one if it crashes.
>>>
>>> On Wednesday, November 28, 2018 at 10:45:59 PM UTC-5, Alex Harsanyi 
>>> wrote:
>>>>
>>>>
>>>> If your Linux installation has systemd, you can create a service file 
>>>> for your application -- this way, systemd will manage the application as a 
>>>> server or daemon.  Systemd will even redirect stderr messages to the 
>>>> system 
>>>> log.
>>>>
>>>> Alex.
>>>>
>>>> On Thursday, November 29, 2018 at 10:56:25 AM UTC+8, Brian Adkins wrote:
>>>>>
>>>>> I briefly looked at the daemonize package on Ubuntu linux, but 
>>>>> couldn't get it to work properly. I found the following Rosetta Code page:
>>>>>
>>>>> https://rosettacode.org/wiki/Run_as_a_daemon_or_service#Racket
>>>>>
>>>>> So, I just tried the code in that example, and it seems to work fine:
>>>>>
>>>>> (module+ main
>>>>> * ((get-ffi-obj 'daemon #f (_fun _int _int -> _int)) 0 0)*
>>>>>  (serve/servlet
>>>>>   dispatcher
>>>>>   #:log-file "hello.log"
>>>>>   #:stateless? #t
>>>>>   #:port 6995
>>>>>   #:command-line? #t
>>>>>   #:file-not-found-responder not-found
>>>>>   #:launch-browser? #f
>>>>>   #:servlet-regexp #rx""))
>>>>>
>>>>> I'm just wondering if there is a better way to accomplish this since 
>>>>> it feels a bit kludgy to me.
>>>>>
>>>>> Thanks,
>>>>> Brian
>>>>>
>>>>> -- 
>> 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...@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.


[racket-users] Re: What is the best way to daemonize a Racket program on linux?

2018-11-29 Thread Brian Adkins
Just out of curiosity, why do you feel using daemon(3) is not a great idea? 
I'm not disagreeing, just curious about your reasons.

On Thursday, November 29, 2018 at 5:54:42 AM UTC-5, Tony Garnock-Jones 
wrote:
>
> IMO using daemon(3) is not a great idea. Instead, I like to use djb's 
> daemontools https://cr.yp.to/daemontools.html to supervise my processes. 
> For example, see the `README` and the `run` script in 
> https://github.com/tonyg/racket-reloadable-example.
>
> Tony
>
>>
>>

-- 
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] Re: What is the best way to daemonize a Racket program on linux?

2018-11-29 Thread Brian Adkins
I'm running Ubuntu 18.04 LTS, so I do have systemd. Just to clarify, are 
you stating that systemd will take a program designed to run as a 
foreground process and run it in the background automatically? I was 
planning on using monit to monitor/restart/etc. a set of Racket processes, 
but maybe systemd will do everything I need such as restarting one if it 
crashes.

On Wednesday, November 28, 2018 at 10:45:59 PM UTC-5, Alex Harsanyi wrote:
>
>
> If your Linux installation has systemd, you can create a service file for 
> your application -- this way, systemd will manage the application as a 
> server or daemon.  Systemd will even redirect stderr messages to the system 
> log.
>
> Alex.
>
> On Thursday, November 29, 2018 at 10:56:25 AM UTC+8, Brian Adkins wrote:
>>
>> I briefly looked at the daemonize package on Ubuntu linux, but couldn't 
>> get it to work properly. I found the following Rosetta Code page:
>>
>> https://rosettacode.org/wiki/Run_as_a_daemon_or_service#Racket
>>
>> So, I just tried the code in that example, and it seems to work fine:
>>
>> (module+ main
>> * ((get-ffi-obj 'daemon #f (_fun _int _int -> _int)) 0 0)*
>>  (serve/servlet
>>   dispatcher
>>   #:log-file "hello.log"
>>   #:stateless? #t
>>   #:port 6995
>>   #:command-line? #t
>>   #:file-not-found-responder not-found
>>   #:launch-browser? #f
>>   #:servlet-regexp #rx""))
>>
>> I'm just wondering if there is a better way to accomplish this since it 
>> feels a bit kludgy to me.
>>
>> Thanks,
>> Brian
>>
>>

-- 
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] What is the best way to daemonize a Racket program on linux?

2018-11-28 Thread Brian Adkins
I briefly looked at the daemonize package on Ubuntu linux, but couldn't get 
it to work properly. I found the following Rosetta Code page:

https://rosettacode.org/wiki/Run_as_a_daemon_or_service#Racket

So, I just tried the code in that example, and it seems to work fine:

(module+ main
* ((get-ffi-obj 'daemon #f (_fun _int _int -> _int)) 0 0)*
 (serve/servlet
  dispatcher
  #:log-file "hello.log"
  #:stateless? #t
  #:port 6995
  #:command-line? #t
  #:file-not-found-responder not-found
  #:launch-browser? #f
  #:servlet-regexp #rx""))

I'm just wondering if there is a better way to accomplish this since it 
feels a bit kludgy to me.

Thanks,
Brian

-- 
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] Racket application servers

2018-11-28 Thread Brian Adkins
I finally got a very simple, "hello world", Racket web app up and running, 
and I'm very encouraged with the performance. I just started a single 
Racket instance and proxy to it from nginx. I have it running on an AWS EC2 
instance, and running the Apache Benchmark (ab) utility on my laptop as 
follows reported 300 requests per second (38 concurrent requests, 1000 
requests total):

ab -c 38 -n 1000 http://hello-app

Granted, the "hello world" app is doing the bare minimum (no database 
connection, minimal processing, etc., but it is logging requests), but the 
fact that I'm getting 300 req/sec including proxying through nginx with one 
single-threaded Racket process (& zero time spent tuning) is great news! Of 
course, over a decade with Ruby may have lowered my performance bar 
somewhat ;)

I can't wait to get a more representative test running.

On Monday, November 26, 2018 at 10:38:23 AM UTC-5, Brian Adkins wrote:
>
> The current Ruby/Rails app will max out at least one core at times now. I 
> realize Racket should be faster, but I expect I'll still need more than a 
> single core for the app as the volume will be going up significantly in 
> January, and as you mentioned, there are some other benefits to a 
> multi-process architecture.
>
> On Sunday, November 25, 2018 at 11:26:11 AM UTC-5, Greg Hendershott wrote:
>>
>> I just want to point out the possibility that your Racket web app 
>> might not be CPU-bound. Some "generic" web sites are IO-bound. Blocked 
>> on IO for the HTTP requests and responses. Blocked on IO talking to a 
>> database server like Postgres. 
>>
>> In cases like that, you might not need more than one process. (Indeed 
>> you might even get away with running on a t2.micro instance, which 
>> throttles horribly after a short CPU burst, because you never come 
>> close to that threshold even under your maximum traffic loads.) 
>>
>> It's a real possibility you might want to measure/see, first. Of 
>> course it depends on how much work your Racket web app does (itself, 
>> not farmed out to DB or other out-of-process servers), as well as on 
>> the traffic loads you expect. 
>>
>> Having two or more servers might be convenient for non-load reasons. 
>> For updates (to let the old "drain" as you described, or blue/green 
>> deploys, etc.).  Or for fail-over (although I'm not sure 2 procs on 
>> same box is the way to go, if you even really need many 9s (many sites 
>> really don't if we're being honest with ourselves)). 
>>
>

-- 
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] Racket application servers

2018-11-26 Thread Brian Adkins
Very interesting. I'll check out your project - thanks for mentioning it.

On Monday, November 26, 2018 at 4:42:15 AM UTC-5, Jérôme Martin wrote:
>
> Just so you know, I started some months ago a Racket project that would 
> help monitor different Racket web servers and load-balance them, using 
> systemd-nspawn as a native container system, and an optional
>  nginx server to load balance everything, serve static content and cache 
> dynamic one.
>
> It's called Bonny: https://github.com/euhmeuh/bonny
>
> It's in a very early stage right now but I'm actively working on it so 
> that I can deploy and monitor my servers without having to rely on some big 
> overkill container app du jour.
>
> I'd be really glad to talk about some approaches you use and what seems 
> the easiest to implement. My main objectives are minimalism, use as much 
> native systems as possible, and as much Racket as possible.
>
> Plus, containers in Bonny are called "pirates" (cause you're "shipping 
> them", ahah).
>

-- 
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] Racket application servers

2018-11-26 Thread Brian Adkins
The current Ruby/Rails app will max out at least one core at times now. I 
realize Racket should be faster, but I expect I'll still need more than a 
single core for the app as the volume will be going up significantly in 
January, and as you mentioned, there are some other benefits to a 
multi-process architecture.

On Sunday, November 25, 2018 at 11:26:11 AM UTC-5, Greg Hendershott wrote:
>
> I just want to point out the possibility that your Racket web app 
> might not be CPU-bound. Some "generic" web sites are IO-bound. Blocked 
> on IO for the HTTP requests and responses. Blocked on IO talking to a 
> database server like Postgres. 
>
> In cases like that, you might not need more than one process. (Indeed 
> you might even get away with running on a t2.micro instance, which 
> throttles horribly after a short CPU burst, because you never come 
> close to that threshold even under your maximum traffic loads.) 
>
> It's a real possibility you might want to measure/see, first. Of 
> course it depends on how much work your Racket web app does (itself, 
> not farmed out to DB or other out-of-process servers), as well as on 
> the traffic loads you expect. 
>
> Having two or more servers might be convenient for non-load reasons. 
> For updates (to let the old "drain" as you described, or blue/green 
> deploys, etc.).  Or for fail-over (although I'm not sure 2 procs on 
> same box is the way to go, if you even really need many 9s (many sites 
> really don't if we're being honest with ourselves)). 
>

-- 
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.


  1   2   3   >