[racket-users] Re: Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Armon Toubman
On Wednesday, March 16, 2016 at 1:57:30 PM UTC+1, Daniel Prager wrote:
> Awesomely, Jens has been working on Urlang: a Racket-ish syntax for 
> JavaScript, using the nanopass compiler infrastructure:
> 
> https://github.com/soegaard/urlang
> 
> 
> 
> and more ambitiously, a Racket (subset) ->JavaScript compiler (rjs), taking a 
> distinct approach from Whalesong.
> 
> * * *
> 
> 
> Just using plain Urlang together with sxml, Bootstrap (for css), and notably 
> Ractive.js for templating and data-binding I made the following demo / 
> proof-of-concept:
> 
> 
> http://htmlpreview.github.io/?https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html
> 
> 
> 
> Note: no heavyweight js runtime required: actually no runtime at all.
> 
> 
> 
> 
> 
> Racket source: 
> https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.rkt
> 
> 
> HTML output (including embedded JavaScript): 
> https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html
> 
> The abstractions are a bit leaky, but I'm quietly excited about where this 
> sort of approach could lead.
> 
> What do you think?
> 
> 
> Dan

This looks great. Would it be possible to extend this to React Native [1], so 
we can write mobile apps in Racket?

[1] https://facebook.github.io/react-native/

Armon

-- 
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] Setting return address in Racket's sendmail

2016-03-19 Thread Matthias Felleisen

