Re: [racket-users] Re: Let's organize a Scheme European Event at FOSDEM 2019

2018-10-17 Thread amz3


On Sunday, October 14, 2018 at 4:33:22 AM UTC+2, Claes Wallin (韋嘉誠) wrote:
>
> Looks like the 
> https://fosdem.org/2019/schedule/track/minimalistic_languages/ 
> devroom came through! 
>
> Unfortunately, http://community.schemewiki.org/?FOSDEM2019 has been 
> down for days. Anyone know who is running it, and what the status is 
> on recovering? 
>

I don't know what happened to schemewiki.

Anyway, here is the proposal that was submitted at FOSDEM:

  https://libreplanet.org/wiki/FOSDEM2019-devroom-minimalism

Of course, you are welcome to submit your proposal at: 
https://penta.fosdem.org/submission/FOSDEM19

To create an account if you don't already have one: 
https://penta.fosdem.org/user/new_account

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
> On Oct 17, 2018, at 11:30, Shu-Hung You  > wrote:
>> 
>> Would it help if in the check module you use `=' as the equality test,
>> or specify #e10.25 instead?
> 
> Success!
> 
> Specifying
> (!test (hour-angle 12 20 30) #e10.25)
> produces the behavior I expected, correctly comparing the numbers.

Ehh, I spoke too soon. The analagous student test —
(check-expect (hour-angle 12 20 30) 10.25)
— fails when included in the handin submission.

My working hypothesis is that I just need to configure the handin server’s 
evaluator to have (read-decimal-as-inexact #f). I’m trying to work out how to 
do that from the (check: ...) form, and failing that, will manually create & 
configure the evaluator.

If you can tell me how to do that — or tell me if I’m wrong — I’d much 
appreciate the saved time. But I do expect it’s a problem I can solve on my own 
with enough time.

Thanks,
Jordan


-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
On Oct 17, 2018, at 11:30, Shu-Hung You  
wrote:
> 
> Would it help if in the check module you use `=' as the equality test,
> or specify #e10.25 instead?

Success!

