RE: [racket-users] custom-print called twice?

2015-09-02 Thread Jos Koot
Thanks for the answer, rapid as always.
Jos 

-Original Message-
From: Matthew Flatt [mailto:mfl...@cs.utah.edu] 
Sent: miércoles, 02 de septiembre de 2015 2:11
To: Jos Koot
Cc: 'racket users'; jos.k...@gmail.com
Subject: Re: [racket-users] custom-print called twice?

The first call is to detect sharing, and the second time is to actually
print.

For example, if you change `(constr 'y)` to

  (define b (box #f))
  (set-box! b (constr b))
  b

then you'll see that the output starts with "#0=", because the first
pass detected that a "#0#" will be needed.

At Wed, 2 Sep 2015 00:45:43 +0200, "Jos Koot" wrote:
> Question:
>  
> why is in the following example the custom-printer called twice?
>  
> #lang racket
>  
> (define n 0)
>  
> (letrec-values
>  (((printer)
>(λ (obj port mode)
> (set! n (add1 n))
> (fprintf port "#" (name obj
>   ((id constr pred acc mut)
>(make-struct-type 'x #f 1 0 #f
> (list (cons prop:custom-write printer
>   ((name) (make-struct-field-accessor acc 0 'name)))
>  (constr 'y)) ; -> #
>  
> n ; -> 2
>  
> ;Done with
> ;DrRacket, version 6.2.0.5--2015-07-06(d6fa581/a) [3m].
> ;Language: racket [custom]; memory limit: 2000 MB.
>  
> Best wishes, Jos Koot
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email 
> to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Class constracts and equality

2015-09-02 Thread Konrad Hinsen
Hi Asumu,

 > In particular, the code for class contracts explicitly installs a value for 
 > the
 > inspector that doesn't allow inspection (there's a comment saying "No
 > inspection").

Thanks for exploring this, at least I now know what's going on!

 > But maybe it's worth revisiting this part of the design. I can look into if
 > it's possible to have the contracted class inherit the inspect of the 
 > original
 > and whether that causes any problems.

That would be great, but if that's not possible, the next-best option would
be to document the restriction.

For now I'll remove the contract, as equality checking is clearly more
important for me.

Konrad.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Lost in ellipsis depths

2015-09-02 Thread Matthias Felleisen

I think you want either this:

(syntax-parse #'(foo a b c)
 [(f:id s:id ...)
  (map (λ (s) (format-id #'f "foo-~a" s)) (syntax->list #'(s ...)))])

or that:

(syntax-parse #'(foo a b c)
 [(f:id s:id ...)
  #'(list (format-id #'f "foo-~a" #'s) ...)])



On Sep 2, 2015, at 7:00 AM, Konrad Hinsen  wrote:

> Hi everyone,
> 
> I am working on what I consider a simple macro, but after reading all
> of the macro-related documentation twice, I still don't see how to do
> this.
> 
> I want to transform
> 
>  (foo a b c)
> 
> to
> 
>  (list foo-a foo-b foo-c)
> 
> Here is my best attempt (using syntax/parse):
> 
> (syntax-parse #'(foo a b c)
>  [(f:id s:id ...)
>   (list (format-id #'f "foo-~a" #'s) ...)])
> 
> This yields the error message
> 
>  syntax: missing ellipsis with pattern variable in template
> 
> In fact, what I want is do something like map over the ellipsis pattern,
> but I haven't seen any example for doing this.
> 
> Help, please!
> 
> Thanks in advance,
>  Konrad.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] http response 204 (no content) with content-encoding "gzip"

2015-09-02 Thread 'John Clements' via Racket Users
I’m interacting with an HTTP server that recently responded with status

#"HTTP/1.1 204 No Content”
and headers

'(#"Content-Encoding: gzip"
  #"Request-Id: ec2f6fe5-5191-11e5-8007-”
  #"X-Influxdb-Version: 0.9.3”
  #"Date: Wed, 02 Sep 2015 16:44:48 GMT”
  #"Connection: close”)

using http-sendrecv/url with default arguments results in an error (and not a 
terribly sensible one), because it tries to gunzip the empty input.

I conjecture that this is a reasonable response from an HTTP server, and that 
in this situation http-sendrecv/url (and more specifically http-conn-recv!) 
should not signal an error, but just return the empty port. In fact, it appears 
to me that it should probably always be the case that an input port for which 
peek-byte returns # should be returned directly rather than being handed 
off to gunzip.  If this seems like the right approach, I’ll make a pull request.

Thanks!

John



-- 
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] http response 204 (no content) with content-encoding "gzip"

2015-09-02 Thread Greg Hendershott
Certain status codes "MUST NOT" include a response body, including 204 [0].

For those, you could say not even a `peek-byte` is necessary. Although
I guess there wouldn't be any harm.

Definitely for the other variants -- even "SHOULD NOT" -- then
peek-byte makes sense.


[0]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html


On Wed, Sep 2, 2015 at 1:15 PM, 'John Clements' via Racket Users
 wrote:
> I’m interacting with an HTTP server that recently responded with status
>
> #"HTTP/1.1 204 No Content”
> and headers
>
> '(#"Content-Encoding: gzip"
>   #"Request-Id: ec2f6fe5-5191-11e5-8007-”
>   #"X-Influxdb-Version: 0.9.3”
>   #"Date: Wed, 02 Sep 2015 16:44:48 GMT”
>   #"Connection: close”)
>
> using http-sendrecv/url with default arguments results in an error (and not a 
> terribly sensible one), because it tries to gunzip the empty input.
>
> I conjecture that this is a reasonable response from an HTTP server, and that 
> in this situation http-sendrecv/url (and more specifically http-conn-recv!) 
> should not signal an error, but just return the empty port. In fact, it 
> appears to me that it should probably always be the case that an input port 
> for which peek-byte returns # should be returned directly rather than 
> being handed off to gunzip.  If this seems like the right approach, I’ll make 
> a pull request.
>
> Thanks!
>
> John
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Interaction between break and custodian-box

2015-09-02 Thread Matthew Flatt
I've pushed a repair for the bug --- and I'm glad you found a
workaround meanwhile. Thanks for the report!

At Wed, 2 Sep 2015 18:48:32 -0400, Greg Hendershott wrote:
> Oops, I'd meant to copy the list.
> 
> On Wed, Sep 2, 2015 at 6:46 PM, Greg Hendershott
>  wrote:
> > Thanks for the quick reply!
> >
> > On Wed, Sep 2, 2015 at 5:28 PM, Matthew Flatt  wrote:
> >> That looks like a bug in the scheduler to me. I don't think it's
> >> specific to `custodian-box`, but to `sync` and any event that is not
> >> ultimately backed by a channel or semaphore. (For example, `alarm-evt`
> >> also seems to trigger the problem.)
> >
> > With that hint, I tried adding a level of indirection -- a thread that
> > can sync on the custodian box, and put to a new, additional channel:
> >
> >   (define repl-cust-box-channel (make-channel))
> >   (define repl-cust-box-thread (thread (λ ()
> >  (let loop ()
> >(sync repl-cust-box)
> >(channel-put 
> > repl-cust-box-channel
> > 'memory-limit)
> >(loop)
> >
> > That way the main sync can be on two events backed by channels:
> >
> >(match (sync the-channel repl-cust-box-channel)
> >  ['memory-limit
> >   (displayln "Exceeded memory limit")
> >   'stop]
> >  [msg msg])
> >
> > And that seems to do the trick, at least in my distilled example.  I
> > do want to test in the real/full code, as well as think about any
> > lurking gotchas.  (Also, come to think of it, I can probably use the
> > one channel for both purposes.)
> >
> > Even if there's a scheduler bug that you might fix, I'm happy if there
> > is some work-around like this, because racket-mode is still aiming to
> > support Racket versions as old as 5.3.5.
> >
> > Thanks again.

-- 
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] can # structures be made transparent?

2015-09-02 Thread Robby Findler
I thought it was exposed as a function, not as a constructor.

Maybe there's not much difference.

I guess I don't really mind. It hasn't changed in a long time. Sorry
for the noise. PR away! :)

Robby

On Wed, Sep 2, 2015 at 6:09 PM, 'John Clements' via Racket Users
 wrote:
>
>> On Sep 2, 2015, at 4:06 PM, Robby Findler  
>> wrote:
>>
>> I was worrying because the internal representation may change (again) so 
>> exposing the real constructor doesn't seem wise. But making a printer print 
>> what you want (or using selectors to check if it comes to that) seems okay.
>
> But it’s already exposed….(and documented).
>
> John
>
>>
>> Robby
>>
>> On Wednesday, September 2, 2015, 'John Clements' via Racket Users 
>>  wrote:
>>
>> > On Sep 2, 2015, at 3:59 PM, Robby Findler  
>> > wrote:
>> >
>> > It makes sense to me to make a printer that uses URL->string.
>>
>> Actually, I kind of don’t want that...
>>
>> Here’s my use case:
>>
>> I have a url string, "http://localhost:8086/query?db=mydb”. I want to add 
>> more query parameters to it. Rather than fussing with the string syntax, I’d 
>> like to just formulate the whole thing as a url, as in
>>
>> (make-url “http” “localhost” 8086 “/query” ‘((db “mydb”)))
>>
>> … but I’m not sure which ones should be byte strings, or whether the initial 
>> slash appears in the path, or whether the query components are an 
>> association list, etc.
>>
>> This is exactly the kind of thing that I would see easily if I could just 
>> write
>>
>> (string->url "http://localhost:8086/query?db=mydb”)
>>
>> … and see something like
>>
>> (url “http” etc. etc.)
>>
>> If it gets converted back to a string, I’m back to square one.
>>
>> Does this make sense?
>>
>> John
>>
>>
>>
>> >
>> > On Wednesday, September 2, 2015, 'John Clements' via Racket Users 
>> >  wrote:
>> > It appears to me that the # structure (as e.g. from net/url) is 
>> > opaque. Is there any good reason for this? It’s kind of a pain (the 
>> > default printer doesn’t show me the fields), and I don’t see any good 
>> > reason for it, especially given the existence of url->string. I’d be happy 
>> > to formulate this as a pull request...
>> >
>> > John Clements
>> >
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to racket-users+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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] Official Docker images for Racket

2015-09-02 Thread Rickard Andersson
I've previously tried to minimize the build without any success, so if you 
can make a base image using only busybox or alpine linux without any 
problems that'd obviously be preferable.


On Wed, 2 Sep 2015, Asumu Takikawa wrote:


On 2015-09-02 15:35:25 -0700, Jack Firth wrote:

I do a lot of Racket development in Docker, and it's a pretty big pain.
There's a handful of images on Docker Hub but they're pretty unmaintained,
usually lag behind a version or two, tend to be built off an unnecessarily
large base image like ubuntu, don't offer a snapshot build, and don't offer
"minimal Racket" versions. I'd like to work on this and add some Racket
images to the Official images like other languages have. Has anyone else
worked on this?


That sounds great and if you put Racket images up I would happily use them.

I did look into building images on Dockerhub a while ago and had trouble
getting builds to finish (ran out of memory), but it looks like they have
improved the infrastructure since then.

Cheers,
Asumu

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Interaction between break and custodian-box

2015-09-02 Thread Greg Hendershott
When you break an expression in the REPL, currently racket-mode takes
you out of the module/environment. I want to change that:

https://github.com/greghendershott/racket-mode/issues/153

To do so, instead of grabbing the break using `with-handlers`, I'm
using `call-with-exception-handler` and the `continue` filed of
`exn:break`.

But I'm experiencing a weird interaction between breaks and sync-ing
on a custodian-box. (It took me awhile to narrow down the problem to
the custodian-box.) Consider this highly distilled version program.
Note that `repl-cust-box` commented out in the sync call, to show an
exmaple where the problem is NOT present:

--- channel.rkt ---

#lang racket/base

(require racket/match)

(define the-channel (make-channel))

(define (prompt-read)
  (display "PROMPT> ")
  (define in ((current-get-interaction-input-port)))
  (define stx ((current-read-interaction) (object-name in) in))
  (syntax-case stx ()
[(uq cmd)
 (and (eq? 'unquote (syntax-e #'uq))
  (eq? 'rerun   (syntax-e #'cmd)))
 (void (channel-put the-channel 'rerun)
   (sync never-evt))]
[_ stx]))

(define (run)
  (define repl-cust (make-custodian))
  (define repl-cust-box (make-custodian-box repl-cust #t))
  (custodian-limit-memory repl-cust (* 8 1024 1024) repl-cust)
  (define repl-thread
(thread
 (λ ()
   (parameterize ([current-custodian repl-cust]
  [current-namespace (make-base-namespace)]
  [current-prompt-read prompt-read])
 (read-eval-print-loop)

  (define msg
(call-with-exception-handler
 (λ (e)
   (match e
 [(exn:break msg marks continue) (break-thread repl-thread) (continue)]
 [e e]))
 (λ ()
   (match (sync the-channel #;repl-cust-box)
 [(? custodian-box?)
  (displayln "Exceeded memory limit")
  'stop]
 [msg msg]

  (displayln msg)
  (custodian-shutdown-all repl-cust)
  (run))

(run)

---


You get this good interaction:

$ racket channel.rkt
PROMPT> (define x 42)
PROMPT> x
42
PROMPT> (sleep 100)
  C-c C-cuser break
  context...:
   /usr/racket/collects/racket/private/misc.rkt:87:7
PROMPT> x
42
PROMPT> ,rerun
rerun
PROMPT> x
x: undefined;
 cannot reference undefined identifier
  context...:
   /usr/racket/collects/racket/private/misc.rkt:87:7
PROMPT> (exit)

In other words, a C-c break will interrupt the program, but maintain
the environment, e.g. x remains defined (good).

The ,rerun command will restart with a fresh environment, e.g. x is
now undefined (good).



Great. But in channel.rkt, now change the line:

   (match (sync the-channel #;repl-cust-box)

to:

   (match (sync the-channel repl-cust-box)

So the sync now also includes the repl-cust-box event.

Now I get this interaction:

$ racket channel.rkt
PROMPT> (define x 42)
PROMPT> x
42
PROMPT> (sleep 100)
  C-c C-cuser break
  context...:
   /usr/racket/collects/racket/private/misc.rkt:87:7
PROMPT> x
42
PROMPT> ,rerun

Here it "hangs". (This only happens if there has been at least one C-c
break previously in the REPL session, as above.) If we now C-c, it
breaks at the channel-put:

  C-c C-cuser break
  context...:
   /usr/racket/collects/racket/private/misc.rkt:168:2: channel-put
   /tmp/channel.rkt:7:0: prompt-read
   /usr/racket/collects/racket/private/misc.rkt:87:7
PROMPT>

In other words, the ,rerun command is effectively broken.

I don't understand why it is stuck on the channel-put. I've re-read
the documentation about breaks, channels, custodians, and memory
limits. Then, I hoped that the act of typing out this long post would
cause me to figure it out. Unfortunately, I'm still stumped. Any ideas
why this is happening, and how to avoid it?

-- 
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] Official Docker images for Racket

2015-09-02 Thread Asumu Takikawa
On 2015-09-02 15:35:25 -0700, Jack Firth wrote:
> I do a lot of Racket development in Docker, and it's a pretty big pain.
> There's a handful of images on Docker Hub but they're pretty unmaintained,
> usually lag behind a version or two, tend to be built off an unnecessarily
> large base image like ubuntu, don't offer a snapshot build, and don't offer
> "minimal Racket" versions. I'd like to work on this and add some Racket
> images to the Official images like other languages have. Has anyone else
> worked on this?

That sounds great and if you put Racket images up I would happily use them.

I did look into building images on Dockerhub a while ago and had trouble
getting builds to finish (ran out of memory), but it looks like they have
improved the infrastructure since then.

Cheers,
Asumu

-- 
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] can # structures be made transparent?

2015-09-02 Thread 'John Clements' via Racket Users
It appears to me that the # structure (as e.g. from net/url) is opaque. Is 
there any good reason for this? It’s kind of a pain (the default printer 
doesn’t show me the fields), and I don’t see any good reason for it, especially 
given the existence of url->string. I’d be happy to formulate this as a pull 
request...

John Clements



-- 
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] can # structures be made transparent?

2015-09-02 Thread Robby Findler
It makes sense to me to make a printer that uses URL->string.

On Wednesday, September 2, 2015, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> It appears to me that the # structure (as e.g. from net/url) is
> opaque. Is there any good reason for this? It’s kind of a pain (the default
> printer doesn’t show me the fields), and I don’t see any good reason for
> it, especially given the existence of url->string. I’d be happy to
> formulate this as a pull request...
>
> John Clements
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] can # structures be made transparent?

2015-09-02 Thread 'John Clements' via Racket Users

> On Sep 2, 2015, at 3:59 PM, Robby Findler  wrote:
> 
> It makes sense to me to make a printer that uses URL->string. 

Actually, I kind of don’t want that...

Here’s my use case:

I have a url string, "http://localhost:8086/query?db=mydb”. I want to add more 
query parameters to it. Rather than fussing with the string syntax, I’d like to 
just formulate the whole thing as a url, as in

(make-url “http” “localhost” 8086 “/query” ‘((db “mydb”)))

… but I’m not sure which ones should be byte strings, or whether the initial 
slash appears in the path, or whether the query components are an association 
list, etc.

This is exactly the kind of thing that I would see easily if I could just write

(string->url "http://localhost:8086/query?db=mydb”)

… and see something like 

(url “http” etc. etc.)

If it gets converted back to a string, I’m back to square one.

Does this make sense?

John



> 
> On Wednesday, September 2, 2015, 'John Clements' via Racket Users 
>  wrote:
> It appears to me that the # structure (as e.g. from net/url) is opaque. 
> Is there any good reason for this? It’s kind of a pain (the default printer 
> doesn’t show me the fields), and I don’t see any good reason for it, 
> especially given the existence of url->string. I’d be happy to formulate this 
> as a pull request...
> 
> John Clements
> 
> 
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] can # structures be made transparent?

2015-09-02 Thread 'John Clements' via Racket Users

> On Sep 2, 2015, at 4:06 PM, Robby Findler  wrote:
> 
> I was worrying because the internal representation may change (again) so 
> exposing the real constructor doesn't seem wise. But making a printer print 
> what you want (or using selectors to check if it comes to that) seems okay. 

But it’s already exposed….(and documented).

John

> 
> Robby 
> 
> On Wednesday, September 2, 2015, 'John Clements' via Racket Users 
>  wrote:
> 
> > On Sep 2, 2015, at 3:59 PM, Robby Findler  
> > wrote:
> >
> > It makes sense to me to make a printer that uses URL->string.
> 
> Actually, I kind of don’t want that...
> 
> Here’s my use case:
> 
> I have a url string, "http://localhost:8086/query?db=mydb”. I want to add 
> more query parameters to it. Rather than fussing with the string syntax, I’d 
> like to just formulate the whole thing as a url, as in
> 
> (make-url “http” “localhost” 8086 “/query” ‘((db “mydb”)))
> 
> … but I’m not sure which ones should be byte strings, or whether the initial 
> slash appears in the path, or whether the query components are an association 
> list, etc.
> 
> This is exactly the kind of thing that I would see easily if I could just 
> write
> 
> (string->url "http://localhost:8086/query?db=mydb”)
> 
> … and see something like
> 
> (url “http” etc. etc.)
> 
> If it gets converted back to a string, I’m back to square one.
> 
> Does this make sense?
> 
> John
> 
> 
> 
> >
> > On Wednesday, September 2, 2015, 'John Clements' via Racket Users 
> >  wrote:
> > It appears to me that the # structure (as e.g. from net/url) is 
> > opaque. Is there any good reason for this? It’s kind of a pain (the default 
> > printer doesn’t show me the fields), and I don’t see any good reason for 
> > it, especially given the existence of url->string. I’d be happy to 
> > formulate this as a pull request...
> >
> > John Clements
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] can # structures be made transparent?

2015-09-02 Thread Robby Findler
I was worrying because the internal representation may change (again) so
exposing the real constructor doesn't seem wise. But making a printer print
what you want (or using selectors to check if it comes to that) seems okay.

Robby

On Wednesday, September 2, 2015, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

>
> > On Sep 2, 2015, at 3:59 PM, Robby Findler  > wrote:
> >
> > It makes sense to me to make a printer that uses URL->string.
>
> Actually, I kind of don’t want that...
>
> Here’s my use case:
>
> I have a url string, "http://localhost:8086/query?db=mydb”. I want to add
> more query parameters to it. Rather than fussing with the string syntax,
> I’d like to just formulate the whole thing as a url, as in
>
> (make-url “http” “localhost” 8086 “/query” ‘((db “mydb”)))
>
> … but I’m not sure which ones should be byte strings, or whether the
> initial slash appears in the path, or whether the query components are an
> association list, etc.
>
> This is exactly the kind of thing that I would see easily if I could just
> write
>
> (string->url "http://localhost:8086/query?db=mydb”)
>
> … and see something like
>
> (url “http” etc. etc.)
>
> If it gets converted back to a string, I’m back to square one.
>
> Does this make sense?
>
> John
>
>
>
> >
> > On Wednesday, September 2, 2015, 'John Clements' via Racket Users <
> racket-users@googlegroups.com > wrote:
> > It appears to me that the # structure (as e.g. from net/url) is
> opaque. Is there any good reason for this? It’s kind of a pain (the default
> printer doesn’t show me the fields), and I don’t see any good reason for
> it, especially given the existence of url->string. I’d be happy to
> formulate this as a pull request...
> >
> > John Clements
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com .
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] http response 204 (no content) with content-encoding "gzip"

2015-09-02 Thread 'John Clements' via Racket Users

> On Sep 2, 2015, at 1:38 PM, Greg Hendershott  
> wrote:
> 
> Certain status codes "MUST NOT" include a response body, including 204 [0].
> 
> For those, you could say not even a `peek-byte` is necessary. Although
> I guess there wouldn't be any harm.
> 
> Definitely for the other variants -- even "SHOULD NOT" -- then
> peek-byte makes sense.

Okay, I’ve made a (3-line) pull request. Jay, are you the right one to take a 
look at this?

John

> 
> 
> [0]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
> 
> 
> On Wed, Sep 2, 2015 at 1:15 PM, 'John Clements' via Racket Users
>  wrote:
>> I’m interacting with an HTTP server that recently responded with status
>> 
>> #"HTTP/1.1 204 No Content”
>> and headers
>> 
>> '(#"Content-Encoding: gzip"
>>  #"Request-Id: ec2f6fe5-5191-11e5-8007-”
>>  #"X-Influxdb-Version: 0.9.3”
>>  #"Date: Wed, 02 Sep 2015 16:44:48 GMT”
>>  #"Connection: close”)
>> 
>> using http-sendrecv/url with default arguments results in an error (and not 
>> a terribly sensible one), because it tries to gunzip the empty input.
>> 
>> I conjecture that this is a reasonable response from an HTTP server, and 
>> that in this situation http-sendrecv/url (and more specifically 
>> http-conn-recv!) should not signal an error, but just return the empty port. 
>> In fact, it appears to me that it should probably always be the case that an 
>> input port for which peek-byte returns # should be returned directly 
>> rather than being handed off to gunzip.  If this seems like the right 
>> approach, I’ll make a pull request.
>> 
>> Thanks!
>> 
>> John
>> 
>> 
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Interaction between break and custodian-box

2015-09-02 Thread Matthew Flatt
That looks like a bug in the scheduler to me. I don't think it's
specific to `custodian-box`, but to `sync` and any event that is not
ultimately backed by a channel or semaphore. (For example, `alarm-evt`
also seems to trigger the problem.)

At Wed, 2 Sep 2015 16:20:56 -0400, Greg Hendershott wrote:
> When you break an expression in the REPL, currently racket-mode takes
> you out of the module/environment. I want to change that:
> 
> https://github.com/greghendershott/racket-mode/issues/153
> 
> To do so, instead of grabbing the break using `with-handlers`, I'm
> using `call-with-exception-handler` and the `continue` filed of
> `exn:break`.
> 
> But I'm experiencing a weird interaction between breaks and sync-ing
> on a custodian-box. (It took me awhile to narrow down the problem to
> the custodian-box.) Consider this highly distilled version program.
> Note that `repl-cust-box` commented out in the sync call, to show an
> exmaple where the problem is NOT present:
> 
> --- channel.rkt ---
> 
> #lang racket/base
> 
> (require racket/match)
> 
> (define the-channel (make-channel))
> 
> (define (prompt-read)
>   (display "PROMPT> ")
>   (define in ((current-get-interaction-input-port)))
>   (define stx ((current-read-interaction) (object-name in) in))
>   (syntax-case stx ()
> [(uq cmd)
>  (and (eq? 'unquote (syntax-e #'uq))
>   (eq? 'rerun   (syntax-e #'cmd)))
>  (void (channel-put the-channel 'rerun)
>(sync never-evt))]
> [_ stx]))
> 
> (define (run)
>   (define repl-cust (make-custodian))
>   (define repl-cust-box (make-custodian-box repl-cust #t))
>   (custodian-limit-memory repl-cust (* 8 1024 1024) repl-cust)
>   (define repl-thread
> (thread
>  (λ ()
>(parameterize ([current-custodian repl-cust]
>   [current-namespace (make-base-namespace)]
>   [current-prompt-read prompt-read])
>  (read-eval-print-loop)
> 
>   (define msg
> (call-with-exception-handler
>  (λ (e)
>(match e
>  [(exn:break msg marks continue) (break-thread repl-thread) 
> (continue)]
>  [e e]))
>  (λ ()
>(match (sync the-channel #;repl-cust-box)
>  [(? custodian-box?)
>   (displayln "Exceeded memory limit")
>   'stop]
>  [msg msg]
> 
>   (displayln msg)
>   (custodian-shutdown-all repl-cust)
>   (run))
> 
> (run)
> 
> ---
> 
> 
> You get this good interaction:
> 
> $ racket channel.rkt
> PROMPT> (define x 42)
> PROMPT> x
> 42
> PROMPT> (sleep 100)
>   C-c C-cuser break
>   context...:
>/usr/racket/collects/racket/private/misc.rkt:87:7
> PROMPT> x
> 42
> PROMPT> ,rerun
> rerun
> PROMPT> x
> x: undefined;
>  cannot reference undefined identifier
>   context...:
>/usr/racket/collects/racket/private/misc.rkt:87:7
> PROMPT> (exit)
> 
> In other words, a C-c break will interrupt the program, but maintain
> the environment, e.g. x remains defined (good).
> 
> The ,rerun command will restart with a fresh environment, e.g. x is
> now undefined (good).
> 
> 
> 
> Great. But in channel.rkt, now change the line:
> 
>(match (sync the-channel #;repl-cust-box)
> 
> to:
> 
>(match (sync the-channel repl-cust-box)
> 
> So the sync now also includes the repl-cust-box event.
> 
> Now I get this interaction:
> 
> $ racket channel.rkt
> PROMPT> (define x 42)
> PROMPT> x
> 42
> PROMPT> (sleep 100)
>   C-c C-cuser break
>   context...:
>/usr/racket/collects/racket/private/misc.rkt:87:7
> PROMPT> x
> 42
> PROMPT> ,rerun
> 
> Here it "hangs". (This only happens if there has been at least one C-c
> break previously in the REPL session, as above.) If we now C-c, it
> breaks at the channel-put:
> 
>   C-c C-cuser break
>   context...:
>/usr/racket/collects/racket/private/misc.rkt:168:2: channel-put
>/tmp/channel.rkt:7:0: prompt-read
>/usr/racket/collects/racket/private/misc.rkt:87:7
> PROMPT>
> 
> In other words, the ,rerun command is effectively broken.
> 
> I don't understand why it is stuck on the channel-put. I've re-read
> the documentation about breaks, channels, custodians, and memory
> limits. Then, I hoped that the act of typing out this long post would
> cause me to figure it out. Unfortunately, I'm still stumped. Any ideas
> why this is happening, and how to avoid it?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email 
> to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

[racket-users] Official Docker images for Racket

2015-09-02 Thread Jack Firth
I do a lot of Racket development in Docker, and it's a pretty big pain. There's 
a handful of images on Docker Hub but they're pretty unmaintained, usually lag 
behind a version or two, tend to be built off an unnecessarily large base image 
like ubuntu, don't offer a snapshot build, and don't offer "minimal Racket" 
versions. I'd like to work on this and add some Racket images to the Official 
images like other languages have. Has anyone else worked on this?

-- 
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] Interaction between break and custodian-box

2015-09-02 Thread Greg Hendershott
Oops, I'd meant to copy the list.

On Wed, Sep 2, 2015 at 6:46 PM, Greg Hendershott
 wrote:
> Thanks for the quick reply!
>
> On Wed, Sep 2, 2015 at 5:28 PM, Matthew Flatt  wrote:
>> That looks like a bug in the scheduler to me. I don't think it's
>> specific to `custodian-box`, but to `sync` and any event that is not
>> ultimately backed by a channel or semaphore. (For example, `alarm-evt`
>> also seems to trigger the problem.)
>
> With that hint, I tried adding a level of indirection -- a thread that
> can sync on the custodian box, and put to a new, additional channel:
>
>   (define repl-cust-box-channel (make-channel))
>   (define repl-cust-box-thread (thread (λ ()
>  (let loop ()
>(sync repl-cust-box)
>(channel-put repl-cust-box-channel
> 'memory-limit)
>(loop)
>
> That way the main sync can be on two events backed by channels:
>
>(match (sync the-channel repl-cust-box-channel)
>  ['memory-limit
>   (displayln "Exceeded memory limit")
>   'stop]
>  [msg msg])
>
> And that seems to do the trick, at least in my distilled example.  I
> do want to test in the real/full code, as well as think about any
> lurking gotchas.  (Also, come to think of it, I can probably use the
> one channel for both purposes.)
>
> Even if there's a scheduler bug that you might fix, I'm happy if there
> is some work-around like this, because racket-mode is still aiming to
> support Racket versions as old as 5.3.5.
>
> Thanks again.

-- 
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] Lost in ellipsis depths

2015-09-02 Thread Konrad Hinsen
Konrad Hinsen writes:

 > In fact, what I want is do something like map over the ellipsis pattern,
 > but I haven't seen any example for doing this.

Well, map actually works:

  (syntax-parse #'(foo a b c)
[(f:id s:id ...)
 (with-syntax ([(foo-s ...)
(map (λ (x) (format-id #'f "foo-~a" x)) (syntax-e #'(s ...) 
))])
   #'(list foo-s ...))])

But is this the only solution? It looks a bit messy.

Konrad.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Lost in ellipsis depths

2015-09-02 Thread Jens Axel Søgaard
Here are two variations:

#lang racket

(require syntax/stx syntax/parse racket/syntax unstable/sequence)

(syntax-parse #'(foo a b c)
  [(f:id s:id ...)
   (define foo-s* (stx-map (λ (x) (format-id #'f "foo-~a" x)) #'(s ...)))
   (with-syntax ([(foo-s ...) foo-s*])
 #'(list foo-s ...))])


(syntax-parse #'(foo a b c)
  [(f:id s:id ...)
   (define foo-s* (for/list ([x (in-syntax #'(s ...))])
(format-id #'f "foo-~a" x)))
   (with-syntax ([(foo-s ...) foo-s*])
 #'(list foo-s ...))])


2015-09-02 13:09 GMT+02:00 Konrad Hinsen :

> Konrad Hinsen writes:
>
>  > In fact, what I want is do something like map over the ellipsis pattern,
>  > but I haven't seen any example for doing this.
>
> Well, map actually works:
>
>   (syntax-parse #'(foo a b c)
> [(f:id s:id ...)
>  (with-syntax ([(foo-s ...)
> (map (λ (x) (format-id #'f "foo-~a" x)) (syntax-e #'(s
> ...) ))])
>#'(list foo-s ...))])
>
> But is this the only solution? It looks a bit messy.
>
> Konrad.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
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] Lost in ellipsis depths

2015-09-02 Thread Konrad Hinsen
Hi everyone,

I am working on what I consider a simple macro, but after reading all
of the macro-related documentation twice, I still don't see how to do
this.

I want to transform

  (foo a b c)

to

  (list foo-a foo-b foo-c)

Here is my best attempt (using syntax/parse):

(syntax-parse #'(foo a b c)
  [(f:id s:id ...)
   (list (format-id #'f "foo-~a" #'s) ...)])

This yields the error message

  syntax: missing ellipsis with pattern variable in template

In fact, what I want is do something like map over the ellipsis pattern,
but I haven't seen any example for doing this.

Help, please!

Thanks in advance,
  Konrad.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Lost in ellipsis depths

2015-09-02 Thread Alexander D. Knauth

> On Sep 2, 2015, at 7:09 AM, Konrad Hinsen  wrote:
> 
> Konrad Hinsen writes:
> 
>> In fact, what I want is do something like map over the ellipsis pattern,
>> but I haven't seen any example for doing this.
> 
> Well, map actually works:
> 
>  (syntax-parse #'(foo a b c)
>[(f:id s:id ...)
> (with-syntax ([(foo-s ...)
>(map (λ (x) (format-id #'f "foo-~a" x)) (syntax-e #'(s 
> ...) ))])
>   #'(list foo-s ...))])
> 
> But is this the only solution? It looks a bit messy.
> 
> Konrad.

To make it look a little less messy, here's what I would do for stuff like this:
(require fancy-app syntax/parse syntax/stx) ; in a for-syntax if necessary
(syntax-parse #'(foo a b c)
  [(f:id s:id ...)
   #:with (foo-s ...) (stx-map (format-id #'f "foo-~a" _) #'(s ...)) ; the _ 
makes a fancy-app anonymous function
   #'(list foo-s ...)])

Or if it's something more complicated, I would use a for/list instead of a 
stx-map.

Alex Knauth

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