Re: [racket-users] Macros crossing documentation-time and run-time phases

2019-03-18 Thread Philip McGrath
On Mon, Mar 18, 2019 at 9:14 AM Matthew Flatt  wrote:

> I wonder whether the solution is an extension of `scribble/lp2` to
> support a `require-for-chunk` form where `chunk` records any such
> imports in its context and adds then to the stitched-together program.
>
>  (require-for-chunk (only-in racket/string string-join))
>
>  (define-syntax-parser cross-phase-macro
>[(_ <>:id)
> @#`begin{@(func-not-exported)
>
>  @chunk[<>
> (string-join 
>
> would work because `chunk` would pick up the `(only-in racket/string
> string-join)` from its context and attach it to the chunk, so that
> `(only-in racket/string string-join)` would be added to the
> stitched-together context.
>
> Maybe this would work by having `require-for-chunk` expand to something
> like `(begin-for-syntax (register-require #'chunk ))` to register
> in a compile-time free-id table mapping from the #'chunk identifier to
> a list of imports. Then, the `chunk` macro would consult the table
> using the identifier that invoked the macro. (I have not tried this to
> be sure that it would work.)
>

While thinking about this idea, I came up with a simpler example that
exposes a hygiene issue in `scribble/lp2` without using `require`:

#lang scribble/lp2
@(define-syntax-rule (chunk/define <> lhs rhs ...)
   (chunk <>
  (define hygiene "this shouldn't cause capture")
  (define lhs rhs ...)))
@(chunk <*>  )
@(chunk/define  a 1)
@(chunk/define  b 2)

fails with the error "module: identifier already defined in: hygiene".

I would have liked it to work analogously to this:

#lang racket
(define-syntax-rule (module+/define mod lhs rhs ...)
  (module+ mod
(define hygiene "this shouldn't cause capture")
(define lhs rhs ...)))
(module+/define main a 1)
(module+/define main b 2)

-Philip

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


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

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

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

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

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


[racket-users] Re: ANN: RacketCon Keynote Speakers; You won't believe #9!

2019-03-18 Thread Lehi Toskin
A clickbait title about workshops!? That might just make me "Come and see." 
;)

On Monday, March 18, 2019 at 10:31:55 AM UTC-7, Jay McCarthy wrote:
>
> This year from July 8th to the 14th is Racket Week. Come and see. 
>
> During the body of the week are the school workshops. Come and see. 
>
> https://school.racket-lang.org/ 
>
> Afterwards is RacketCon itself, for two days. Come and see. 
>
> https://con.racket-lang.org/ 
>
> We're happy to announce that the keynote speaker is Aaron Turon, a 
> leader on the Rust team at Mozilla. Come and see. 
>
> https://aturon.github.io/about/ 
>
> If you'd like to apply to present, send me an email. 
>
> <3 
>
> Jay 
>
> -- 
> -=[ 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] Re: Simple conditional in web template

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

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


On Monday, March 18, 2019 at 11:56:25 AM UTC-4, Philip McGrath wrote:
>
> I don't use `include-template` (I've come to love x-expressions), but I 
> believe this would work:
> @,(if #true
>   @`{
>  This will be displayed if true
>  }
>   @`{
>  This will be displayed if false
>  })
>
> -Philip
>
>
> On Mon, Mar 18, 2019 at 11:48 AM Jérôme Martin  > wrote:
>
>>
>> On Monday, March 18, 2019 at 4:45:19 PM UTC+1, Brian Adkins wrote:
>>>
>>> Yes, using code would certainly make some things easier, but for the 
>>> moment, I'm looking for a template solution.
>>>
>>
>> Oh sorry, I didn't quite catch that! I never used templates, so I don't 
>> know.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[racket-users] ANN: RacketCon Keynote Speakers; You won't believe #9!

2019-03-18 Thread Jay McCarthy
This year from July 8th to the 14th is Racket Week. Come and see.

During the body of the week are the school workshops. Come and see.

https://school.racket-lang.org/

Afterwards is RacketCon itself, for two days. Come and see.

https://con.racket-lang.org/

We're happy to announce that the keynote speaker is Aaron Turon, a
leader on the Rust team at Mozilla. Come and see.

https://aturon.github.io/about/

If you'd like to apply to present, send me an email.

<3

Jay

-- 
-=[ 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] Accomodation on the Racket School 2019 page

2019-03-18 Thread Matthew Flatt
Hi Chris,

Stay turned for more information. There will be space for all Racket
School attendees, so you don't have to worry about claiming space early.

Matthew

At Mon, 18 Mar 2019 12:15:05 -0400, Christopher Lemmer Webber wrote:
> According to https://school.racket-lang.org/#accommodation
> there's subsidized lodgin at the University of Utah dorms.
> Sounds great!  But it's not really clear to me which buildings it would
> be at or where I should contact them.  Maybe this is useful info to
> clarify on the website?
> 
> I see that contact info is listed at the bottom of:
> https://housing.utah.edu/
> 
> Should I just call that? :)
> 
> Not really sure myself, so I figured others may also be unsure, and I
> don't see a contact link on the Racket School page, so I figured I'd
> email the list.  Hope it isn't too awkward!
> 
>  - Chris
> 
> -- 
> 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] Accomodation on the Racket School 2019 page

