[racket-users] Racket Document Translation

2018-11-30 Thread Mr. Lambda
Is there any plan to translate current document of Racket to other language.
If true ,how could the translator contribute to the document

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


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

2018-11-30 Thread Brian Adkins
Jay:

Thanks for taking the time to educate me a bit. I expect you are right 
regarding some/most of my concerns being due to misunderstandings on my 
part. Despite playing with Racket for a few years, it wasn't until this 
particular project (with a deadline) that I really began to dig in more 
deeply. I admit I don't yet fully understand continuations in general, let 
alone in the context of the web server, but I've had great success with the 
stateless approach that Rails uses.

I've been bitten by "leaky abstractions" in the past, and Rails uses a lot 
of "magic" that mostly works well, but sometimes does not, so I'm trying to 
better understand the foundation I'll be building upon with Racket along 
with the pros/cons of various approaches. Having said that, I wouldn't at 
all be surprised if I end up using some of the stateless functionality 
you've developed in the future. And I have some apps that may benefit from 
stateful continuations, so I'll be experimenting with that after this 
initial project.

Using the lift dispatcher directly didn't feel quite right, so I'll look 
into dispatch/servlet. Will dispatch/servlet spin up a thread for each 
request as serve/servlet does? If so, that will save me from handling the 
request threading myself. I don't think I need a stuffer or manager though, 
so I'm not sure dispatch/sev

I don't know if the Racket web server (or related libraries) currently 
provide a way to stream data in the response, but that is something I'll 
definitely need relatively soon (primarily for streaming large CSV/JSON 
files). If it doesn't exist, I don't mind writing it, but I also don't want 
to begin with an approach now that might make adding that capability more 
difficult later. From my brief research, given the output field of the 
response struct is a lambda, I think I can stream using that (i.e. return a 
lambda in the response immediately that begins writing the data as it 
retrieves it) - hopefully the infrastructure doesn't buffer the entire 
output. Other than something like that, I'm happy to work mostly at the 
level of functions from requests to responses.

I will need full control over the URL, and I thought I read somewhere that 
some servlets needed to use the URL for state in some cases. That wouldn't 
work for me.

I'm confused about your statement, "...make it easy to do stuff like 
encrypt and sign the state you store on the clients". I would think 
encrypting and signing something would be simple function calls unrelated 
to whether I'm using servlets or not. Is this not the case? My client-side 
state needs are minimal - typically a session ID is sufficient. I wasn't 
aware of functionality built-in to the web server for this, so I just 
assumed I would have a secret key on the server that I'd use to encrypt 
state. I haven't gotten that far yet.

I had to look up send/suspend, etc., and I don't think I'd be using 
anything like that.

Thanks,
Brian

On Friday, November 30, 2018 at 8:25:40 PM UTC-5, Jay McCarthy wrote:
>
> Hi Brian, 
>
> I think you are misunderstanding what that section is about. It is 
> just describing how the system is implemented.  There's basically 
> nothing in there that you need to know as user other than "It may take 
> a while to compile." For instance, you don't worry about the fact that 
> all tree-like functions in your normal Racket code are eventually 
> turned into linear sequences of assembly. Those changes to your code 
> discussed in 3.2 are things that happen in the compiler, you don't 
> need to do anything, just like you don't need to think about register 
> allocation when you write normal programs, but it happens behind the 
> scenes. 
>
> Nothing described in section 3 happens to your code unless you write 
> in `#lang web-server` or `#lang web-server/base`. You can use or not 
> use continuations and use or not use this library... they are totally 
> orthogonal. There is basically no program that you can write in one 
> that you can't write in the other, as long as you call the appropriate 
> version of `send/suspend`. 
>
> The whole point of this library is to write code as-if it were 
> stateful, but the compiler automatically makes it stateless. If you 
> are comfortable programming directly with inverted control, then go 
> right ahead and implement the stateless stuff yourself. Both ways are 
> going to be equally efficient, although the `#lang web-server` library 
> will be guaranteed to do it correctly and make it easy to do stuff 
> like encrypt and sign the state you store on the clients. 
>
> As far as using `serve/servlet` or not, the implementation of it is 
> really simple [1] in case you want to adapt it. I don't recommend 
> using the lift dispatcher directly. You probably want to use 
> `dispatch/servlet`. Remember, in Racket, a servlet is just a function 
> from request to response, with some resource control. It doesn't 
> impose any programming style or other costs on you. I get the 
> 

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

2018-11-30 Thread Jay McCarthy
Hi Brian,