This has gotten me rejection replies: 

  (smtp-send-message
   (dns-get-address (dns-find-nameserver) "smtp.gmail.com") 
   "matth...@ccs.neu.edu" 
   actual-send-to-addresses
   addresses-put-into-header
   file 
   #:port-no 465
   ; for gmail don't include the @gmail.com
   #:auth-user “foobarf@" 
   #:auth-passwd “XYZ"
   #:tcp-connect ssl-connect))



> On Mar 16, 2016, at 8:35 PM, Marc Kaufmann  wrote:
> 
> Hi all,
> 
> I am using send-mail-message as follows:
> 
> #lang racket
> 
> (require net/sendmail)
> (send-mail-message
>  #f "Test sendmail"
>  '("fake-em...@marcs-server.com ")
>  '()
>  '()
>  '("Testing Racket sendmail."))
> 
> It works as expected when I send something to myself, since sendmail goes and 
> gets the email associated with my user. But when I send it to a non-existing 
> email, I do not get a notification that it wasn't delivered.
> 
> Is there a way to set the return address? I presume it goes into the 
> extra-header argument, but I am not sure.
> 
> Thanks,
> Marc
> 
> 
> -- 
> 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] Trouble with displaying value-turtles

2016-03-19 Thread Robby Findler
Thanks, I've pushed a fix for this.

If you want, you can apply this diff (use the "File | Open Require
Path..." menu item in DrRacket and type
"graphics/private/value-turtles" into the dialog to find the right
file to edit). You'll have to restart DrRacket to see your changes
work. And you may find that programs run more slowly after that --
it's because it is now compiling from source each time you hit "Run".
You'll need to run "raco setup" from a Terminal / command.com prompt
to fix that. (It will print a lot of output -- just wait for it to
finish.)

https://github.com/racket/htdp/commit/1d6bfae614720c3ed9a2e4956983d650beee143a

You could also use tomorrow's snapshot builds.

Robby

On Sat, Mar 19, 2016 at 5:31 PM, nikofeyn  wrote:
> Lol. I almost mentioned my confusion on why the interactions window appeared
> to be clearing itself when running that code but had obviously not scrolled
> up. Simple solution indeed.
>
> I guess my next question would be how to move the display window to a
> separate window similar to what "(turtles #t)" does, but I haven't looked
> into that yet. If someone knows the quick answer though I'm all ears. :)
>
> Am I right in guessing that the value-turtles library is preferred for
> performance (since it's not constantly updating a window) and functional
> dataflow reasons?
>
> Thanks for taking a look. My copy of Turtle Geometry arrived today, so I'm
> going to dive in.
>
> On Sat, Mar 19, 2016 at 5:51 PM, Jens Axel Søgaard 
> wrote:
>>
>> I ran your program and was, too, a bit confused at first.
>> But ... turns out it is simple.
>> Run the program in DrRacket.
>> Switch to the repl.
>> Then scroll up!
>> The "windows" are displayed as pictures in the repl,
>> but they are so big, that you can't see them at first.
>>
>> /Jens Axel
>>
>>
>>
>>
>> 2016-03-19 22:47 GMT+01:00 :
>>>
>>> Hello,
>>>
>>> I am beginning a project in which I want to use Racket's turtle
>>> functionality to implement the examples and exercises from the book Turtle
>>> Geometry.
>>>
>>> In doing so, there is of course the choice between the traditional
>>> turtles (graphics/turtles) and the value turtles (graphics/value-turtles).
>>>
>>> I am playing around with the two libraries to pick a direction. The
>>> implication is that the value-turtules is more functional in nature and thus
>>> the ideal, long-term way to go. However, I am unable to get a turtle window
>>> to display.
>>>
>>> For example, the following code does nothing and returns no errors:
>>> #lang racket
>>> (require graphics/value-turtles)
>>> (require graphics/value-turtles-examples)
>>> (define twindow (turtles 500 500))
>>> (neato twindow)
>>> twindow
>>>
>>> For the traditional turtles, the following code works just fine:
>>> #lang racket
>>> (require graphics/turtles)
>>> (require graphics/turtle-examples)
>>> (turtles #t)
>>> (neato)
>>>
>>> What am I doing wrong with the value-turtles? It's not clear how to
>>> actually display the turtle window/drawing.
>>>
>>> This isn't related to this issue is it?
>>> https://groups.google.com/forum/#!searchin/racket-dev/turtles/racket-dev/qv840Wtwu5E/vC08lyZjAWQJ
>>>
>>> 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.
>>
>>
>>
>>
>> --
>> --
>> 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.

-- 
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: Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Greg Trzeciak
On Wednesday, March 16, 2016 at 10:32:22 PM UTC+1, Jens Axel Søgaard wrote:
> 2016-03-16 22:18 GMT+01:00 Greg Trzeciak :
> 
> 
> Thanks Dan, seems to be exactly what I need (especially the combination with 
> ractive.js! BTW you couldn't find js framework with name more fitting to work 
> with racket ;)
> 
> I am only curious what racket subset does urlang include or rather what won't 
> work in urlang.
> 
> 
> Hi Greg,
> 
> 
> Think of Urlang as JavaScript with s-expression syntax.
> The core urlang language includes constructs that mirror JavaScript almost 
> one-to-one.
> 
> So Urlang is not "Racket to JavaScript compiler".

Got it. In other words:

"Urlang is a Racket flavoured S-expression syntax for Javascript"

Thank you for your explanation - still seems like a good fit for one of my 
projects (as I needed something more lightweight than Whalesong) so I will try 
it out shortly.

Greg


-- 
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] Racket for web apps

2016-03-19 Thread Kaylen Wheeler
Hi,

I'm new to Racket, but not to lisp.  I have been a Clojure user for some time.  
I began developing a web game in clojure/clojurescript, but I am considering 
switching languages.

How good is Racket for web-related development?

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] Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Daniel Prager
Awesomely, Jens has been working on Urlang: a Racket-ish syntax for
JavaScript, using the nanopass compiler infrastructure:

https://github.com/soegaard/urlang

and more ambitiously, a Racket (subset) ->JavaScript compiler (rjs), taking
a distinct approach from Whalesong.

* * *

Just using plain Urlang together with sxml, Bootstrap (for css), and
notably Ractive.js  for templating and data-binding I
made the following demo / proof-of-concept:

http://htmlpreview.github.io/?https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html

Note: no heavyweight js runtime required: actually no runtime at all.


Racket source:
https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.rkt

HTML output (including embedded JavaScript):
https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html

The abstractions are a bit leaky, but I'm quietly excited about where this
sort of approach could lead.

What do you think?

Dan

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


[racket-users] string-join vs string-append

2016-03-19 Thread Arnel
Hi,

How does 'string-join' differ from 'string-append'? More specifically, why does
the following code:

(let ([z ""]
  [y "b"])
  (string-join '(z y) "\n"))

result in a contract violation, yet the following:

(let ([z ""]
  [y "b"])
  (string-append z y))

works without any issues. (It's not necessarily the result I wanted, but I can
work around it.) Isn't '(z y) essentially a list of strings?


Thank you,
Arnel

-- 
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 -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Matthew Butterick
When you put it that way, subjectively it still sounds good. I'd use it. But 
objectively I can't foresee that it would be a wise investment of anyone's 
Racket time. Let's face it: any web framework is lucky to live 5 yrs before 
developers tire of it and move onto the next thing, or browser changes make it 
obsolete. I have a shoddy `css-tools` library that I sometimes think about 
cleaning up for public consumption, and then I get dizzy and move on to 
something else. 


On Mar 18, 2016, at 1:27 PM, Daniel Prager  wrote:

> Matthew writes:
> > The idea of a subset of Racket that compiles to this kind of statistically 
> > probable subset of JS is very appealing. 
> 
> Agreed. The way Jens has split it up is that Urlang is a thin, cleaned-up 
> Racket-ish syntax for ES5, with a bit of sugar and a macro capability.
> 
> Then there's rjs, which includes a runtime, and aims to compile a substantive 
> subset of Racket. Of course there's going to be a trade-off between 
> completeness and runtime-size, etc.
> 
> > Especially if it can obviate the need or should I say "need" for a JS 
> > framework.
> 
> So, I'm currently looking at some of the "better" JS / HTML / CSS frameworks 
> / libraries with a view to being able to hide the detail and relatively 
> easily spin-up browser-hosted applications. E.g.
> CSS / reponsiveness: e.g. Bootstrap
> DOM manipulation & binding: e.g Ractive, Mithril
> Data structures: e.g. mori
> Graphics: e.g. D3
> I take it obviating the need for frameworks would essentially mean pulling 
> necessary functionality up into Racket: analogous to writing in Racket rather 
> than using interop to access external e.g. C/C++ libraries from regular 
> Racket.
> 
> Is that what you mean? Sounds good to me, but more of a "longer term" 
> project. Elm might be a good model for this.
> 
> Dan

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


Re: [racket-users] Trouble with displaying value-turtles

2016-03-19 Thread nikofeyn
Lol. I almost mentioned my confusion on why the interactions window
appeared to be clearing itself when running that code but had obviously not
scrolled up. Simple solution indeed.

I guess my next question would be how to move the display window to a
separate window similar to what "(turtles #t)" does, but I haven't looked
into that yet. If someone knows the quick answer though I'm all ears. :)

Am I right in guessing that the value-turtles library is preferred for
performance (since it's not constantly updating a window) and functional
dataflow reasons?

Thanks for taking a look. My copy of Turtle Geometry arrived today, so I'm
going to dive in.

On Sat, Mar 19, 2016 at 5:51 PM, Jens Axel Søgaard 
wrote:

> I ran your program and was, too, a bit confused at first.
> But ... turns out it is simple.
> Run the program in DrRacket.
> Switch to the repl.
> Then scroll up!
> The "windows" are displayed as pictures in the repl,
> but they are so big, that you can't see them at first.
>
> /Jens Axel
>
>
>
>
> 2016-03-19 22:47 GMT+01:00 :
>
>> Hello,
>>
>> I am beginning a project in which I want to use Racket's turtle
>> functionality to implement the examples and exercises from the book Turtle
>> Geometry.
>>
>> In doing so, there is of course the choice between the traditional
>> turtles (graphics/turtles) and the value turtles (graphics/value-turtles).
>>
>> I am playing around with the two libraries to pick a direction. The
>> implication is that the value-turtules is more functional in nature and
>> thus the ideal, long-term way to go. However, I am unable to get a turtle
>> window to display.
>>
>> For example, the following code does nothing and returns no errors:
>> #lang racket
>> (require graphics/value-turtles)
>> (require graphics/value-turtles-examples)
>> (define twindow (turtles 500 500))
>> (neato twindow)
>> twindow
>>
>> For the traditional turtles, the following code works just fine:
>> #lang racket
>> (require graphics/turtles)
>> (require graphics/turtle-examples)
>> (turtles #t)
>> (neato)
>>
>> What am I doing wrong with the value-turtles? It's not clear how to
>> actually display the turtle window/drawing.
>>
>> This isn't related to this issue is it?
>> https://groups.google.com/forum/#!searchin/racket-dev/turtles/racket-dev/qv840Wtwu5E/vC08lyZjAWQJ
>>
>> 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.
>>
>
>
>
> --
> --
> 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.


Re: [racket-users] Trouble with displaying value-turtles

2016-03-19 Thread Jens Axel Søgaard
I ran your program and was, too, a bit confused at first.
But ... turns out it is simple.
Run the program in DrRacket.
Switch to the repl.
Then scroll up!
The "windows" are displayed as pictures in the repl,
but they are so big, that you can't see them at first.

/Jens Axel




2016-03-19 22:47 GMT+01:00 :

> Hello,
>
> I am beginning a project in which I want to use Racket's turtle
> functionality to implement the examples and exercises from the book Turtle
> Geometry.
>
> In doing so, there is of course the choice between the traditional turtles
> (graphics/turtles) and the value turtles (graphics/value-turtles).
>
> I am playing around with the two libraries to pick a direction. The
> implication is that the value-turtules is more functional in nature and
> thus the ideal, long-term way to go. However, I am unable to get a turtle
> window to display.
>
> For example, the following code does nothing and returns no errors:
> #lang racket
> (require graphics/value-turtles)
> (require graphics/value-turtles-examples)
> (define twindow (turtles 500 500))
> (neato twindow)
> twindow
>
> For the traditional turtles, the following code works just fine:
> #lang racket
> (require graphics/turtles)
> (require graphics/turtle-examples)
> (turtles #t)
> (neato)
>
> What am I doing wrong with the value-turtles? It's not clear how to
> actually display the turtle window/drawing.
>
> This isn't related to this issue is it?
> https://groups.google.com/forum/#!searchin/racket-dev/turtles/racket-dev/qv840Wtwu5E/vC08lyZjAWQJ
>
> 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.
>



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


Re: [racket-users] predicate as an atom within a regexp?

2016-03-19 Thread Alex Knauth
There's a string-append match expander for that here, although it's pretty slow 
right now.
http://docs.racket-lang.org/match-string/index.html 


Alex Knauth

> On Mar 17, 2016, at 7:17 PM, Matthew Butterick  > wrote:
> 
> Racket's `match` is not far from this. In fact maybe I shouldn't be thinking 
> in terms of hacking regexps, but rather making a new match expander. For 
> instance, you can destructure a list like so:
> 
> (match '("foo" "-42.3" "bar")
>  [(list a (? string->number b) c) 'yay]
>  [else 'boo])
> 
> So it would extend logically to this pseudocode:
> 
> (match "foo-42.3bar"
>  [(string-append a (? string->number b) c) 'yay]
>  [else 'boo])

-- 
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 for web apps

2016-03-19 Thread Kaylen Wheeler
On Friday, 18 March 2016 21:11:51 UTC-7, Jay McCarthy  wrote:
> It's great. Check out the various libraries of the web-server. I'd
> suggest starting from web-server/servlet-env and web-server/dispatch.
> 
> Jay
> 
> On Fri, Mar 18, 2016 at 5:00 PM, Kaylen Wheeler  wrote:
> > Hi,
> >
> > I'm new to Racket, but not to lisp.  I have been a Clojure user for some 
> > time.  I began developing a web game in clojure/clojurescript, but I am 
> > considering switching languages.
> >
> > How good is Racket for web-related development?
> >
> > 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.
> 
> 
> 
> -- 
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> 
>"Wherefore, be not weary in well-doing,
>   for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>   - D 64:33

One thing I would like to do is have a single code base shared between the 
server back end and the in-browser front end.  The front end would have to be 
in javascript.  I know there's a way to compile racket to JS, but can the code 
be shared.

Also, can *typed* racket code be shared this way?

-- 
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] making standalone application

2016-03-19 Thread Daniel Brunner
Am 19.03.2016 um 17:03 schrieb sagar tripathy:
> i am trying to make a software with Racket for generic use . Or ,you can say 
> a complete setup for system without "DRracket" or "minimal Racket" . I do not 
> know the way to achieve it.
> 

Hi, what kind of OS and platform are you using?

Perhaps the following parts of the documentation may help:

https://docs.racket-lang.org/guide/running.html

https://docs.racket-lang.org/raco/exe.html
https://docs.racket-lang.org/raco/exe-dist.html

Hope that helps.

Kind regards,
Daniel

-- 
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] making standalone application

2016-03-19 Thread sagar tripathy
i am trying to make a software with Racket for generic use . Or ,you can say a 
complete setup for system without "DRracket" or "minimal Racket" . I do not 
know the way to achieve 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.


[racket-users] Re: Eliminating boiler plate for parallel tasks

2016-03-19 Thread Brian Adkins
On Saturday, March 19, 2016 at 11:45:46 AM UTC-4, Brian Adkins wrote:
> I've put together a very simple (31 lines) example of parallel task execution 
> here:
> 
> https://gist.github.com/lojic/6cee4fcd4220e2788ece
> 
> The example contains a lot of boilerplate (only a few lines are specific to 
> the problem), so before I go about eliminating the boilerplate myself, I 
> thought I'd ask if this has already been done in a general and reusable way - 
> has it?
> 
> I'm fairly new to parallel programming in Racket, but thus far I seem to 
> encounter the same pattern repeatedly:
> 
> 1) Create a pair of place channels to allow sending units of work to parallel 
> workers and retrieving results
> 
> 2) Create one place per core which repeatedly grabs a unit of work from the 
> queue, calls a function with the unit of work, and places the result on the 
> queue
> 
> 3) Write all the units of work to the queue
> 
> 4) Retrieve all the results from the queue
> 
> It think this can all be boiled down to specifying:
> 1) The name of the function to do the work (line 4)
> 2) The list of units of work (line 23)
> 
> The rest of the example is generic.
> 
> Thanks,
> Brian

This example is probably clearer:

https://gist.github.com/lojic/d92bd1f537410f6dc4e9

It's shorter, and by using place/context, I eliminated a lot of cruft. All of 
main is now generic.

-- 
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] Eliminating boiler plate for parallel tasks

2016-03-19 Thread Brian Adkins
I've put together a very simple (31 lines) example of parallel task execution 
here:

https://gist.github.com/lojic/6cee4fcd4220e2788ece

The example contains a lot of boilerplate (only a few lines are specific to the 
problem), so before I go about eliminating the boilerplate myself, I thought 
I'd ask if this has already been done in a general and reusable way - has it?

I'm fairly new to parallel programming in Racket, but thus far I seem to 
encounter the same pattern repeatedly:

1) Create a pair of place channels to allow sending units of work to parallel 
workers and retrieving results

2) Create one place per core which repeatedly grabs a unit of work from the 
queue, calls a function with the unit of work, and places the result on the 
queue

3) Write all the units of work to the queue

