[racket-users] Tools and Syntax Highlighting

2021-01-03 Thread Ben Ryjikov
Hi Racket,

Is it possible for a tool invoked by info.rkt to access code which is outside 
of the tool?

We’re building a #lang and would like to have on-demand syntax highlighting.
We’ve tried using a tool, and have successfully made a button and a menu item 
that do it, but we’d like to activate the highlighting programmatically at 
runtime instead of by clicking on something.
We also are hoping to have multiple highlights at once if possible.

Is there any way to get on-demand syntax highlighting without using a button or 
menu item? Are there any pre-existing Racket tools or functions that would do 
this?

Thanks for your time and Happy New Year!

Best,
Ben

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.com.


Re: [racket-users] Why do single-form modules behave differently?

2021-01-03 Thread Sage Gerard
Fantastic, thank you

~slg

‐‐‐ Original Message ‐‐‐
On Sunday, January 3, 2021 12:14 PM, Ryan Culpepper  
wrote:

> It's the consequence of two design goals:
>
> 1. The `module` form is separate from the `#%module-begin` syntax hook so 
> that the module's initial language can pick the hook macro that controls the 
> entire module body.
>
> 2. Racket's primitive syntax is designed so that it can be re-expanded. (The 
> `expand` operation should be idempotent.) Some of Racket's tools (for 
> example, debugging support) work by expanding code, instrumenting it, and 
> then re-expanding, compiling, and running the result. But a `#%module-begin` 
> hook macro can transform the module body in non-idempotent ways, so that hook 
> macro should only be called once. So the answer to "have I already run the 
> module's `#%module-begin` hook?" must be reflected in the fully-expanded 
> syntax of the module.
>
> Ryan
>
> On Sun, Jan 3, 2021 at 8:40 AM Michael MacLeod  
> wrote:
>
>> Oops, sorry about interpreting your question wrong. Unfortunately I don't 
>> know the answer to your actual question.
>>
>> On Sat, Jan 2, 2021, 10:24 PM Sage Gerard  wrote:
>>
>>> I know about that. I asked why it was designed that way.
>>>
>>> Sent from ProtonMail mobile
>>>
>>>  Original Message 
>>> On Jan 3, 2021, 12:18 AM, Michael MacLeod < michaelmmacl...@gmail.com> 
>>> wrote:
>>>
 There's an edge case of 'module' when only one form is provided which 
 results in that form being partially expanded to determine if such 
 expansion would lead to a #%plain-module-begin form. Otherwise (more than 
 one form provided) they are wrapped in #%module-begin with no partial 
 expansion occurring.

 I think this might be causing the discrepancy you witnessed.

 From the docs (https://docs.racket-lang.org/reference/module.html):

 If a single form is provided, then it is partially expanded in a 
 module-begin context. If the expansion leads to #%plain-module-begin, then 
 the body of the #%plain-module-begin is the body of the module. If partial 
 expansion leads to any other primitive form, then the form is wrapped with 
 #%module-begin using the lexical context of the module body; this 
 identifier must be bound by the initial module-path import, and its 
 expansion must produce a #%plain-module-begin to supply the module body. 
 Finally, if multiple forms are provided, they are wrapped with 
 #%module-begin, as in the case where a single form does not expand to 
 #%plain-module-begin.

 (This response was adapted from one of my earlier replies to the mailing 
 list. Search racket-users for "perplexed by macro-expansion behavior near 
 #%module-begin" for more context).

 Best,
 Michael

 On Sat, Jan 2, 2021 at 8:26 PM Sage Gerard  wrote:

> Why does Racket handle modules with exactly one form differently?
>
> I ran into a bug where modules in my module language won't expand if the
> modules have exactly one form, so I'm just curious.
>
> (Wild guess: It's Racket's way of checking for a shortcut to end 
> expansion earlier)
>
> ~slg
>
> --
> 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.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/racket-users/OVvZ0OK4_PfyvXCWfuvzDWBM5-ellmDvNmWchVmsCwAJb_rbSZkCkyraakcGsEMSCl2BsLsWtMXFhQcXY75IKhYiYYGQQEI7lVXLgGBbTCc%3D%40sagegerard.com](https://groups.google.com/d/msgid/racket-users/OVvZ0OK4_PfyvXCWfuvzDWBM5-ellmDvNmWchVmsCwAJb_rbSZkCkyraakcGsEMSCl2BsLsWtMXFhQcXY75IKhYiYYGQQEI7lVXLgGBbTCc%3D%40sagegerard.com?utm_medium=email_source=footer).
>>
>> --
>> 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.
>> To view this discussion on the web visit 
>> [https://groups.google.com/d/msgid/racket-users/CACehHmBvs5KK4vQmwio93D1NZ9hTOoSv-Qkm8XOjF%2B4JWDOiHg%40mail.gmail.com](https://groups.google.com/d/msgid/racket-users/CACehHmBvs5KK4vQmwio93D1NZ9hTOoSv-Qkm8XOjF%2B4JWDOiHg%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/Chmb4Sh3Pm8Y0D-qf19jw8Z0aM6AYGMrDfOZn2FzzrgrDNINR_K7QV5beIaJPiVakohvBLgSeSHoesndVxQOTaj068otESk8ROXGif0RHWY%3D%40sagegerard.com.


[racket-users] Re: Typed Racket: require macros from untyped modules

2021-01-03 Thread unlimitedscolobb
I continued doing various tests and realized that my problem was something 
else, since the following code works:

#lang typed/racket

(module untyped-submodule racket
  (provide a macro)
  (define a 2)
  (define-syntax-rule (macro arg) (+ 1 arg)))

(require 'untyped-submodule)

(macro 3)

Using a in the enclosing module doesn't work (a is required without a 
type), but macro works fine.

Getting back to thinking and trying.

-
Sergiu

On Sunday, January 3, 2021 at 9:22:16 PM UTC+1 unlimitedscolobb wrote:

> Hello,
>
> How can I require macros coming from untyped modules into typed modules?
>
> Intuitively I'd expect that to be possible in a way or another because 
> such imports don't seem to violate any safety guarantees, but maybe I'm 
> missing something.
>
> -
> Sergiu
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/937fdcb5-2e59-46da-8a16-1262d35a97d1n%40googlegroups.com.


Re: [racket-users] I made some videos about Racket (a.k.a the return of Playing the Game with PLT Redex)

2021-01-03 Thread Sage Gerard
Thanks for sharing.

I honed in on the review video because I like the philosophical discussions 
that come from them. I'm not sure about the comments re: toxicity in the 
community and how that helps one succeed in academia, but I did see some value 
in discussing the merits of LOP.

I spent enough years on JavaScript to see the ecosystem slowly gain features 
that other languages enjoyed for decades. It seemed wise to learn new tools 
instead of waiting on a standards committee. Part of my frustration with 
JavaScript was spending so many hours either A) reinventing the same things, or 
B) trying to get other people's stuff to do what I thought was advertised. All 
in the name of achieving some level of productivity that computers are 
ironically terrible at providing. I noticed after a while that I was trying to 
use JavaScript to control everything, including other languages and other 
variants of JavaScript. Racket was attractive because the structure of a 
"governing" language was already in place, with access to many more features. 
This made problems A and B seem less significant when I ran into them again, 
because I always had a way out of a technical corner.

I agree with you about adapting tools to what people already know, but not for 
the same reasons. You mentioned "GUIs and spreadsheets." I think the 
productivity gains of a GUI do not discount the need for LOP. For example, my 
wife uses Excel for work, but she took the time to learn SQL, Excel Macros and 
VBA to address data problems that GUIs won't make easy for her (like making 
reports using inventory data in different formats from many international 
entities). She never planned to be a programmer, and she doesn't call herself 
one, but she became one by the circumstances of a global economy where 
everybody is doing their own thing.