I think you are misunderstanding what that section is about. It is
just describing how the system is implemented.  There's basically
nothing in there that you need to know as user other than "It may take
a while to compile." For instance, you don't worry about the fact that
all tree-like functions in your normal Racket code are eventually
turned into linear sequences of assembly. Those changes to your code
discussed in 3.2 are things that happen in the compiler, you don't
need to do anything, just like you don't need to think about register
allocation when you write normal programs, but it happens behind the
scenes.

Nothing described in section 3 happens to your code unless you write
in `#lang web-server` or `#lang web-server/base`. You can use or not
use continuations and use or not use this library... they are totally
orthogonal. There is basically no program that you can write in one
that you can't write in the other, as long as you call the appropriate
version of `send/suspend`.

The whole point of this library is to write code as-if it were
stateful, but the compiler automatically makes it stateless. If you
are comfortable programming directly with inverted control, then go
right ahead and implement the stateless stuff yourself. Both ways are
going to be equally efficient, although the `#lang web-server` library
will be guaranteed to do it correctly and make it easy to do stuff
like encrypt and sign the state you store on the clients.

As far as using `serve/servlet` or not, the implementation of it is
really simple [1] in case you want to adapt it. I don't recommend
using the lift dispatcher directly. You probably want to use
`dispatch/servlet`. Remember, in Racket, a servlet is just a function
from request to response, with some resource control. It doesn't
impose any programming style or other costs on you. I get the
impression from your comments that you are really nervous about some
sort of costs imposed by using Racket libraries and think you will get
some benefit by being "low-level". This is probably misguided and just
based on some misunderstandings.

Jay

1. 
https://github.com/racket/web-server/blob/master/web-server-lib/web-server/servlet-env.rkt#L156