2019-03-18 Thread Jay McCarthy
What we have done in the past is gathering a list of who wants the
subsidized housing, then collect the fee from them (last year it was
$40 per night), and directly negotiate with the housing. We need to
arrange it with them so that all our people are in roughly the same
building and not too interspersed with the soccer camps, and so on. If
you are curious what the rooms are like, we normally get put in
Benchmark Plaza ---
https://d2vxd53ymoe6ju.cloudfront.net/wp-content/uploads/sites/2/20180108093435/Benchmark-Combined-Floor-Plans.pdf

On Mon, Mar 18, 2019 at 12:15 PM Christopher Lemmer Webber
 wrote:
>
> According to https://school.racket-lang.org/#accommodation
> there's subsidized lodgin at the University of Utah dorms.
> Sounds great!  But it's not really clear to me which buildings it would
> be at or where I should contact them.  Maybe this is useful info to
> clarify on the website?
>
> I see that contact info is listed at the bottom of:
> https://housing.utah.edu/
>
> Should I just call that? :)
>
> Not really sure myself, so I figured others may also be unsure, and I
> don't see a contact link on the Racket School page, so I figured I'd
> email the list.  Hope it isn't too awkward!
>
>  - Chris
>
> --
> 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.


[racket-users] Accomodation on the Racket School 2019 page

2019-03-18 Thread Christopher Lemmer Webber
According to https://school.racket-lang.org/#accommodation
there's subsidized lodgin at the University of Utah dorms.
Sounds great!  But it's not really clear to me which buildings it would
be at or where I should contact them.  Maybe this is useful info to
clarify on the website?

I see that contact info is listed at the bottom of:
https://housing.utah.edu/

Should I just call that? :)

Not really sure myself, so I figured others may also be unsure, and I
don't see a contact link on the Racket School page, so I figured I'd
email the list.  Hope it isn't too awkward!

 - Chris

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


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

2019-03-18 Thread Philip McGrath
I don't use `include-template` (I've come to love x-expressions), but I
believe this would work:
@,(if #true
  @`{
 This will be displayed if true
 }
  @`{
 This will be displayed if false
 })

-Philip


On Mon, Mar 18, 2019 at 11:48 AM Jérôme Martin 
wrote:

>
> On Monday, March 18, 2019 at 4:45:19 PM UTC+1, Brian Adkins wrote:
>>
>> Yes, using code would certainly make some things easier, but for the
>> moment, I'm looking for a template solution.
>>
>
> Oh sorry, I didn't quite catch that! I never used templates, so I don't
> know.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+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 News - Issue 4

2019-03-18 Thread Matt Jadud
I'd be willing to pitch in some text around the thinking about the 'tbl'
library for introductory data work, so that people might push back on it.
Or, it would at least give a coherent surface for some conversation around
collaboration.

If not next issue, at some point. Or, not. I'm flexible. It would force me
to get some things in writing, though, which is useful.

Cheers,
Matt

On Mon, Mar 18, 2019 at 9:55 AM Jérôme Martin 
wrote:

> Thank you so much for this!
>
> If I can suggest a project for next month's spotlight:
>
> - Christopher Lemmer Webber, co-editor of the ActivityPub specs, is
> working on a distributed social network library based on Racket:
> https://gitlab.com/spritely
>   It's still in early development, but I think it's an important project
> to give visibility to ;)
>
> Maybe we could also have a spotlight section for #lang languages too?
>
> - The brag parser generator is obviously a good project.
> - The video lang by Leif is also pretty awesome.
> - The slideshow lang might be a great pick too.
> - Obviously scribble.
>
> On Friday, March 15, 2019 at 12:03:47 PM UTC+1, Paulo Matos wrote:
>>
>> I have just published Issue 4 at
>>
>> http://racket-news.com/2019/03/racket-news-issue-4.html
>>
>> Grab a coffee and enjoy!
>> --
>> Paulo Matos
>>
> --
> 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: Simple conditional in web template

2019-03-18 Thread Jérôme Martin

On Monday, March 18, 2019 at 4:45:19 PM UTC+1, Brian Adkins wrote:
>
> Yes, using code would certainly make some things easier, but for the 
> moment, I'm looking for a template solution.
>

Oh sorry, I didn't quite catch that! I never used templates, so I don't 
know.

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


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

2019-03-18 Thread Jérôme Martin
Some precisions:

You ever need to have a "p" procedure to generate the paragraph (for 
example from html-lib) or quote it in my example, otherwise it won't work.
The trick is to use a quasiquotation (backtick) to render your HTML 
template, and unquote (comma) to put logic in the template.

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

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


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

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

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

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


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