Another example: A lawyer reached out to me due to his interest in Racket, and 
how it can help him manage his firm's growing collection of evidence and notes. 
His rules for keeping the documents organized and mutually-reinforcing were 
sophisticated, but his staff was having trouble working within those rules. 
They would frequently ask him to clarify where to put a particular PDF. This 
lawyer (again, someone who does not identify as a programmer) has trouble with 
the file managers, search features, and the other organizational tools in their 
disposal. And when I listened to him speak, he was... thinking like a 
programmer!

What does it tell you if my wife, an accountant, has to learn SQL and VBA to be 
an accountant?What does it tell you if a lawyer independently stumbles onto 
Racket and wonders what it could do for his business?

It tells me that people's work is getting complicated, and you can't just say 
that Racket is failing to adapt to what people know. If we are going to live in 
a world of people forced into computer literacy, and GUIs are not able to cover 
these little openings to deep technical rabbit holes, then we need a way to 
help people keep moving when the things they know start to fail them. But what 
do we use to quickly synthesize complex and exact ideas at a moment's notice? 
Language. Why would I accomodate user's knowledge of tools that were too 
limited to help them in the first place? I can trust them to communicate, so 
why not give the words they know power? After all, they'll always have words.

I don't know if LOP is the best answer, or the answer that will see the most 
adoption. All I know is that Racket is the most interesting attempt at the 
answer I've seen so far.