On Fri, Nov 30, 2018 at 4:30 PM Brian Adkins  wrote:
>
> I could be misreading the information in "3.2 Usage Considerations", but it 
> seemed like the modifications to my program were automatic, but maybe that 
> only happens when using #lang web-server or #lang web-server/base ?
>
> Regardless, I'm wondering if maybe I should just use (serve) instead of 
> (serve/servlet) since I'll likely be working at that level later anyway. In 
> that case, it looks like dispatch-lift:make is the main thing I need to get 
> things rolling. As a simple example:
>
> #lang racket
> (require web-server/web-server)
> (require web-server/http/response-structs)
> (require (prefix-in log: web-server/dispatchers/dispatch-log))
> (require (prefix-in lift: web-server/dispatchers/dispatch-lift))
> (require (prefix-in seq: web-server/dispatchers/dispatch-sequencer))
> (require (prefix-in stat: web-server/dispatchers/dispatch-stat))
>
> (define (controller request)
>   (response
>200
>#"OK"
>(current-seconds)
>TEXT/HTML-MIME-TYPE
>empty
>(λ (op) (write-bytes #"Hello, World!" op
>
> (serve
>  #:dispatch (seq:make (log:make #:format log:extended-format
> #:log-path "development.log") ; log request
>   (stat:make) ; print memory usage
>   (lift:make controller))
>  #:port 8080)
>
> To be clear, it's not just continuations that I want to avoid, I'd also like 
> to avoid the changes that are described in section 3.2 above.
>
>
> On Friday, November 30, 2018 at 3:20:39 PM UTC-5, Jay McCarthy wrote:
>>
>> There's nothing wrong with ignoring the continuation support in the
>> Web server, either the native ones or stateless ones. If you do, I
>> recommend using something like `create-none-manager` [1]  as the
>> `#:manager` argument to `serve/servlet` so that you don't accidentally
>> start using them. The "too far" line is that you can't use
>> `send/suspend`. In the web-server/servlet/web [2] module, you just
>> want to use `send/back` and `with-errors-to-browser`, and no other
>> functions.
>>
>> Jay
>>
>> 1. 
>> https://docs.racket-lang.org/web-server/servlet.html?q=none-manager#%28def._%28%28lib._web-server%2Fmanagers%2Fnone..rkt%29._create-none-manager%29%29
>> 2. 
>> https://docs.racket-lang.org/web-server/servlet.html?q=send%2Fsuspend#%28part._web%29
>> On Fri, Nov 30, 2018 at 2:17 PM Brian Adkins  wrote:
>> >
>> > A while ago, I read Jay's response about how to use the Racket web server 
>> > w/o continuations here:
>> >
>> > https://groups.google.com/forum/#!msg/racket-users/bTBj-RbMLDA/k80HNazuFAAJ
>> >
>> > At the time, I didn't dig very deeply into it and just assumed avoiding 
>> > web-server/servlet would be sufficient, but I just read through the 

[racket-users] Re: embedded api docs and the `doc` submodule

2018-11-30 Thread Alex Harsanyi


On Wednesday, November 28, 2018 at 12:10:18 AM UTC+8, Neil Van Dyke wrote:
>
> What do people think about the following way of providing Scribble API 
> documentation from a module? 
>
>
Scribble can already be used to document Racket packages and the `scrdoc`
modules can be used by people who wish to put the documentation together in
the source code.  It is not clear from you email (1) what do you perceive as
problems with the existing system, (2) how your proposed solution will 
address
those problems.

 

> BTW, the context of this is query is that I'm refining some optional 
> "lightweight language" tweaks to a `#lang` that's mostly `racket/base`.  
> This would initially be focused on simplifying some good routine 
> practices for unit testing, documentation, and then `info` metadata.  
>


What is the problem the existing unit testing, documentation and `info`
metadata practices and why do they need simplifying?

 

> This would interoperate with all the other `#lang`s, but some people 
> will find it much more convenient than `#lang racket` when building 
> systems out of components made from the start to be reusable. 
>
>
What are the current inconveniences for reusing Racket components, by which
I assume you mean packages?  Or do you mean that the existing racket 
packages
are not reusable?  And what does "from the start" even mean?
 
Best Regards,
Alex.

-- 
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] Thoughts/questions on the DOS package

2018-11-30 Thread Christopher Lemmer Webber
Hello all,

This is a conversation I had with Jay earlier earlier this month.  I
asked if I could forward it and Jay said that's fine, so I'm doing so in
case it's of use to anyone else.

For those not in the know, Jay's DOS package stands for
"Delimited-continuation-based Operating-system Simulator" and the docs
can be found here:

  https://docs.racket-lang.org/dos/

I presume some inspiration has been taken from "Delimited Continuations
in Operating Systems" though I have not confirmed with Jay:

  http://okmij.org/ftp/continuations/ZFS/context-OS.pdf

Anyway, for the most part what it's currently used for is defining a
functional way to do game behavior using prompts in one of several
layers... I was trying to figure out how I might do some more complex
game behavior and so hence this email exchange.  I'm still processing
it, admittedly ;)

Anyway, maybe you'll find it interesting or useful!

Jay McCarthy writes:

> Your understanding at last isn't correct :)
>
> The environment after one round of `win-boot` (and the state after one
> round of `os2-boot` or `dos-boot`) is always the result of the monoid
> operation. In the case of `win`, that means that the various
> environment updates that each process writes are merged. If there is a
> key `k1` in the old environment that is not written in the current
> round, then it is not included at all in the next one.
>
> ```
> #lang racket/base
> (require dos/win)
>
> (module+ test
>   (define w
> (win-boot
>  (win-env-replace
>   (win-mbr
>(λ (old-env)
>  (win-write 'new-key
> (add1 (env-read1 old-env 'old-key 0)
>   'old-key (list 41
>
>   (require chk)
>   (chk (win-env-read w 'old-key) '()
>(win-env-read w 'new-key) '(42)))
> ```
>
> As far as your conversation...
>
> First, the `win` environment is strictly for global things. If you
> want local things, then you can use the closed-over state of the
> continuation for that. For example, in the win test, the
> `mouse-tracking-ball` function is using the `r` parameter to have its
> own internal state. It calls itself with `env-write`, which returns
> the environment after synchronization with all the other entities
> (i.e. at the next frame.) This means that the `r` part and the
> control-state of what the ball is doing is embedded in the captured
> continuation.
>
> So, in your example, there's two ways I look at it.
>
> In one case, the player state is global, so there are two effects
> posted a (was-damaged amount) and (was-upgraded amount) and the monoid
> operation has to determine what the effect is. You could reproduce the
> race condition by saying that that the monoid plus is (lambda (x y) x)
> or (lambda (x y) y) and just ignore one of them. (The idea, btw, of
> the the win environment being a set is that most consumers will
> `foldr` the result and have a monoid per key.) Or, you could actually
> inspect the values and have a rule like "teleport always goes first,
> otherwise sum effects." Etc.
>
> In the other case, the player state is local and the collision
> information is global, so the player update process should consult
> that information and you need to decide how to deal with multiple
> collisions at the same time inside that function.
>
> Basically, the first case is where the objects (missiles) read the
> player state and try to update it but the changes must be merged. In
> the second case, the player reads about the missiles and decides how
> it will update its state.
>
> The dos model allows all behaviors that race conditions/etc provide,
> but you have to be a little more particular about what you want.
>
> On Sun, Nov 11, 2018 at 11:58 AM Christopher Lemmer Webber
>  wrote:
>>
>> Aha!  It's clear to me at last.
>>
>> If any process writes to the registry on that turn, they participate
>> in overwriting the value... if multiple processes write, multiple values
>> are written, but if it's just one it's just a list of one value.  If
>> nobody writes to that key, it doesn't change that turn!
>>
>> Christopher Lemmer Webber writes:
>>
>> > Hello Jay,
>> >
>> > I've read through all of the DOS code and docs now.  It's beautiful
>> > stuff!  I love that the main kernel is 50 readable lines and the layers
>> > on top of it aren't much larger.
>> >
>> > The only thing I think I don't understand at this point is the code in
>> > the big-bang usage of the Win example.  From my reading, on each "turn"
>> > a process takes for both mouse-tracking-ball and decaying-ball it's
>> > performing win-write to gfx, adding a new thing to render.
>> >
>> > The problem is, between "runs" of the big-bang, how does gfx get reset
>> > in any way so that the old values in gfx just don't sit around?  I don't
>> > see anything that looks like it should reset gfx, and yet every round
>> > the "canvas" does seem to be like it's running fresh.
>> >
>> > Unless, I guess, if each process is allowed to write a single value to
>> > the "set" of 

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

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

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

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

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

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

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


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

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

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

2018-11-30 Thread Jay McCarthy
There's nothing wrong with ignoring the continuation support in the
Web server, either the native ones or stateless ones. If you do, I
recommend using something like `create-none-manager` [1]  as the
`#:manager` argument to `serve/servlet` so that you don't accidentally
start using them. The "too far" line is that you can't use
`send/suspend`. In the web-server/servlet/web [2] module, you just
want to use `send/back` and `with-errors-to-browser`, and no other
functions.

Jay

1. 
https://docs.racket-lang.org/web-server/servlet.html?q=none-manager#%28def._%28%28lib._web-server%2Fmanagers%2Fnone..rkt%29._create-none-manager%29%29
2. 
https://docs.racket-lang.org/web-server/servlet.html?q=send%2Fsuspend#%28part._web%29
On Fri, Nov 30, 2018 at 2:17 PM Brian Adkins  wrote:
>
> A while ago, I read Jay's response about how to use the Racket web server w/o 
> continuations here:
>
> https://groups.google.com/forum/#!msg/racket-users/bTBj-RbMLDA/k80HNazuFAAJ
>
> At the time, I didn't dig very deeply into it and just assumed avoiding 
> web-server/servlet would be sufficient, but I just read through the 
> documentation on stateless servlets here:
>
> https://docs.racket-lang.org/web-server/stateless.html
>
> In particular, section 3.2, where it states things like:
>
> "All uses of letrec are removed and replaced with equivalent uses of let and 
> imperative features."
>
> "The program is defunctionalized with a serializable data-structure for each 
> lambda"
>
> "First, this process drastically changes the structure of your program. It 
> will create an immense number of lambdas and structures your program did not 
> normally contain. The performance implication of this has not been studied 
> with Racket."
>
> It seems like there is quite a bit of stuff going on to support continuations 
> with stateless servlets. Since I'm not planning on using continuations at 
> all, I'm not sure I want the changes to my code described in section 3.2.
>
> I'm coming from an entirely stateless architecture w/ Ruby/Rails, and I was 
> planning on using a similar style w/ Racket, so I'm just trying to get a feel 
> for how low in the stack I need to be to avoid the extra functionality that I 
> don't want/need. Eventually, I'm planning on resuming work on a web app 
> framework in Racket that steals my favorite things from Rails & other 
> frameworks, and leaves out the cruft. For that, I expect I'll need to base my 
> code on lower levels, but for my current app, I don't have time to create too 
> much infrastructure, so I'd like to leverage basic things from built-in 
> Racket functionality without going "too far", and I'm not even able to 
> articulate well where the "too far" line is.
>
> Thanks,
> Brian
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
-=[ Jay McCarthy   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

-- 
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] embedded api docs and the `doc` submodule

2018-11-30 Thread Neil Van Dyke

Greg Hendershott wrote on 11/30/18 12:01 PM:

Are you familiar with the existing `srcdoc` submodule?

 https://docs.racket-lang.org/scribble/srcdoc.html

If so: I'm curious, what are your thoughts behind not using it?


For one reason, when I asked in January whether `srcdoc` is something to 
use, willing to make some compromises for it, no one said "yes". :) 
https://groups.google.com/d/topic/racket-users/MSeP8Fxt-0A/discussion


One interface that people do commit to, however, is Scribble manuals, so 
that's what I'd target.  And Scribble manuals support the kind of 
narrative embedded Scheme documentation I've been doing since around 
2000.  (I previously used a Texinfo backend for my embedded 
documentation, with my own converters to the HTML and plain ASCII 
formats PLT Scheme wanted for `.plt` packages, before Scribble existed, 
and then I switched to Scribble.)


--
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 do I launch a REPL in the context of a file?

2018-11-30 Thread Alexis King
> On Nov 30, 2018, at 08:23, Sam Tobin-Hochstadt  wrote:
> 
> I'm not sure why `-e` doesn't evaluate in the same namespace as the
> REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:

I’m curious about this, too. At first I thought it was just a misfeature, not 
necessarily a bug, but now I’m not so sure. The namespaces are not actually 
separate, as the following interaction demonstrates:

$ racket -ie '(define x 3)'
Welcome to Racket v7.1.0.1.
> x
3

So then what gives? After further experimentation, my running theory is that 
any mutation of `current-namespace` inside of -e is reverted when the REPL 
starts up. You can see this by skipping `enter!` completely and just modifying 
`current-namespace` directly:

$ racket -ie '(define ns (make-base-namespace)) (current-namespace ns)'
Welcome to Racket v7.1.0.1.
> (eq? ns (current-namespace))
#f

I don’t know if this is intentional behavior or just a bug.

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

Thanks,
Brian

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


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

2018-11-30 Thread Bogdan Popa


Brian Adkins writes:

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

I personally run the server with serve[1] which runs it in a background
thread and I keep a reference to the returned stopper function and
finally do something along the lines of

(with-handlers ([exn:break? (lambda (e) (stopper))])
  (sync/enable-break never-evt))

in my main thread.  As I understand it[2], exn:break? will be truthy for
SIGINT, SIGTERM and SIGHUP (though there are also the exn:break:hang-up?
and exn:break:terminate? predicates) on UNIX, so this should "catch" all
of those and gracefully terminate my server.

[1]: 
https://docs.racket-lang.org/web-server-internal/web-server.html?q=serve#%28def._%28%28lib._web-server%2Fweb-server..rkt%29._serve%29%29
[2]: https://docs.racket-lang.org/reference/breakhandler.html?q=breaks

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


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

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

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

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


[racket-users] Signal handling (or alternative)

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

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

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

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

Thanks,
Brian

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


Re: [racket-users] embedded api docs and the `doc` submodule

2018-11-30 Thread Greg Hendershott
Are you familiar with the existing `srcdoc` submodule?

https://docs.racket-lang.org/scribble/srcdoc.html

If so: I'm curious, what are your thoughts behind not using it?

If not: The existing `scribble/srcdoc` interface works, but I think
there's definitely an opportunity to build some conveniences and
short-hands on top of it.


p.s. I made a `define/doc` macro for use within frog... but only took
time to do the minimum I needed/wanted in that project.


https://github.com/greghendershott/frog/blob/2bc070a60333e1316ff713f9b9b577a7c27e54b3/frog/private/define-doc.rkt

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


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Sam Tobin-Hochstadt
You can report an issue at https://github.com/racket/racket/issues

Sam
On Fri, Nov 30, 2018 at 10:56 AM Habib Alamin  wrote:
>
> Great points which I’d overlooked. It solved the immediate problem; thanks 
> for this improved approach.
>
> I’ll be implementing that soon (hoping it works). I just gotta decide where 
> to place the enter file for maximum reusability.
>
> Does anyone know where I could report this misfeature, by the way?
>
> Sent from my iPhone
>
> > On 30 Nov 2018, at 2:23 pm, Sam Tobin-Hochstadt  
> > wrote:
> >
> > I strongly recommend not doing this. In particular, it will break in
> > many situations. A few examples:
> > - any file that isn't written in #lang racket such as typed/racket or
> > scribble/manual or ...
> > - any file that doesn't work the same as a sequence of repl
> > interactions. For example, any use of mutual recursion or any
> > shadowing of imported ids
> > - any file that uses forms only allowed in modules, such as `module+`
> > or `provide`.
> >
> > I'm not sure why `-e` doesn't evaluate in the same namespace as the
> > REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:
> >
> > $ racket -i -f enter.rktl
> >
> > will do what you want.
> >
> > You can generalize this to:
> >
> > (dynamic-enter! (vector-ref (current-command-line-arguments) 0))
> >
> > and then:
> >
> > $ racket -i -f enter.rktl my-file.rkt
> >
> > will do what you wanted.
> >
> > Sam
> >
> >
> >
> >> On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
> >>
> >> I found a solution:
> >>
> >> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
> >>
> >> This little hack, instead of enter!ing a file, simply echoes the contents 
> >> of the file into the -e argument using a subshell. Racket treats newlines 
> >> the same as spaces, and ignores blank lines, but if you're a neat freak, 
> >> you can do:
> >>
> >> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
> >> '\n' ' ')" -i
> >>
> >>> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
> >>>
> >>> Hi,
> >>>
> >>> I'm trying to set up a keybinding in my editor to enter the namespace of 
> >>> my current file in a REPL, similar to how Dr Racket's Run button works.
> >>>
> >>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
> >>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm 
> >>> able to access a in the REPL. However, I can't do racket -e '(enter! 
> >>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
> >>> the file.
> >>>
> >>> After asking in the IRC channel, I was asked to try
> >>>
> >>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
> >>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
> >>> "current-file.rkt") (read-eval-print-loop)
> >>>
> >>> which didn't work either. Neither did
> >>>
> >>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
> >>>
> >>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but 
> >>> I hear using -f isn't good practice, and besides, I want to write valid 
> >>> Racket files; removing the #lang line breaks normal Racket operation; I 
> >>> can't just do a racket file.rkt.
> >>>
> >>> I'd really appreciate any help in figuring out why this is happening and 
> >>> a simple fix.
> >>>
> >>> Cheers,
> >>> Habib
> >>
> >> --
> >> 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] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Habib Alamin
Great points which I’d overlooked. It solved the immediate problem; thanks for 
this improved approach.