4) Retrieve all the results from the queue

It think this can all be boiled down to specifying:
1) The name of the function to do the work (line 4)
2) The list of units of work (line 23)

The rest of the example is generic.

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: custom keybindings (AltGr)

2016-03-19 Thread Robby Findler
On Thu, Mar 17, 2016 at 8:09 PM, Matthew Flatt  wrote:
> A "c:a" binding doesn't show up in the keybindings dialog for Windows,
> but it does for OS X.

I've pushed a fix this. Thanks!

Robby

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


Re: [racket-users] Setting return address in Racket's sendmail

2016-03-19 Thread George Neuner

On 3/16/2016 10:29 PM, Matthias Felleisen wrote:


This has gotten me rejection replies:

  (smtp-send-message
   (dns-get-address (dns-find-nameserver) "smtp.gmail.com 
")

   "matth...@ccs.neu.edu "
   actual-send-to-addresses
   addresses-put-into-header
   file
   #:port-no 465
   ; for gmail don't include the @gmail.com 
   #:auth-user “foobarf@"
   #:auth-passwd “XYZ"
   #:tcp-connect ssl-connect))



Gmail is a PITA.  It drove me crazy last year testing email code for my 
web application - the deployment system had a local SMTP service to use, 
but my development system didn't.



Gmail is very critical of the message format - it has to be (more or 
less) 100% correct.  If there are any errors in the message string you 
are very likely to get rejected.


No matter what "from" address you specify, the address that appears in 
the received email will that of the Gmail user.  The specified address 
appears in an extra header - "X-Google-Original-From" - but the receiver 
will never see that unless they look for it.   I have not tried using a 
"reply-to" header with Gmail.


Also, AFAIK, Gmail's SMTP server does require the domain of the 
authorized user: e.g., "foob...@gmail.com".  I was not able to make it 
work otherwise.  I think this is because there are both @gmail.com and 
@google.com addresses that it recognizes.


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] Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread 'John Clements' via Racket Users

> On Mar 16, 2016, at 5:56 AM, Daniel Prager  wrote:
> 
> Awesomely, Jens has been working on Urlang: a Racket-ish syntax for 
> JavaScript, using the nanopass compiler infrastructure:
> 
> https://github.com/soegaard/urlang

Looks very cool. I’ll use this the next time I write JS code.

Thanks!

John

> 
> and more ambitiously, a Racket (subset) ->JavaScript compiler (rjs), taking a 
> distinct approach from Whalesong.
> 
> * * *
> 
> Just using plain Urlang together with sxml, Bootstrap (for css), and notably 
> Ractive.js for templating and data-binding I made the following demo / 
> proof-of-concept:
> 
> http://htmlpreview.github.io/?https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html
> 
> Note: no heavyweight js runtime required: actually no runtime at all.
> 
> 
> Racket source: 
> https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.rkt
> 
> HTML output (including embedded JavaScript): 
> https://github.com/danprager/urlang/blob/master/urlang-examples/ractive/ractive-bootstrap-example.html
> 
> The abstractions are a bit leaky, but I'm quietly excited about where this 
> sort of approach could lead.
> 
> What do you think?
> 
> Dan
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
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: custom keybindings (AltGr)

2016-03-19 Thread Bert De Ketelaere
Hello,

this does everything I want.
The only difference is between your implementation and what I previously had 
done is that Ctrl+Alt+q is treated the same as AltGr+q (with the latter being a 
custom keybinding defined with "g:q").  I don't really care about this, but I 
thought it was nice that they were two distinct events.

Looking deeper into this, there is some other weirdness, using your file (I've 
abandoned mine):
for Ctrl+Alt+a, u or n doesn't produce anything
  Ctrl+Alt+z, m  just prints z or m
  Ctrl+Alt+t l ... opens menu Tabs, Language etc...
It's the difference between the first two that surprises me.
But defining "g:u" "g:n" "g:z" "g:t" ... as keybindings to some other letter 
works fine (with AltGr or Ctrl+Alt)
Except for "g:a" or "c:m:a".  I can't find any reason why "a" is treated 
differently (if I look in the keybindings menu it doesn't seem different from 
for example "z".  Both have only one binding "c:z" for undo and "c:a" for 
select all.)

The difference between these letters was also there when using the old key.rkt

I'm using latest snapshot ( version 6.4.0.14--2016-03-16(d27bf66/a) [3m]) and 
following keybindings
#lang s-exp framework/keybinding-lang
(keybinding "g:q" (λ (x y) (send x insert #\◊)))
(keybinding "g:a" (λ (x y) (send x insert #\A)))

to test different keybindings.
I also noticed that a "c:m:q" always trumps a "g:q" binding regardless of order.
and a "g:q" always trumps "c:m:~g:q" (regardless of Ctrl+Alt or AltGr 
combination)

Thanks for the file.  For what I want, it works just fine.
Kind regards,
Bert

Van: racket-users@googlegroups.com  namens 
Matthew Flatt 
Verzonden: donderdag 17 maart 2016 1:34
Aan: Bert De Ketelaere
CC: us...@racket-lang.org
Onderwerp: Re: [racket-users] Re: custom keybindings (AltGr)

Thanks for the helpful table!

The problem with Control combinations was a mistake in my code, fixed
in the enclosed "key.rkt".

The problem with dead keys was harder. It seems that ToUnicode() has
the same effect as TranslateEvent() for dead-key combinations, so using
ToUnicode() multiple times and in addition to TranslateEvent() triggers
the extra accents in your experiments. My new attempt uses ToUnicode()
only when it's in a position to cancel a TranslateEvent() call ---
which is always the case when we first want to get its result  and
records the result instead of calling ToUnicode() again later.

At Wed, 16 Mar 2016 08:53:48 +, Bert De Ketelaere wrote:
> Thanks for looking into this!  My implementation worked somewhat, but I was
> indeed not happy with the way I solved it. (State and losing the key release
> events)
> Just to be sure, I updated my patch a week ago for some errors I found in my
> handling of key-events, the table below is based on that revision.
>
>
> ​   ​   ​old
> bdeket​ mflat​  desired​​
> ​AltGr+qcustom keybinding​ ​​  ​◊  ​◊  ​◊
>   ​
> ​Ctrl+Alt+q ​q  ​q  ​◊  ​q  ​(normal is nothing)
>
> ​AltGr+ ​Ctrl+Alt+< ​<  ​\  \​  ​\
> ​AltGr+ù​keyboard layout
> ​dead key
> ​   ​  ù​  ​´´ ​  ​ ​ ​(my patch does 
> this ok if
> ù without modifier is used before ù with modifier, so it deserves some points,
> but probably negative ones, because of its inconsistency)
> ​followed by space
> ​´  ​ù´ ​´´´​´
> ​followed by a
> ​á  ​ùá ​´´á​á
> ​AltGr+ekeyboard layout​ ​  ​€  €​  ​€  ​€  ​(I 
> would
> expect the menu only to open for Alt+e)
> ​
> ​Ctr+Alt+e  ​
> ​€  ​€  ​€
> ​Ctr+s  ​save   ​   ​   ​  ​   ​
> ​Ctrl+c ​copy   ​   ​   ​  ​   ​
> ​Alt+arrowright ​jump to end s-expr
> ​   ​   ​   ​   ​
> ​Ctrl+Arrowright
> ​jump to end word
> ​   ​   ​   ​   ​
>
>
> I'll look at your code when I have more time tomorrow or this weekend.
>
>
> Thanks again,
>
> Bert
>
> 
> Van: racket-users@googlegroups.com  namens
> Matthew Flatt 
> Verzonden: woensdag 16 maart 2016 4:09
> Aan: Bert De Ketelaere
> CC: us...@racket-lang.org
> Onderwerp: Re: [racket-users] Re: custom keybindings (AltGr)
>
> Thanks for looking into this problem in depth! Although I'll suggest an
> alternate implementation, your patch was helpful for me to understand
> the problems and goals.
>
> To generate an event when AltGr- doesn't produce a character, I
> think a better approach here is to call ToUnicode(). That seems to work
> as a check for whether a meaning is assigned to a key combination. It
> avoids using state to try to match key-up events with key-down events,
> and it should work better with key repeats.
>
> For making Ctl-Alt- work as AltGr-, I think I see what you want,
> 

Re: [racket-users] Web server catch exceptions, print stack trace to error-logs, display simple page to user

2016-03-19 Thread Jay McCarthy
I would just make my-error-responder print out date->string's result
on current-seconds. Is that now what you want?

On Thu, Mar 17, 2016 at 2:50 PM, Marc Kaufmann
 wrote:
> Hi all,
>
> I do not want people to see "Contract violation: massive stack trace
> documenting my brilliance as a programmer" every time they hit a bug on my
> website.
>
> Currently I show them simply an error page and redirect the trace to stderr
> (see code below). But this doesn't track time of the error, and so on. Is
> there a simple way to do this (seems like it should be a common problem), or
> at least how to easily get the time-stamp from servlet-error-response
> without having to manually pipe everything to stderr?
>
> Cheers,
>
> Marc
>
> #lang racket
>
> (require ...)
>
> (define error-response
>   (response/xexpr
> `(html
>,(html-head "Error")
>(body
>  (h1 "An error occurred")
>  (p "We are sorry, but an error occurred.")
>  (p "Please contact the person who is responsible for this mess to
> fix it.")
>
> (define (my-error-responder url exn)
>   ((response-output (servlet-error-responder url exn)) (current-error-port))
>   error-response)
>
> (serve/servlet start
>#:log-file (build-path "local.logs")
>#:servlet-path "/"
>#:launch-browser? #f
>#:servlet-regexp #rx""
>#:extra-files-paths (list (build-path "htdocs"))
>#:servlet-responder my-error-responder
>)
>
>
> --
> 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.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 64:33

-- 
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: string-join vs string-append

2016-03-19 Thread Arnel
On Thu, 17 Mar 2016 13:20:34 -0500, Vincent St-Amour
 wrote:
> On Thu, 17 Mar 2016 13:08:44 -0500,
> Arnel wrote:
> > 
> > Hi,
> > 
> > How does 'string-join' differ from 'string-append'? More specifically, why 
> > does
> > the following code:
> > 
> > (let ([z ""]
> >   [y "b"])
> >   (string-join '(z y) "\n"))
> > 
> > result in a contract violation, yet the following:
> > 
> > (let ([z ""]
> >   [y "b"])
> >   (string-append z y))
> > 
> > works without any issues. (It's not necessarily the result I wanted, but I 
> > can
> > work around it.) Isn't '(z y) essentially a list of strings?
> 
> '(z y) is not a list of strings. It's a list with two symbols, 'z and 'y.
> (list z y) will be a list with the two strings you want.
> 
> The quote form does create a list in this case, but it does not evaluate
> any of its subforms. Hence why you get symbols, as opposed to the values
> of your variables.
> 
> Vincent

"In that moment, the monk was enlightened."

Thanks, Vincent.


Thank you,
Arnel

-- 
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] Setting return address in Racket's sendmail

2016-03-19 Thread Marc Kaufmann
Thanks, the smtp works, and it seems that sendmail actually does work even
the way I used it, but the email I used landed in spam, because google
realized it hadn't been sent from that account (since I was bypassing it,
unlike the smtp solution, which logs into the account first).

Matthew, regarding your point, the #f actually gets replaced by sendmail by
the email address associated with the account (which needs to be set), so
that wasn't the issue.

Best,
Marc

On Wed, Mar 16, 2016 at 10:29 PM, Matthias Felleisen 
wrote:

>
> This has gotten me rejection replies:
>
>   (smtp-send-message
>(dns-get-address (dns-find-nameserver) "smtp.gmail.com")
>"matth...@ccs.neu.edu"
>actual-send-to-addresses
>addresses-put-into-header
>file
>#:port-no 465
>; for gmail don't include the @gmail.com
>#:auth-user “foobarf@"
>#:auth-passwd “XYZ"
>#:tcp-connect ssl-connect))
>
>
>
> On Mar 16, 2016, at 8:35 PM, Marc Kaufmann 
> wrote:
>
> Hi all,
>
> I am using send-mail-message as follows:
>
> #lang racket
>
> (require net/sendmail)
> (send-mail-message
>  #f "Test sendmail"
>  '("fake-em...@marcs-server.com")
>  '()
>  '()
>  '("Testing Racket sendmail."))
>
> It works as expected when I send something to myself, since sendmail goes
> and gets the email associated with my user. But when I send it to a
> non-existing email, I do not get a notification that it wasn't delivered.
>
> Is there a way to set the return address? I presume it goes into the
> extra-header argument, but I am not sure.
>
> Thanks,
> Marc
>
>
> --
> 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] Re: Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Jens Axel Søgaard
2016-03-16 22:50 GMT+01:00 Greg Trzeciak :

> "Urlang is a Racket flavoured S-expression syntax for Javascript"
>

Can I steal that for a tag-line?


> Thank you for your explanation - still seems like a good fit for one of my
> projects (as I needed something more lightweight than Whalesong) so I will
> try it out shortly.
>

Sounds great. Don't hesitate to send feedback.

/Jens Axel

-- 
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] colorizing code in html - scribble or the GUI?

2016-03-19 Thread Sanjeev Sharma
thanks folks - marked completed but please share more if there are more 

I was going to use hilite.me but I prefer having something resembling the 
racket documents

-- 
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: custom keybindings (AltGr)

2016-03-19 Thread Matthew Flatt
I think the issue with Control-Alt-a is that Control-a is mapped to
"beginning-of-line" as "c:a". Probably that should be ":c:a". 

A "c:a" binding doesn't show up in the keybindings dialog for Windows,
but it does for OS X. My guess is that the keybindings list is filtered
to omit combinations that are shadowed by menu shortcuts (even though I
have menu shortcuts disabled on Windows). The menu shortcut for "Select
All" is actually ":c:a", so that shortcut only partly shadows "c:a".
Then again, the "c:u" and "c:n" combinations do show up in the
keybindings dialog, so maybe my guess isn't quite right.

In any case, I've pushed the changes. When you start using the latest
(e.g., with the next snapshot build or later), you could go to
"Editing" -> "General Editing" in the preferences dialog, select "Treat
Control-Alt combination as AltGr", and then make sure things work as
expected.

At Thu, 17 Mar 2016 08:58:01 +, Bert De Ketelaere wrote:
> Hello,
> 
> this does everything I want.
> The only difference is between your implementation and what I previously had 
> done is that Ctrl+Alt+q is treated the same as AltGr+q (with the latter being 
> a custom keybinding defined with "g:q").  I don't really care about this, but 
> I thought it was nice that they were two distinct events.
> 
> Looking deeper into this, there is some other weirdness, using your file 
> (I've 
> abandoned mine):
> for Ctrl+Alt+a, u or n doesn't produce anything
>   Ctrl+Alt+z, m  just prints z or m
>   Ctrl+Alt+t l ... opens menu Tabs, Language etc...
> It's the difference between the first two that surprises me.
> But defining "g:u" "g:n" "g:z" "g:t" ... as keybindings to some other letter 
> works fine (with AltGr or Ctrl+Alt)
> Except for "g:a" or "c:m:a".  I can't find any reason why "a" is treated 
> differently (if I look in the keybindings menu it doesn't seem different from 
> for example "z".  Both have only one binding "c:z" for undo and "c:a" for 
> select all.)
> 
> The difference between these letters was also there when using the old key.rkt
> 
> I'm using latest snapshot ( version 6.4.0.14--2016-03-16(d27bf66/a) [3m]) and 
> following keybindings
> #lang s-exp framework/keybinding-lang
> (keybinding "g:q" (λ (x y) (send x insert #\◊)))
> (keybinding "g:a" (λ (x y) (send x insert #\A)))
> 
> to test different keybindings.
> I also noticed that a "c:m:q" always trumps a "g:q" binding regardless of 
> order.
> and a "g:q" always trumps "c:m:~g:q" (regardless of Ctrl+Alt or AltGr 
> combination)
> 
> Thanks for the file.  For what I want, it works just fine.
> Kind regards,
> Bert
> 
> Van: racket-users@googlegroups.com  namens 
> Matthew Flatt 
> Verzonden: donderdag 17 maart 2016 1:34
> Aan: Bert De Ketelaere
> CC: us...@racket-lang.org
> Onderwerp: Re: [racket-users] Re: custom keybindings (AltGr)
> 
> Thanks for the helpful table!
> 
> The problem with Control combinations was a mistake in my code, fixed
> in the enclosed "key.rkt".
> 
> The problem with dead keys was harder. It seems that ToUnicode() has
> the same effect as TranslateEvent() for dead-key combinations, so using
> ToUnicode() multiple times and in addition to TranslateEvent() triggers
> the extra accents in your experiments. My new attempt uses ToUnicode()
> only when it's in a position to cancel a TranslateEvent() call ---
> which is always the case when we first want to get its result  and
> records the result instead of calling ToUnicode() again later.
> 
> At Wed, 16 Mar 2016 08:53:48 +, Bert De Ketelaere wrote:
> > Thanks for looking into this!  My implementation worked somewhat, but I was
> > indeed not happy with the way I solved it. (State and losing the key release
> > events)
> > Just to be sure, I updated my patch a week ago for some errors I found in my
> > handling of key-events, the table below is based on that revision.
> >
> >
> > ​   ​   ​old
> > bdeket​ mflat​  desired​​
> > ​AltGr+qcustom keybinding​ ​​  ​◊  ​◊  ​◊  
> > ​
> > ​Ctrl+Alt+q ​q  ​q  ​◊  ​q  ​(normal is nothing)
> >
> > ​AltGr+ > ​Ctrl+Alt+< ​<  ​\  \​  ​\
> > ​AltGr+ù​keyboard layout
> > ​dead key
> > ​   ​  ù​  ​´´ ​  ​ ​ ​(my patch does 
> > this ok 
> if
> > ù without modifier is used before ù with modifier, so it deserves some 
> points,
> > but probably negative ones, because of its inconsistency)
> > ​followed by space
> > ​´  ​ù´ ​´´´​´
> > ​followed by a
> > ​á  ​ùá ​´´á​á
> > ​AltGr+ekeyboard layout​ ​  ​€  €​  ​€  ​€  ​(I 
> > would
> > expect the menu only to open for Alt+e)
> > ​
> > ​Ctr+Alt+e  ​
> > ​€  ​€  ​€
> > ​Ctr+s  ​save   ​   ​   ​  ​   ​
> > ​Ctrl+c ​copy   ​   ​   ​ 

[racket-users] dynamic-require

2016-03-19 Thread Jos Koot
Hi,
 
The following example of dynamic-require in the reference manual works in
the interactions window of DrRacket, but not in its definitions window:
 
(module a racket/base (displayln "hello")) 
(dynamic-require ''a #f)
 
How do I do this in the definitions window?
 
The reason I use dynamic-require is that I want to set some parameters
before submod a is executed.
 
I found out I can do the following:
 
#lang racket
(module a racket/base (displayln "hello"))
(module b racket/base (current-output-port (open-output-file ...)))
(require 'b)
(require 'a)
 
To me this seems an ugly trick.
In addition I am not sure this is guaranteed to work consistently.
How can I dynamically require a submod in the same source as it is defined?
 
Jos

-- 
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: Racket -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Jens Axel Søgaard
2016-03-16 22:18 GMT+01:00 Greg Trzeciak :

>
> Thanks Dan, seems to be exactly what I need (especially the combination
> with ractive.js! BTW you couldn't find js framework with name more fitting
> to work with racket ;)
> I am only curious what racket subset does urlang include or rather what
> won't work in urlang.


Hi Greg,

Think of Urlang as JavaScript with s-expression syntax.
The core urlang language includes constructs that mirror JavaScript almost
one-to-one.
So Urlang is not "Racket to JavaScript compiler".

There are few miniscule differences:
-   functions support optional arguments
-  The = operator generates === in JavaScript
-  if will only count the false  value as false (zero is not considered
to be true)

That said: Urlang does support macros, which means you can write
constructs that expand into core Urlang.

In urlang/for you will find a Racket-ish for constructs.
That is  for, for*, for/sum, for*/sum etc

https://github.com/soegaard/urlang/blob/master/urlang/for.rkt

In urlang/extra you will find some often used macros:

These constructs can be used as expressions:

; (begin0 expr statement ...)
; (when   test statement ... expr)
; (unless test statement ... expr)

; (cond [test statement ... expr] ...)
; (case val-expr clause ...)
;  where clause is  [(datum ...) statement ... expr]
;   or  [elsestatement ... expr]
; (letrec ([id val-expr] ...) statement ... expr)
; (let*   ([id val-expr] ...) statement ... expr)

;; These constructs can be used as statements:
; (swhen   test statement ...)
; (sunless test statement ...)
; (scond  [test statement ...] ...)

https://github.com/soegaard/urlang/blob/master/urlang/extra.rkt

We are working on making some more examples.

/Jens Axel

-- 
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: custom keybindings (AltGr)

2016-03-19 Thread Matthew Flatt
Thanks for the helpful table!

The problem with Control combinations was a mistake in my code, fixed
in the enclosed "key.rkt".

The problem with dead keys was harder. It seems that ToUnicode() has
the same effect as TranslateEvent() for dead-key combinations, so using
ToUnicode() multiple times and in addition to TranslateEvent() triggers
the extra accents in your experiments. My new attempt uses ToUnicode()
only when it's in a position to cancel a TranslateEvent() call ---
which is always the case when we first want to get its result  and
records the result instead of calling ToUnicode() again later.

At Wed, 16 Mar 2016 08:53:48 +, Bert De Ketelaere wrote:
> Thanks for looking into this!  My implementation worked somewhat, but I was 
> indeed not happy with the way I solved it. (State and losing the key release 
> events)
> Just to be sure, I updated my patch a week ago for some errors I found in my 
> handling of key-events, the table below is based on that revision.
> 
> 
> ​   ​   ​old
> bdeket​ mflat​  desired​​
> ​AltGr+qcustom keybinding​ ​​  ​◊  ​◊  ​◊
>   ​
> ​Ctrl+Alt+q ​q  ​q  ​◊  ​q  ​(normal is nothing)
> 
> ​AltGr+ ​Ctrl+Alt+< ​<  ​\  \​  ​\
> ​AltGr+ù​keyboard layout
> ​dead key
> ​   ​  ù​  ​´´ ​  ​ ​ ​(my patch does 
> this ok if 
> ù without modifier is used before ù with modifier, so it deserves some 
> points, 
> but probably negative ones, because of its inconsistency)
> ​followed by space
> ​´  ​ù´ ​´´´​´
> ​followed by a
> ​á  ​ùá ​´´á​á
> ​AltGr+ekeyboard layout​ ​  ​€  €​  ​€  ​€  ​(I 
> would 
> expect the menu only to open for Alt+e)
> ​
> ​Ctr+Alt+e  ​
> ​€  ​€  ​€
> ​Ctr+s  ​save   ​   ​   ​  ​   ​
> ​Ctrl+c ​copy   ​   ​   ​  ​   ​
> ​Alt+arrowright ​jump to end s-expr
> ​   ​   ​   ​   ​
> ​Ctrl+Arrowright
> ​jump to end word
> ​   ​   ​   ​   ​
> 
> 
> I'll look at your code when I have more time tomorrow or this weekend.
> 
> 
> Thanks again,
> 
> Bert
> 
> 
> Van: racket-users@googlegroups.com  namens 
> Matthew Flatt 
> Verzonden: woensdag 16 maart 2016 4:09
> Aan: Bert De Ketelaere
> CC: us...@racket-lang.org
> Onderwerp: Re: [racket-users] Re: custom keybindings (AltGr)
> 
> Thanks for looking into this problem in depth! Although I'll suggest an
> alternate implementation, your patch was helpful for me to understand
> the problems and goals.
> 
> To generate an event when AltGr- doesn't produce a character, I
> think a better approach here is to call ToUnicode(). That seems to work
> as a check for whether a meaning is assigned to a key combination. It
> avoids using state to try to match key-up events with key-down events,
> and it should work better with key repeats.
> 
> For making Ctl-Alt- work as AltGr-, I think I see what you want,
> based on how programs like Notepad interpret key combinations. I think
> other users will still want to distinguish Ctl-Alt- and AltGr-
> for keyboard shortcuts, though, along the same lines that Emacs
> distinguishes them. So we'll probably need to make that an option,
> similar to the `special-option-key` setting for OS X.
> 
> Can you try the enclosed "key.rkt" to see whether it works the way you
> want? This version defines `control+alt-always-as-altgr?` as #t to
> simulate an option for making Ctl-Alt- work as AltGr-.
> 
> At Mon, 7 Mar 2016 15:16:23 +, Bert De Ketelaere wrote:
> > Hello,
> >
> >
> > after looking around trying to fix my previous
> > 
> problem
> > I found that DrRacket really is not sending any event for AltGr+(Key x)
> > combinations if this combination doesn't actually produces a char.
> >
> > I tried changing the win32/key.rkt file in gui-lib so DrRacket would get 
> these
> > events and en passant I tried to make DrRacket behave more like other Win
> > programs when it comes to keyboard input.
> >
> >
> > my attempt is at:
> >
> > https://github.com/bdeket/gui/commit/994a5655a9f913b7388e0c74c1b6203659b645d3
> >
> >
> > A few problems remain:
> >
> > Ctrl+Alt+(key x): where this combination doesn't produce a char, x is 
> produced
> > instead of nothing
> >
> > Ctrl+Alt+(key x) or AltGr+(key x): the release event is now hijacked and 
> sends
> > another keypress-event.
> >
> > This is a problem, but I don't know how to fix this, and I prefer this
> > over the previous state where key-events where ignored
> >
> >
> > Unfortunately I didn't understand all the code that was already there, and I
> > didn't find standard tests to test this.
> >
> > Are there tests for the key-events?
> >
> >
> > Kind regards,
> >
> > Bert
> >
> > --
> > 

Re: [racket-users] predicate as an atom within a regexp?

2016-03-19 Thread Andrew Gwozdziewycz
On Thu, Mar 17, 2016 at 1:27 PM, Matthew Butterick  wrote:

> What is the best approach to destructuring strings using predicates? For
> instance "match a substring for which `string->number` is true."
>
>
I am imagining an API that utilizes SCSH style regexes but allows you to do
something like this (fictional):

(define-values (area prefix line) (sre-match (: (= digits 3) (_? "-") (=
digits 3) (_? "-") (= digits 3

The `_` at the head of each component would essentially operate like `_`
does in structural pattern matching (e.g. ignore), but give you the ability
to specify a regexp that you are ignoring.

This may not be exactly what you are thinking of, but it's the half baked
idea that came to mind... The API, would also be pretty damn ugly.

-- 
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 -> HTML+JavaScript using Urlang and Ractive

2016-03-19 Thread Matthew Butterick
> and more ambitiously, a Racket (subset) ->JavaScript compiler (rjs), taking a 
> distinct approach from Whalesong.


The short answer: +1

The longer: I am no fan of JavaScript, which I consider a brain-eating virus. 
[1] But IMO the "frameworkification" of JS has made it even worse. Yes, the 
wheel-reinvention critique is also leveled at Lisps. But never have so many 
devoted so much effort to creating ever-larger elephants to crush ever-smaller 
peanuts. [2] 

And yes, I maintain a package called `sugar`. Dry humor intended. Would that JS 
frameworks acknowledged their place in the world. Which is mostly to create 
mutually unintelligible dialects of JS.

Today, I use Pollen as a JS preprocessor. [3] That's a lot better than JS 
alone. But I notice that 90% of my JS code uses 10% of the language. The usual: 
variables, loops, functions. Manipulation of the DOM. Async requests. The idea 
of a subset of Racket that compiles to this kind of statistically probable 
subset of JS is very appealing. Especially if it can obviate the need or should 
I say "need" for a JS framework.


[1] https://youtu.be/20GGVNBykaw?t=128
[2] http://stackoverflow.com/questions/3811678/add-two-variables-using-jquery
[3] http://pollenpub.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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Setting return address in Racket's sendmail

2016-03-19 Thread Marc Kaufmann
Hi all,

I am using send-mail-message as follows:

#lang racket

(require net/sendmail)
(send-mail-message
 #f "Test sendmail"
 '("fake-em...@marcs-server.com")
 '()
 '()
 '("Testing Racket sendmail."))

It works as expected when I send something to myself, since sendmail goes
and gets the email associated with my user. But when I send it to a
non-existing email, I do not get a notification that it wasn't delivered.

Is there a way to set the return address? I presume it goes into the
extra-header argument, but I am not sure.

Thanks,
Marc

-- 
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] dynamic-require

2016-03-19 Thread Jos Koot
Thanks very much.
I'll try that.
I wonder what happens when I already have a file test.rkt in the current
directory,
but I'll find out.
Thanks again, Jos.

  _  

From: Scott Moore [mailto:sc...@thinkmoore.net] 
Sent: miércoles, 16 de marzo de 2016 18:03
To: Jos Koot; Racket Users
Cc: Jos Koot
Subject: Re: [racket-users] dynamic-require


If the definitions are saved as “test.rkt”, the following works:

#lang racket

(module a racket/base (displayln "hello"))
(dynamic-require '(submod "test.rkt" a) #f)

I also tried (dynamic-require ‘(submod “.” a) #f) which I expected to work,
but it didn’t.


On March 16, 2016 at 12:13:46 PM, Jos Koot (jos.k...@gmail.com) wrote:


Hi,
 
The following example of dynamic-require in the reference manual works in
the interactions window of DrRacket, but not in its definitions window:
 
(module a racket/base (displayln "hello"))
(dynamic-require ''a #f)
 
How do I do this in the definitions window?
 
The reason I use dynamic-require is that I want to set some parameters
before submod a is executed.
 
I found out I can do the following:
 
#lang racket
(module a racket/base (displayln "hello"))
(module b racket/base (current-output-port (open-output-file ...)))
(require 'b)
(require 'a)
 
To me this seems an ugly trick.
In addition I am not sure this is guaranteed to work consistently.
How can I dynamically require a submod in the same source as it is defined?
 
Jos
--
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] Web server catch exceptions, print stack trace to error-logs, display simple page to user

2016-03-19 Thread Marc Kaufmann
Yep, printing that out is indeed all I want. I hadn't thought about the
fact that 'print and 'display will show up in standard output.

John, how do you use drrackt's log handlers, are you running the server via
Drracket or did you mean something different.

I can't use daemontools for reasons to do with permissions, but I will have
access to supervisord, which seems to be doing the same type of tasks.

On Thu, Mar 17, 2016 at 4:46 PM, John Clements 
wrote:

>
> > On Mar 17, 2016, at 11:50 AM, Marc Kaufmann 
> wrote:
> >
> > Hi all,
> >
> > I do not want people to see "Contract violation: massive stack trace
> documenting my brilliance as a programmer" every time they hit a bug on my
> website.
> >
> > Currently I show them simply an error page and redirect the trace to
> stderr (see code below). But this doesn't track time of the error, and so
> on. Is there a simple way to do this (seems like it should be a common
> problem), or at least how to easily get the time-stamp from
> servlet-error-response without having to manually pipe everything to stderr?
>
> I think this problem is one of the ones that falls into the “Lisp crack”:
> specifically, implementing your own solution is sufficiently easy that
> building a general-purpose solution winds up being more trouble than it’s
> worth, and never quite covers all of the various users’ requirements. Of
> course, this leads to lack of standardization.
>
> For me, I use drracket’s log handlers, make sure that everything winds up
> on stdout, and then use ‘multilog’ from ‘daemontools’ to take care of
> timestamps, partitioning (if desired) and log rotation.
>
> 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.