2019-03-18 Thread Jérôme Martin
(define (my-server-response show-cat?)
  (response/xexpr
`(div ([class "my-content"])
  ,(if show-cat?
   (p "Welcome to my blog about cats!")
   (p "This blog is definitely not about cats.")

On Monday, March 18, 2019 at 4:26:16 PM UTC+1, Brian Adkins wrote:
>
> How would one translate the following Ruby template into a Racket web 
> template (including multiple lines for the if and else clauses) ?
>
> <% if true %>
>   
>  This will be displayed if true
>   
> <% else %>
>   
> This will be displayed if false
>   
> <% end %>
>
> I've read a fair amount of doc and was unable to find a simple example 
> like the above. I think this is a pretty common need, so an example in the 
> docs would be awesome. The "for" example with the recommendation to use 
> "in" was helpful.
>
> Thanks,
> Brian
>

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


[racket-users] Simple conditional in web template

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

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

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

Thanks,
Brian

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


[racket-users] Guards and R7RS

2019-03-18 Thread jmhuffle
Dear Racket users of the #!r7rs modules,

 It seems to me that there is an error with R7RS' "guard" special form. The 
reference manual reads that "raise-continuable" is called with a raised object 
not handled by a "guard" special form. But, if I try:

(with-exception-handler (lambda (x) 'gotcha) 
 (lambda () (guard (y) (raise 2019

I got an error. The same if "raise" is replaced by "raise-continuable" in the 
previous expression. Unless I miss some points?

 Thanks in advance for your answers,

J.-M. Hufflen

-- 
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] Promises and Racket's dialects

2019-03-18 Thread jmhuffle
Dear Racket users,

 Within the documentation or elsewhere on Internet, is there a survey about the 
different ways of implementing promises in Racket and its dialects. I know that 
there are several ways, especially about recursive promises, but I am puzzled. 
For example:

(define x 0)

(define p
 (delay (if (= x 5)
 x
 (begin
 (set! x (+ x 1)) (force p) (set! x (+ x 1)) x

If I understood, Racket does not allow such recursive promise.

In #!r5rs (force p) => 5

In #!r7rs (force p) => 10 and then (force p) => 5, what is surprising because 
"force" is supposed to yield the same result for the same promise.

 Please is there a place where these differences are discussed? Many thanks in 
advance,

J.-M. Hufflen

-- 
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] Struct subtype with default/fixed value of super-type

2019-03-18 Thread Marc Kaufmann
While I did know that I could define my own, I was going to do it while
providing-out another function make-fish and make-shark, but it's nice to
know that this allows me to locally define make-fish, while it looks to the
outside like (fish ...).

Thanks to including sufficient numbers of mundane bugs in my code (all
well-maintained in version control, for quick deployment on docker), I
rarely get to worry about phases - it just isn't where the highest gains
are. :-)

On Mon, Mar 18, 2019 at 2:46 PM Jérôme Martin 
wrote:

> Once you discover that the default constructor for a struct is just a
> simple procedure that was generated for you, it's not that big of deal to
> just make your own and export it like this:
>
> (provide
>   (except-out (struct-out fish) fish)
>   (rename-out (make-fish fish)))
>
> All the code relying on it will still work.
> Except I guess if you pass through different phase levels, it becomes a
> bit more complicated because you have a syntax attached at compile-time to
> the identifier. But that's another issue.
> Correct me if I'm wrong.
>
> On Monday, March 18, 2019 at 2:11:46 PM UTC+1, Marc Kaufmann wrote:
>>
>> Yes, I saw that, the problem is that I want to be able to set a
>> (potentially different) default value for the sub-type shark than for the
>> sub-type guppy. So if I set the value to 'big for all `fish`, then I can't
>> do that. Essentially, I'd need an #:auto for every sub-type, but the #:auto
>> refers to a parent/super field.
>>
>> I'll just run with defining a custom constructor.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/TthsE0FZDB0/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Racket News - Issue 4

2019-03-18 Thread Jérôme Martin
Thank you so much for this!

If I can suggest a project for next month's spotlight:

- Christopher Lemmer Webber, co-editor of the ActivityPub specs, is working 
on a distributed social network library based on Racket: 
https://gitlab.com/spritely
  It's still in early development, but I think it's an important project to 
give visibility to ;)

Maybe we could also have a spotlight section for #lang languages too?

- The brag parser generator is obviously a good project.
- The video lang by Leif is also pretty awesome.
- The slideshow lang might be a great pick too.
- Obviously scribble.

On Friday, March 15, 2019 at 12:03:47 PM UTC+1, Paulo Matos wrote:
>
> I have just published Issue 4 at 
>
> http://racket-news.com/2019/03/racket-news-issue-4.html 
>
> Grab a coffee and enjoy! 
> -- 
> Paulo Matos 
>

-- 
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] Struct subtype with default/fixed value of super-type

2019-03-18 Thread Jérôme Martin
Once you discover that the default constructor for a struct is just a 
simple procedure that was generated for you, it's not that big of deal to 
just make your own and export it like this:

(provide
  (except-out (struct-out fish) fish)
  (rename-out (make-fish fish)))

All the code relying on it will still work.
Except I guess if you pass through different phase levels, it becomes a bit 
more complicated because you have a syntax attached at compile-time to the 
identifier. But that's another issue.
Correct me if I'm wrong.

On Monday, March 18, 2019 at 2:11:46 PM UTC+1, Marc Kaufmann wrote:
>
> Yes, I saw that, the problem is that I want to be able to set a 
> (potentially different) default value for the sub-type shark than for the 
> sub-type guppy. So if I set the value to 'big for all `fish`, then I can't 
> do that. Essentially, I'd need an #:auto for every sub-type, but the #:auto 
> refers to a parent/super field. 
>
> I'll just run with defining a custom constructor.
>

-- 
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] Macros crossing documentation-time and run-time phases

2019-03-18 Thread Matthew Flatt
Just to make sure we're on the same page, it seems like your example
fails for the same reason that

 #lang scribble/lp2
 @(require racket/string)
 @(chunk <*> string-join)

fails. That `require` turns out to do nothing, and there's no binding
of `string-join` in the "phase" of the program is that stitched
together by the chunks.

In this single-file example, the solution could be

 #lang scribble/lp2
 @(chunk  (require racket/string))
 @(chunk <*>  string-join)

but that puts `require` text in the generated document, which could be
undesirable in some context. Even if including the `require` was ok,
changing your original example to

 

 (chunk  (require (only-in racket/string string-join)))

 (define-syntax-parser cross-phase-macro
   [(_ <>:id)
@#`begin{@(func-not-exported)
 
 @chunk[<> 
(string-join
 '("string-join is not provided"
   "at runtime"
   "by #lang scribble/lp2"))]
 }])

does not work, because `chunk` binding doesn't work that way.