~slg

‐‐‐ Original Message ‐‐‐
On Sunday, January 3, 2021 4:26 AM, Leandro Facchinetti  
wrote:

> Hi all,
>
> Here are the videos:
>
> Playing the Game with PLT Redex: https://youtu.be/NszLQNROdw0
> Understanding the Type of call/cc: https://youtu.be/7Zkt_IJaYOY
> Racket: Why I Think It’s a Great Language, and Why I’m Not Using It Anymore: 
> https://youtu.be/_wY7FBtr7_c
>
> The first two used to be articles on my website (https://leafac.com), but I 
> changed the way the website is built and took them down. From time to time 
> people ask me about it, so here it is, in video form.
>
> I hope you like it.
>
> Best.
>
> --
> 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.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/racket-users/16cbbdc6-63e6-4f78-8862-76f7ff52ec01n%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/16cbbdc6-63e6-4f78-8862-76f7ff52ec01n%40googlegroups.com?utm_medium=email_source=footer).

-- 
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.
To view this discussion on the 

[racket-users] Typed Racket: require macros from untyped modules

2021-01-03 Thread unlimitedscolobb
Hello,

How can I require macros coming from untyped modules into typed modules?

Intuitively I'd expect that to be possible in a way or another because such 
imports don't seem to violate any safety guarantees, but maybe I'm missing 
something.

-
Sergiu

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b4315813-0a63-4a1f-a1d5-1ea344cd5c67n%40googlegroups.com.


Re: [racket-users] Why do single-form modules behave differently?

2021-01-03 Thread Ryan Culpepper
It's the consequence of two design goals:

1. The `module` form is separate from the `#%module-begin` syntax hook so
that the module's initial language can pick the hook macro that controls
the entire module body.

2. Racket's primitive syntax is designed so that it can be re-expanded.
(The `expand` operation should be idempotent.) Some of Racket's tools (for
example, debugging support) work by expanding code, instrumenting it, and
then re-expanding, compiling, and running the result. But a
`#%module-begin` hook macro can transform the module body in non-idempotent
ways, so that hook macro should only be called once. So the answer to "have
I already run the module's `#%module-begin` hook?" must be reflected in the
fully-expanded syntax of the module.

Ryan


On Sun, Jan 3, 2021 at 8:40 AM Michael MacLeod 
wrote:

> Oops, sorry about interpreting your question wrong. Unfortunately I don't
> know the answer to your actual question.
>
> On Sat, Jan 2, 2021, 10:24 PM Sage Gerard  wrote:
>
>> I know about that. I asked why it was designed that way.
>>
>>
>> Sent from ProtonMail mobile
>>
>>
>>
>>  Original Message 
>> On Jan 3, 2021, 12:18 AM, Michael MacLeod < michaelmmacl...@gmail.com>
>> wrote:
>>
>>
>> There's an edge case of 'module' when only one form is provided which
>> results in that form being partially expanded to determine if such
>> expansion would lead to a #%plain-module-begin form. Otherwise (more than
>> one form provided) they are wrapped in #%module-begin with no partial
>> expansion occurring.
>>
>> I think this might be causing the discrepancy you witnessed.
>>
>> From the docs (https://docs.racket-lang.org/reference/module.html):
>>
>> If a single form is provided, then it is partially expanded in a
>> module-begin context. If the expansion leads to #%plain-module-begin, then
>> the body of the #%plain-module-begin is the body of the module. If partial
>> expansion leads to any other primitive form, then the form is wrapped with
>> #%module-begin using the lexical context of the module body; this
>> identifier must be bound by the initial module-path import, and its
>> expansion must produce a #%plain-module-begin to supply the module body.
>> Finally, if multiple forms are provided, they are wrapped with
>> #%module-begin, as in the case where a single form does not expand to
>> #%plain-module-begin.
>>
>> (This response was adapted from one of my earlier replies to the mailing
>> list. Search racket-users for "perplexed by macro-expansion behavior near
>> #%module-begin" for more context).
>>
>> Best,
>> Michael
>>
>> On Sat, Jan 2, 2021 at 8:26 PM Sage Gerard  wrote:
>>
>>> Why does Racket handle modules with exactly one form differently?
>>>
>>> I ran into a bug where modules in my module language won't expand if the
>>> modules have exactly one form, so I'm just curious.
>>>
>>> (Wild guess: It's Racket's way of checking for a shortcut to end
>>> expansion earlier)
>>>
>>> *~slg*
>>>
>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/OVvZ0OK4_PfyvXCWfuvzDWBM5-ellmDvNmWchVmsCwAJb_rbSZkCkyraakcGsEMSCl2BsLsWtMXFhQcXY75IKhYiYYGQQEI7lVXLgGBbTCc%3D%40sagegerard.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CACehHmBvs5KK4vQmwio93D1NZ9hTOoSv-Qkm8XOjF%2B4JWDOiHg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33qmm57T3jFZW_saSQ_g%3Der5BNRdARuAjtSJ%2BsMsaQnQo%3DA%40mail.gmail.com.


Re: [racket-users] PLT Redex: how to falsify the judgment in define-judgment-form

2021-01-03 Thread Robby Findler
I think this boils down to a question about how redex executes judgment
forms. Leaving aside modeless judgment forms (where redex will only check a
derivation for you but won't ever make them up), redex is turning each
judgment form into a (fancy) function from the inputs to sets of the
outputs and, based on how that function goes, will build a derivation for
you.

So, in the example in your message, think of `infer` as a function that
consumes the first thing and produces the second thing, where the part
below the bar is a kind of case/choice and the part above the bar are
recursive calls. So, if we want to use that rule, we'll be given "C" and
have to come up with "B". To make the recursive call to infer for the
premise, we have to supply an "A" which will then give us a "B". And now
we're stuck because we don't have that "B".

Of course, there are many other ways that one could think of turning
judgment forms into something that is, at least in some sense, executable.
Doing something like prolog is an obvious choice (although Redex is more
expressive than the standard/original prolog so there are some tricks
required) and Redex does indeed use a prolog-inspired solver when it is
generating random derivations that satisfy a judgment form (see Burke
Fetscher's dissertation). One might also try to turn it into a SMT query,
but Redex doesn't currently do that (and there aren't any plans to do
that). Perhaps there is another way too.

So, as to your specific question, the answer is "it depends". If you can
formulate your judgment form in a way that respects the mode, then yes, you
can use premises to constrain the sets of valid judgments. If not, you
can't.

hth,
Robby


On Sun, Jan 3, 2021 at 2:59 AM Xu Xue  wrote:

> Hi, Racketeers
>
> Since Redex can calculate all possible results in the judgment, Can I add
> some negative premise to help derive the output? like
>
> (define-judgment-form Lambda
> #:mode (infer I O)
> [(infer A B)
> *(not (infer number B)*
> -
> (Infer C B)]
>
> I tried to replace bold line with (side-condition (not (judgment-holds
> (infer number B, which is disallowed in Redex since B is in the output
> position.
>
> So any standard way to express this intention?
>
> more concrete example is in
> https://github.com/juniorxxue/applicative-intersection-semantics/blob/main/definition.rkt#L94
>
> Regards
> Xu
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/25e4ec2e-ba34-4a53-8284-37cbac422ae2n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdONOr5pJCtmH53bT-7tH3OuyVeKm_P61M0KSAegsx%3DQa%3Dg%40mail.gmail.com.


[racket-users] I made some videos about Racket (a.k.a the return of Playing the Game with PLT Redex)

2021-01-03 Thread Leandro Facchinetti
Hi all,

Here are the videos:

Playing the Game with PLT Redex: https://youtu.be/NszLQNROdw0
Understanding the Type of call/cc: https://youtu.be/7Zkt_IJaYOY
Racket: Why I Think It’s a Great Language, and Why I’m Not Using It 
Anymore: https://youtu.be/_wY7FBtr7_c

The first two used to be articles on my website (https://leafac.com), but I 
changed the way the website is built and took them down. From time to time 
people ask me about it, so here it is, in video form.

I hope you like it.

Best.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/16cbbdc6-63e6-4f78-8862-76f7ff52ec01n%40googlegroups.com.


[racket-users] PLT Redex: how to falsify the judgment in define-judgment-form

2021-01-03 Thread Xu Xue
Hi, Racketeers

Since Redex can calculate all possible results in the judgment, Can I add 
some negative premise to help derive the output? like

(define-judgment-form Lambda
#:mode (infer I O)
[(infer A B)
*(not (infer number B)*
-
(Infer C B)]

I tried to replace bold line with (side-condition (not (judgment-holds 
(infer number B, which is disallowed in Redex since B is in the output 
position.

So any standard way to express this intention?

more concrete example is in 
https://github.com/juniorxxue/applicative-intersection-semantics/blob/main/definition.rkt#L94

Regards
Xu

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/25e4ec2e-ba34-4a53-8284-37cbac422ae2n%40googlegroups.com.