I’ll be implementing that soon (hoping it works). I just gotta decide where to 
place the enter file for maximum reusability.

Does anyone know where I could report this misfeature, by the way?

Sent from my iPhone

> On 30 Nov 2018, at 2:23 pm, Sam Tobin-Hochstadt  wrote:
> 
> I strongly recommend not doing this. In particular, it will break in
> many situations. A few examples:
> - any file that isn't written in #lang racket such as typed/racket or
> scribble/manual or ...
> - any file that doesn't work the same as a sequence of repl
> interactions. For example, any use of mutual recursion or any
> shadowing of imported ids
> - any file that uses forms only allowed in modules, such as `module+`
> or `provide`.
> 
> I'm not sure why `-e` doesn't evaluate in the same namespace as the
> REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:
> 
> $ racket -i -f enter.rktl
> 
> will do what you want.
> 
> You can generalize this to:
> 
> (dynamic-enter! (vector-ref (current-command-line-arguments) 0))
> 
> and then:
> 
> $ racket -i -f enter.rktl my-file.rkt
> 
> will do what you wanted.
> 
> Sam
> 
> 
> 
>> On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
>> 
>> I found a solution:
>> 
>> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
>> 
>> This little hack, instead of enter!ing a file, simply echoes the contents of 
>> the file into the -e argument using a subshell. Racket treats newlines the 
>> same as spaces, and ignores blank lines, but if you're a neat freak, you can 
>> do:
>> 
>> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
>> '\n' ' ')" -i
>> 
>>> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>>> 
>>> Hi,
>>> 
>>> I'm trying to set up a keybinding in my editor to enter the namespace of my 
>>> current file in a REPL, similar to how Dr Racket's Run button works.
>>> 
>>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
>>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm able 
>>> to access a in the REPL. However, I can't do racket -e '(enter! 
>>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
>>> the file.
>>> 
>>> After asking in the IRC channel, I was asked to try
>>> 
>>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
>>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
>>> "current-file.rkt") (read-eval-print-loop)
>>> 
>>> which didn't work either. Neither did
>>> 
>>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>>> 
>>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but I 
>>> hear using -f isn't good practice, and besides, I want to write valid 
>>> Racket files; removing the #lang line breaks normal Racket operation; I 
>>> can't just do a racket file.rkt.
>>> 
>>> I'd really appreciate any help in figuring out why this is happening and a 
>>> simple fix.
>>> 
>>> Cheers,
>>> Habib
>> 
>> --
>> 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] minor doc change proposal?