I wonder whether the solution is an extension of `scribble/lp2` to
support a `require-for-chunk` form where `chunk` records any such
imports in its context and adds then to the stitched-together program.

 

 (require-for-chunk (only-in racket/string string-join))

 (define-syntax-parser cross-phase-macro
   [(_ <>:id)
@#`begin{@(func-not-exported)
 
 @chunk[<>
(string-join 

would work because `chunk` would pick up the `(only-in racket/string
string-join)` from its context and attach it to the chunk, so that
`(only-in racket/string string-join)` would be added to the
stitched-together context.

Maybe this would work by having `require-for-chunk` expand to something
like `(begin-for-syntax (register-require #'chunk ))` to register
in a compile-time free-id table mapping from the #'chunk identifier to
a list of imports. Then, the `chunk` macro would consult the table
using the identifier that invoked the macro. (I have not tried this to
be sure that it would work.)


At Mon, 18 Mar 2019 02:20:50 -0400, Philip McGrath wrote:
> Racket makes it easy to write macros that mix run-time code with various
> compile-time phases, using lexical scope to refer unambiguously to the
> correct binding for each identifier, including bindings that are not
> directly exported. Macro-generating macros are a great example, in that
> they expand to code at several different phases.
> 
> When trying to write macros that interleave documentation-time and run-time
> phases, I haven't been able to find the same elegance. I'm going to
> demonstrate one of the problems I've found using `#lang scribble/lp2`, but
> I really encountered these issues while implementing the specification
> #lang I've made for Digital Ricoeur: my current implementation is based
> quite closely on `scribble/lp2`.
> 
> Imagine a library module "lib.rkt" from which you want to export a
> `cross-phase-macro`, which expands to both documentation-time and run-time
> code for your literate programs. Here's an initial attempt: (The code for
> this example is up at
> https://github.com/LiberalArtist/doc-lang-experiments/tree/1de75817866d9d782da7
> 5f1799daeb5eb26e6fe1/lp2-example1
> .)
> #lang at-exp racket/base
> 
> (provide cross-phase-macro)
> 
> (require (only-in racket/string string-join)
>  (only-in scribble/lp2 chunk)
>  syntax/parse/define
>  (for-syntax racket/base))
> 
> (define (func-not-exported)
>   "This is the result of func-not-exported.")
> 
> (define-syntax-parser cross-phase-macro
>   [(_ <>:id)
>@#`begin{@(func-not-exported)
> 
> @chunk[<>
>(string-join
> '("string-join is not provided"
>   "at runtime"
>   "by #lang scribble/lp2"))]
> }])
> 
> When you try to use `cross-phase-macro` from a literate program
> "program.scrbl":
> #lang scribble/lp2
> 
> @(require "lib.rkt")
> 
> @cross-phase-macro[<*>]
> you get an unbound identifier error complaining about the use of
> `string-join`.
> 
> The reason for the error is clear: `chunk` bodies are stitched together
> into a `doc` submodule in the `racket/base` language, and `racket/base`
> doesn't include `string-join`. In essence, `string-join` isn't bound at the
> right phase. If this were a macro-generating macro—imagine `define-syntax`
> instead of `chunk`—the solution would be equally clear: use a `for-syntax`
> require or a `begin-for-syntax` block to bind `string-join` at
> compile-time, and the use of the identifier in the syntax template will
> resolve to the right binding, even without explicitly exporting
> `string-join`.
> 
> I have yet to find a way to do the equivalent thing when mixing run-time
> and documentation-time phases, rather than run-time and compile-time(s).
> 
> Some of the objectives and implementation details of `scribble/lp2` (shared
> by my specification language) seem to make this problem harder. The
> run-time phase shouldn't have a dependency on 

Re: [racket-users] Struct subtype with default/fixed value of super-type

2019-03-18 Thread Marc Kaufmann
Yes, I saw that, the problem is that I want to be able to set a
(potentially different) default value for the sub-type shark than for the
sub-type guppy. So if I set the value to 'big for all `fish`, then I can't
do that. Essentially, I'd need an #:auto for every sub-type, but the #:auto
refers to a parent/super field.

I'll just run with defining a custom constructor.

On Sat, Mar 16, 2019 at 8:24 AM Luis Sanjuán 
wrote:

> Maybe #:auto/#:auto-value is what you want:
>
> ```
> (struct fish (name [size #:auto])
>   #:auto-value 'big
>   #:transparent)
> (struct shark fish (scares-people?) #:transparent)
>
> (define white-shark (shark "The big white" #t))
> ```
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/TthsE0FZDB0/unsubscribe.
> To unsubscribe from this group and all its topics, 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: London Racket Meet-up ?

2019-03-18 Thread Jérôme Martin
Interested!

To make it worth the trip, I'd suggest we put up a list of topics to 
discuss, so that people can ponder whether they should buy an expensive 
ticket to go there.

I'd suggest the following topics I'd be glad to talk about:

- Innovative use of syntax-parse, with tips and tricks to make macro code 
readable
- New #lang DSLs in the wild: present the one you've built
- Successful use of Racket in the industry
- Racket for the web

Feel free to suggest topics too!

-- 
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] Macros crossing documentation-time and run-time phases