Specifying
(!test (hour-angle 12 20 30) #e10.25)
produces the behavior I expected, correctly comparing the numbers.

Thanks, all!

Best,
Jordan

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
>> So, what aspect of the language config would be responsible for 41/4 not 
>> equaling 10.25?
> 
> Welcome to Racket v7.0.0.20.
>> (= 41/4 10.25)
> #t
>> (read-decimal-as-inexact #f)
>> (= 41/4 10.25)
> #t
> 
> Do you perhaps print and read the result? 

Nope. The code that’s generating the error is

(check: :language 'lang/htdp-intermediate
...
(!test (hour-angle 12 20 30) 10.25)
...)

I’m looking into !test now; I don’t yet know how it does its comparison.

jmj

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Shu-Hung You
On Wed, Oct 17, 2018 at 1:12 PM Jordan Johnson  wrote:
>
>
> On Oct 17, 2018, at 10:35, Matthias Felleisen  wrote:
>
> (check-expect (+ 10 .25) 10.25)
>
> errors with check-expect’s message about not comparing inexact numbers, but 
> in DrRacket+BSL the decimals are treated as exact numbers.
>
> What do I need to change in the checker, in order to obtain the same numeric 
> behavior as in DrRacket?
>
> Set read-decimal-as-inexact might solve the problem.
>
>
> Progress! But not completely solved. By adding
>
> (read-decimal-as-inexact #f)
>
> to the checker module, I now don’t get the check-expect error. Instead, I’m 
> seeing
>
> submit error: your code failed a test: (hour-angle 12 20 30) evaluated to 
> 41/4, expecting 10.25
>
>
> produced by the checker line
>
> (!test (hour-angle 12 20 30) 10.25)
>

Would it help if in the check module you use `=' as the equality test,
or specify #e10.25 instead?

> where hour-angle computes exactly.
>
> So, what aspect of the language config would be responsible for 41/4 not 
> equaling 10.25?
>
> Best,
> Jordan
>
> --
> 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] handin-server: reader used in checker modules

2018-10-17 Thread Matthias Felleisen


> On Oct 17, 2018, at 2:11 PM, Jordan Johnson  wrote:
> 
> 
>> On Oct 17, 2018, at 10:35, Matthias Felleisen  wrote:
>>> (check-expect (+ 10 .25) 10.25)
>>> 
>>> errors with check-expect’s message about not comparing inexact numbers, but 
>>> in DrRacket+BSL the decimals are treated as exact numbers.
>>> 
>>> What do I need to change in the checker, in order to obtain the same 
>>> numeric behavior as in DrRacket?
>> Set read-decimal-as-inexact might solve the problem. 
> 
> Progress! But not completely solved. By adding 
> (read-decimal-as-inexact #f)
> to the checker module, I now don’t get the check-expect error. Instead, I’m 
> seeing
> submit error: your code failed a test: (hour-angle 12 20 30) evaluated to 
> 41/4, expecting 10.25
> 
> produced by the checker line
> (!test (hour-angle 12 20 30) 10.25)
> where hour-angle computes exactly.
> 
> So, what aspect of the language config would be responsible for 41/4 not 
> equaling 10.25?


Hmph: 
 
Welcome to Racket v7.0.0.20.
> (= 41/4 10.25)
#t
> (read-decimal-as-inexact #f)
> (= 41/4 10.25)
#t


Do you perhaps print and read the result? 

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson

> On Oct 17, 2018, at 10:35, Matthias Felleisen  wrote:
>>  (check-expect (+ 10 .25) 10.25)
>> 
>> errors with check-expect’s message about not comparing inexact numbers, but 
>> in DrRacket+BSL the decimals are treated as exact numbers.
>> 
>> What do I need to change in the checker, in order to obtain the same numeric 
>> behavior as in DrRacket?
> Set read-decimal-as-inexact might solve the problem. 

Progress! But not completely solved. By adding 
(read-decimal-as-inexact #f)
to the checker module, I now don’t get the check-expect error. Instead, I’m 
seeing
submit error: your code failed a test: (hour-angle 12 20 30) evaluated to 41/4, 
expecting 10.25

produced by the checker line
(!test (hour-angle 12 20 30) 10.25)
where hour-angle computes exactly.

So, what aspect of the language config would be responsible for 41/4 not 
equaling 10.25?

Best,
Jordan

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Matthias Felleisen


> On Oct 17, 2018, at 1:21 PM, Jordan Johnson  wrote:
> 
> Hi all,
> 
> In my last thread regarding the handin server, Matthew suggested:
>> A workaround is to use `'lang/htdp-beginner` as the language instead of
>> `'(special beginner)`. That happens to avoid a redundant and
>> troublemaking `require`.
> 
> So, I’m using 'lang/htdp-beginner in an assignment’s checker.rkt file, and I 
> am seeing errors that appear to be the result of the handin server using a 
> different reader (or configuration thereof) than DrRacket does for BSL. 
> Specifically,
> 
>   (check-expect (+ 10 .25) 10.25)
> 
> errors with check-expect’s message about not comparing inexact numbers, but 
> in DrRacket+BSL the decimals are treated as exact numbers.
> 
> What do I need to change in the checker, in order to obtain the same numeric 
> behavior as in DrRacket?


Set read-decimal-as-inexact might solve the problem. 

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
Hi all,

In my last thread regarding the handin server, Matthew suggested:
> A workaround is to use `'lang/htdp-beginner` as the language instead of
> `'(special beginner)`. That happens to avoid a redundant and
> troublemaking `require`.

So, I’m using 'lang/htdp-beginner in an assignment’s checker.rkt file, and I am 
seeing errors that appear to be the result of the handin server using a 
different reader (or configuration thereof) than DrRacket does for BSL. 
Specifically,

(check-expect (+ 10 .25) 10.25)

errors with check-expect’s message about not comparing inexact numbers, but in 
DrRacket+BSL the decimals are treated as exact numbers.

What do I need to change in the checker, in order to obtain the same numeric 
behavior as in DrRacket?

Thanks,
Jordan

-- 
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] Higher-order units

2018-10-17 Thread Philip McGrath
The way I have found to do this is to both use the `tag` form and
explicitly rename all signature elements, e.g.:

(define-unit twice-collector@
  (import (tag base (prefix base: collector^)))
  (export collector^)

  (define item/c base:item/c)
  (define (collect . xs)
(apply base:collect (append xs xs

However, I also find this unsatisfying, and I would note that there is a
bug that prevents doing this sort of thing with `define-unit/contract`:
https://github.com/racket/racket/issues/2196

-Philip


On Wed, Oct 17, 2018 at 11:29 AM Alexis King  wrote:

> Imagine I have the following signature:
>
> (define-signature collector^
>   [(contracted
> [item/c contract?]
> [collect (-> item/c ... item/c)])])
>
> Writing a unit that exports this signature is easy. For example, here’s
> one that sums its arguments:
>
> (define-unit sum-collector@
>   (import)
>   (export collector^)
>
>   (define item/c number?)
>
>   (define (collect . xs)
> (apply + xs)))
>
> But imagine I want to instead write a higher-order unit that implements
> collector^ by wrapping an existing collector^ implementation. For example,
> I could write a unit that applies the “base” collector to a doubled list:
>
> (define-unit twice-collector@
>   (import (rename collector^ [base:collect collect]))
>   (export collector^)
>
>   (define (collect . xs)
> (apply base:collect (append xs xs
>
> However, this fails with the following error message:
>
> define-unit: import item/c is exported
>
> The error message is not wrong — item/c is indeed re-exported by
> twice-collector@, but this is because twice-collector@ doesn’t care about
> item/c, only collect. However, I can accept that this program is rejected,
> since it isn’t clear how to link twice-collector@ with a base collector;
> there would be two different units that export collector^ in a single
> compound unit. Therefore, it seems that the intended solution would be to
> tag the import:
>
> (define-unit twice-collector@
>   (import (tag base (rename collector^ [base:collect collect])))
>   (export collector^)
>
>   (define (collect . xs)
> (apply base:collect (append xs xs
>
> However, this program is still rejected with the same error message. In
> this case, I can’t understand why.
>
> One alternative is to avoid using the import mechanism altogether and
> instead define twice-collector@ as a function, creating a sort of “unit
> mixin”:
>
> (define (twice-collector@ base-collector@)
>   (unit
> (import)
> (export collector^)
>
> (define-values/invoke-unit base-collector@
>   (import)
>   (export (rename collector^ [base:collect collect])))
>
> (define (collect . xs)
>   (apply base:collect (append xs xs)
>
> This works, but it seems a little bit silly, since it effectively performs
> the linking manually and runs around the linker.
>
> What is the “correct” way to write higher-order units? I looked for ideas
> in the original units paper (Units: Cool Modules for HOT Languages), and it
> seems to just use the function approach I mentioned above, but the system
> it describes is meaningfully different from the one implemented in Racket,
> and I can’t find very much information about the design of the Racket
> system.
>
> Alexis
>
> --
> 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] Higher-order units

2018-10-17 Thread Alexis King
Imagine I have the following signature:

(define-signature collector^
  [(contracted
[item/c contract?]
[collect (-> item/c ... item/c)])])

Writing a unit that exports this signature is easy. For example, here’s one 
that sums its arguments:

(define-unit sum-collector@
  (import)
  (export collector^)

  (define item/c number?)

  (define (collect . xs)
(apply + xs)))

But imagine I want to instead write a higher-order unit that implements 
collector^ by wrapping an existing collector^ implementation. For example, I 
could write a unit that applies the “base” collector to a doubled list:

(define-unit twice-collector@
  (import (rename collector^ [base:collect collect]))
  (export collector^)

  (define (collect . xs)
(apply base:collect (append xs xs

However, this fails with the following error message:

define-unit: import item/c is exported

The error message is not wrong — item/c is indeed re-exported by 
twice-collector@, but this is because twice-collector@ doesn’t care about 
item/c, only collect. However, I can accept that this program is rejected, 
since it isn’t clear how to link twice-collector@ with a base collector; there 
would be two different units that export collector^ in a single compound unit. 
Therefore, it seems that the intended solution would be to tag the import:

(define-unit twice-collector@
  (import (tag base (rename collector^ [base:collect collect])))
  (export collector^)

  (define (collect . xs)
(apply base:collect (append xs xs

However, this program is still rejected with the same error message. In this 
case, I can’t understand why.

One alternative is to avoid using the import mechanism altogether and instead 
define twice-collector@ as a function, creating a sort of “unit mixin”:

(define (twice-collector@ base-collector@)
  (unit
(import)
(export collector^)

(define-values/invoke-unit base-collector@
  (import)
  (export (rename collector^ [base:collect collect])))

(define (collect . xs)
  (apply base:collect (append xs xs)

This works, but it seems a little bit silly, since it effectively performs the 
linking manually and runs around the linker.

What is the “correct” way to write higher-order units? I looked for ideas in 
the original units paper (Units: Cool Modules for HOT Languages), and it seems 
to just use the function approach I mentioned above, but the system it 
describes is meaningfully different from the one implemented in Racket, and I 
can’t find very much information about the design of the Racket system.

Alexis

-- 
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] Web server hits "Sorry, this page has expired. Please go back."

2018-10-17 Thread Luke Whittlesey
Interesting conversation.. I want to add that #lang web-server does have
file-boxes (
https://docs.racket-lang.org/web-server/stateless.html?q=web-server#%28part._lang%2Ffile-box%29)
for when one might want to preserve data like you would in the store. To
run across multiple machines I would imagine one could also write a
file-box-ish approach to a database, but I haven't gotten there yet.
I think one of the exciting aspects for me regarding stateless
continuations is the idea of running on multiple servers with the only
shared state being cookies and file-boxes. I imagine being able to easily
scale with something like Amazon Lambda. Although I haven't tried that yet
either, so maybe there are roadblocks there.

On Sun, Oct 14, 2018 at 7:55 PM George Neuner  wrote:

> Hi Philip,
>
> Sorry for the delay in responding ... busy day.
>
>
> On 10/14/2018 7:09 AM, Philip McGrath wrote:
>
> On Sun, Oct 14, 2018 at 5:30 AM George Neuner 
> wrote:
>
>> You are absolutely correct that in typical usage globals are not closed
>> over ... normally they are considered mutable shared "communication"
>> state.
>>
>> However, I was speaking more generally:  to be persisted long duration,
>> and be made portable across separate runtime instances, the continuation
>> must close over AND deep copy ANY VALUE the current call chain references.
>> You don't (necessarily) want to restart the continuation a week later, on a
>> different machine, with different values than when it started.
>>
>
> I am definitely not an expert on continuations or PL generally, so I could
> be very wrong. My understanding, though, has been that continuations not
> closing over non-local variables is a property of continuations in general:
> not only in a web context, and not only of the serializable continuations
> from `#lang web-server`. (I used those in my example just because it is
> easy to see what values they do in fact close over.)
>
>
> In the most basic form, the continuation is just "what to do next" - e.g.,
> a pointer to the next code to be executed.  That is [more or less] all that
> is required for a local (within a function) escape continuation because
> [barring stack corruption] all of the EC's stack context is guaranteed to
> exist if/when the continuation is invoked, and that state is needed anyway
> because the program will continue on regardless of how it leaves the scope
> of the EC.
>
> For a non-local EC, you need to return to the stack frame that was current
> when the continuation was created [the rest of the stack can be
> discarded].  In any case, an EC can very compact - just a couple of
> pointers.
>
> [Aside: a Lisp-style exception requires that the entire call stack be kept
> until you know where execution will continue.  You need to return to the
> EC's call frame (to find the exception handler), but Lisp allows exceptions
> to introspect/modify the environment and then to return control to the
> point of the exception (where the intrinsic EC was invoked).  Scheme
> doesn't have this capability.]
>
>
> General continuations - such as can implement coroutines - need to capture
> much more state.  The entire stack state of the current function call chain
> at the point where the continuation is created must be preserved in order
> to reenter the continuation.
> [this is where stateful and stateless part company - more below]
>
>
> Winding continuations are an extension of general continuations to the
> requirements of dynamic-wind.  In addition to whatever is required for a
> general continuation, a winding continuation has preamble code that must be
> executed whenever a continuation enters the winding scope, and postamble
> code to be executed whenever (and how ever) execution leaves the winding
> scope.
>
>
> The long winded point here is that continuations have no canon
> implementation - if you want more functionality from them, you need to
> capture/preserve more state.
>
>
>
> The web-server is multi-threaded, and the stack state of each thread is
> unique - so for each thread in which a continuation is created in the
> stateful server, the thread's call stack must be preserved.
>
> The stateless server is a different case.  CPS code doesn't use a call
> stack ... or rather its "stack" only ever contains one useful frame - the
> current one.  So there's only one call frame per thread that needs to be
> preserved rather than a (maybe large) stack of them.  This is why stateless
> server continuations - in general - use much less memory than stateful
> server continuations.
>
> [The above is a bit simplistic because Scheme supports nested functions
> with non-local variable access.  [Scheme also supports 1st class closures
> based on nested functions, but that is not what this is about.]   To
> support non-local access without a stack, CPS code needs to construct
> shared environments on the fly as the program executes to communicate
> values from producers to consumers, and these environments (where
> applicable)

Re: [racket-users] How to download image using net/http-client?

2018-10-17 Thread George Neuner

On 10/17/2018 9:06 AM, George Neuner wrote:


But be aware that you may run into images that do *^NOT* have 
Content-Length  set.  Many sites assume images are only for display by 
the browser.


Sorry.  Should have been  'do not'

Gorge

--
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] How to download image using net/http-client?

2018-10-17 Thread George Neuner




On 10/16/2018 4:02 PM, Philippe Mechaï wrote:
Indeed the issue is with your call to pipe-content-length which is to 
be used with pipes and is not the Content-Length header returned when 
doing HTTP requests.
The Content-Length can be found in the list of headers returned by the 
call to http-sendrecv (second value or b in your let-values call). You 
can parse these using the net/head module.



But be aware that you may run into images that do have Content-Length  
set.  Many sites assume images are only for display by the browser.


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.