2018-11-30 Thread Greg Hendershott
On Fri, Nov 30, 2018 at 5:58 AM Robby Findler
 wrote:
> What about using the function
>
> (lambda (x) (and x #true))
>
> And putting a short discussion of truthy and a link to elsewhere in the docs?

Yeah. I feel like the `filter-map` doc would be fine with just that change.

Already it tells you `filter-map` is made of `filter` and `map` --
which are already clickable links right there!

I think really it's the `filter` doc that needs improving. It talks
about the pred function returning "a true value". Should it say "any
value except #f"?

(In the User's Guide, the only discussion of "truthy" I can find is
for things like `if`. The discussion is pretty much just "any value
except #f". Truthy is simpler in Racket than some other languages.
That's probably the only discussion needed -- to help people coming
from other langs? The only false value is #f.  Everything else --
including 0 '() null -- is true. Right?)

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


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Sam Tobin-Hochstadt
I strongly recommend not doing this. In particular, it will break in
many situations. A few examples:
- any file that isn't written in #lang racket such as typed/racket or
scribble/manual or ...
- any file that doesn't work the same as a sequence of repl
interactions. For example, any use of mutual recursion or any
shadowing of imported ids
- any file that uses forms only allowed in modules, such as `module+`
or `provide`.

I'm not sure why `-e` doesn't evaluate in the same namespace as the
REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:

$ racket -i -f enter.rktl

will do what you want.

You can generalize this to:

(dynamic-enter! (vector-ref (current-command-line-arguments) 0))

and then:

$ racket -i -f enter.rktl my-file.rkt

will do what you wanted.

Sam



On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
>
> I found a solution:
>
> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
>
> This little hack, instead of enter!ing a file, simply echoes the contents of 
> the file into the -e argument using a subshell. Racket treats newlines the 
> same as spaces, and ignores blank lines, but if you're a neat freak, you can 
> do:
>
> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr '\n' 
> ' ')" -i
>
> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>>
>> Hi,
>>
>> I'm trying to set up a keybinding in my editor to enter the namespace of my 
>> current file in a REPL, similar to how Dr Racket's Run button works.
>>
>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm able 
>> to access a in the REPL. However, I can't do racket -e '(enter! 
>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
>> the file.
>>
>> After asking in the IRC channel, I was asked to try
>>
>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
>> "current-file.rkt") (read-eval-print-loop)
>>
>> which didn't work either. Neither did
>>
>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>>
>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but I 
>> hear using -f isn't good practice, and besides, I want to write valid Racket 
>> files; removing the #lang line breaks normal Racket operation; I can't just 
>> do a racket file.rkt.
>>
>> I'd really appreciate any help in figuring out why this is happening and a 
>> simple fix.
>>
>> Cheers,
>> Habib
>
> --
> 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: How do I launch a REPL in the context of a file?

2018-11-30 Thread حبيب محمد ألأمين محمد ألهـاد
Thanks for the help, but I've already solved the problem; not sure if my second 
message went out.

I was looking for a very specific workflow, and I have it working now, so I no 
longer require any help (but am open to any criticisms of the workflow I have 
chosen).

Cheers,
Habib

> On 30 Nov 2018, at 13:58, Greg Hendershott  wrote:
> 
> If you have xrepl enabled (it is by default in recent Rackets), you
> get a bunch of handy commands. Try entering ,help to see them. One is
> ,enter.
> 
> So one common workflow is you keep one `racket` process running all
> the time, and simply type `,en /path/to/to/file.rkt` at the prompt.
> 
> If typing `,en /path/to/file.rkt` gets tiresome, then you can have
> your editor type this for you.
> 
> In Emacs you could do this by running `racket` in an Emacs
> shell/comint/terminal buffer and your Emacs key/command is a thin
> wrapper around comint-send-input or whatever.
> 
> In other editors, I don't know how to "send keys to some process"?

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


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Greg Hendershott
If you have xrepl enabled (it is by default in recent Rackets), you
get a bunch of handy commands. Try entering ,help to see them. One is
,enter.

So one common workflow is you keep one `racket` process running all
the time, and simply type `,en /path/to/to/file.rkt` at the prompt.

If typing `,en /path/to/file.rkt` gets tiresome, then you can have
your editor type this for you.

In Emacs you could do this by running `racket` in an Emacs
shell/comint/terminal buffer and your Emacs key/command is a thin
wrapper around comint-send-input or whatever.

In other editors, I don't know how to "send keys to some process"?

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


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

2018-11-30 Thread hashim muqtadir
I've found monit to work alongside systemd services pretty neatly. As in, I 
have monit monitoring my web server, which is running using systemd, and 
monit sends me emails if it's not working or something.

-- 
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] minor doc change proposal?

2018-11-30 Thread Robby Findler
What about using the function

(lambda (x) (and x #true))

And putting a short discussion of truthy and a link to elsewhere in the
docs?

Robby

On Thu, Nov 29, 2018 at 11:17 PM Philip McGrath 
wrote:

> I can do it.
>
> -Philip
>
>
> On Thu, Nov 29, 2018 at 5:17 PM John Clements 
> wrote:
>
>> I like your idea better than mine. Do you have time to make it a pull
>> request? If not, I’ll do it.
>>
>> John
>>
>> > On Nov 29, 2018, at 2:08 PM, Philip McGrath 
>> wrote:
>> >
>> > I would find `true?` confusing, since it really means "truthy." For
>> example, in Rackunit, `check-not-false` has this behavior, whereas
>> `check-true` checks that the result is really `eq?` to `#t`.
>> >
>> > Personally, I think it might be better to clarify the documentation
>> with more prose, rather than adding a new binding to the standard library.
>> Maybe something like this?
>> > Like (map proc lst ...), except that, when `proc` returns `#f`, that
>> element is omitted from the resulting list. In other words, filter-map is
>> equivalent to (filter (lambda (x) x) (map proc lst ...)), but more
>> efficient, because filter-map avoids building the intermediate list.
>> >
>> > -Philip
>> >
>> >
>> > On Thu, Nov 29, 2018 at 3:25 PM Gustavo Massaccesi 
>> wrote:
>> > This function is a already defined in a few libraries and it is called
>> `true?` for example in
>> https://docs.racket-lang.org/predicates/index.html?q=true#%28def._%28%28lib._predicates%2Fmain..rkt%29._true~3f%29%29
>> >
>> > I think that `not-false?` is easier to understand, but `true?` is more
>> idiomatic.
>> >
>> > Gustavo
>> >
>> >
>> >
>> >
>> > On Thu, Nov 29, 2018 at 3:11 PM 'John Clements' via Racket Users <
>> racket-users@googlegroups.com> wrote:
>> > This stack overflow post
>> >
>> >
>> https://stackoverflow.com/questions/53543191/what-is-the-different-between-filter-and-filter-map/53545115#53545115
>> >
>> > … is written by someone confused by the documentation for `filter-map`.
>> I went and read the documentation, and *I* was confused for about 30
>> seconds. I eventually proposed rewriting the existing
>> >
>> > Returns (filter (lambda (x) x) (map proc lst ...)), but without
>> building the intermediate list.
>> >
>> > to
>> >
>> > Returns (filter not-false? (map proc lst ...)), but without building
>> the intermediate list, where not-false? can be defined as (lambda (x) x).
>> >
>> > This text is kludgier, but I think that the use of (lambda (x) x) as
>> “not-false?” is idiomatic and confusing. And yes, I realize that this
>> suggestion probably applies to many places in the docs. Maybe I should just
>> propose adding `not-false?` as a library function, defined as (lambda (x)
>> x)….
>> >
>> >
>> > 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.
>>
>>
>>
>> --
> 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] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Habib Alamin
I found a solution:

nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i

This little hack, instead of enter!ing a file, simply echoes the contents 
of the file into the -e argument using a subshell. Racket treats newlines 
the same as spaces, and ignores blank lines, but if you're a neat freak, 
you can do:

nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
'\n' ' ')" -i

On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>
> Hi,
>
> I'm trying to set up a keybinding in my editor to enter the namespace of 
> my current file in a REPL, similar to how Dr Racket's Run button works.
>
> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
> printing Hello. A racket -e '(define a "a") -i also works, in that I'm 
> able to access a in the REPL. However, I can't do racket -e '(enter! 
> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
> the file.
>
> After asking in the IRC channel, I was asked to try
>
> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
> "current-file.rkt") (read-eval-print-loop)
>
> which didn't work either. Neither did
>
> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>
> I can do a racket -if file.rkt if I get rid of the #lang racket line, but 
> I hear using -f isn't good practice, and besides, I want to write valid 
> Racket files; removing the #lang line breaks normal Racket operation; I 
> can't just do a racket file.rkt.
>
> I'd really appreciate any help in figuring out why this is happening and a 
> simple fix.
>
> Cheers,
> Habib
>

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