2019-03-18 Thread Philip McGrath
Racket makes it easy to write macros that mix run-time code with various
compile-time phases, using lexical scope to refer unambiguously to the
correct binding for each identifier, including bindings that are not
directly exported. Macro-generating macros are a great example, in that
they expand to code at several different phases.

When trying to write macros that interleave documentation-time and run-time
phases, I haven't been able to find the same elegance. I'm going to
demonstrate one of the problems I've found using `#lang scribble/lp2`, but
I really encountered these issues while implementing the specification
#lang I've made for Digital Ricoeur: my current implementation is based
quite closely on `scribble/lp2`.

Imagine a library module "lib.rkt" from which you want to export a
`cross-phase-macro`, which expands to both documentation-time and run-time
code for your literate programs. Here's an initial attempt: (The code for
this example is up at
https://github.com/LiberalArtist/doc-lang-experiments/tree/1de75817866d9d782da75f1799daeb5eb26e6fe1/lp2-example1
.)
#lang at-exp racket/base

(provide cross-phase-macro)

(require (only-in racket/string string-join)
 (only-in scribble/lp2 chunk)
 syntax/parse/define
 (for-syntax racket/base))

(define (func-not-exported)
  "This is the result of func-not-exported.")

(define-syntax-parser cross-phase-macro
  [(_ <>:id)
   @#`begin{@(func-not-exported)

@chunk[<>
   (string-join
'("string-join is not provided"
  "at runtime"
  "by #lang scribble/lp2"))]
}])

When you try to use `cross-phase-macro` from a literate program
"program.scrbl":
#lang scribble/lp2

@(require "lib.rkt")

@cross-phase-macro[<*>]
you get an unbound identifier error complaining about the use of
`string-join`.

The reason for the error is clear: `chunk` bodies are stitched together
into a `doc` submodule in the `racket/base` language, and `racket/base`
doesn't include `string-join`. In essence, `string-join` isn't bound at the
right phase. If this were a macro-generating macro—imagine `define-syntax`
instead of `chunk`—the solution would be equally clear: use a `for-syntax`
require or a `begin-for-syntax` block to bind `string-join` at
compile-time, and the use of the identifier in the syntax template will
resolve to the right binding, even without explicitly exporting
`string-join`.

I have yet to find a way to do the equivalent thing when mixing run-time
and documentation-time phases, rather than run-time and compile-time(s).

Some of the objectives and implementation details of `scribble/lp2` (shared
by my specification language) seem to make this problem harder. The
run-time phase shouldn't have a dependency on the documentation-time phase,
which would pull in Scribble etc. Likewise, the documentation-time phase
shouldn't import the run-time phase, other than perhaps `for-label`. The
`#%module-begin` implementation uses complicated tricks to expand the
documentation-time phase before the run-time phase, even though the
documentation-time phase becomes a `module*` submodule, because it has to
discover the run-time code (uses of `chunk` or, for my language,
`begin-for-runtime`) inside of the documentation-time code. The
implementation actually expands the documentation-time phase twice, and it
uses `strip-context` in a few places, which seems like it would undo any
fancy scope manipulation that I might otherwise look to as the beginning of
a solution.

Currently, I work around this in my specification language by manually
arranging to have the language provide any bindings I need to expand to at
run-time, but this is fragile and aesthetically displeasing. Actually, I
would say the same about expanding the documentation-time phase twice (and,
in my case, with observable differences, e.g. to get `for label` requires
working thanks to an earlier post on this list
).
It seems like there must be a better way to do this, and I'm wondering if
anyone has ideas. With my specification language, in particular, I have the
freedom to completely change the implementation if I can get to a better
place.

Since much of this email has been about problems, I want to close by
reiterating that our specification #lang has been a big win for us at
Digital Ricoeur. While there are things about the implementation of the
#lang that I'd like to improve, using the #lang has reduced bugs, greatly
aided maintainability, and kept our prose documents in sync with various
layers of code. Part of my motivation for trying to make the implementation
more robust is that it has been so useful to us that I'd like to make the
core more reusable for others.


-Philip

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