[racket-users] Re: curly-fn language syntax not recognized in the repl

2020-10-20 Thread Greg Hendershott
It looks like this works neither in Dr Racket nor Racket Mode's REPLs.

>From a hasty, shallow look, it seems that the curly-fn package 
 uses a convention or 
protocol defined by the namespaced-transformer package 
.

As a quick experimental hack, if I namespace-require the 
namespaced-transformer module before entering read-eval-print-loop -- so 
that the #%namespaced syntax transformer is defined -- then this does work 
in Racket Mode's REPL.

So I could... just add that. But I don't know the history of this. Is this 
a convention that Alexis proposed be adopted by Dr Racket? If so, was it 
not adopted simply due to lack of time, or, for technical reasons like 
gotchas or some other ideas about how to approach this?

Maybe someone like Alexis or Robby remembers?

On Monday, October 19, 2020 at 10:38:57 AM UTC-4, primer wrote:
>
> If I run this program:
>
> #lang curly-fn racket
> (map #{/ 1}  '(1 2 3))
>
> I get the expected result in the repl.  But in the repl after the run, if 
> I type:
> (map #{/ 1}  '(1 2 3)) 
>
> I get an error:
> #%namespaced: undefined;
>  cannot reference an identifier before its definition
>
> Is there a way to make this work in the repl?
>

-- 
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/cbc697a3-9e82-4a4b-8f6b-6e93b6ed14dco%40googlegroups.com.


[racket-users] Re: Problems using (debug-repl) with emacs racket-mode

2020-10-20 Thread Greg Hendershott
To post back to the list, this was resolved:

  https://github.com/greghendershott/racket-mode/issues/499

On Wednesday, October 14, 2020 at 8:48:43 PM UTC-4, primer wrote:
>
> I'm trying to use (debug-repl) in the following simple program:
>
> #lang racket 
> (require debug/repl)
>
> (define (add a b)
>   (debug-repl)
>   (+ a b))
>
> (add 4 5)
>
> If I run this in Dr. Racket, then I get a repl prompt as expected.  
> However, I'm using Greg Hendershott's racket-mode for emacs, where it blows 
> up with the following:
>
> ; 
> ; Welcome to Racket v7.8.
> ; 
> > 
> ; cache-set!: contract violation
> ;   expected: path-string?
> ;   given: #f
> ;   in: the 6th argument of
> ;   (->
> ;path?
> ;syntax?
> ;syntax?
> ;string?
> ;namespace?
> ;path-string?
> ;any)
> ;   contract from: (function cache-set!)
> ;   blaming: 
> d:\data\prj\EmacsUnification\emacs\home\.emacs.d\elpa\racket-mode-20200924.1506\racket\syntax.rkt
> ;(assuming the contract is correct)
> ;   at: 
> d:\data\prj\EmacsUnification\emacs\home\.emacs.d\elpa\racket-mode-20200924.1506\racket\syntax.rkt:89.18
>
> I'm not sure if this is a bug or a setup issue.  FWIW, I'm setting up 
> racket-mode in my .emacs file as follows:
>
> (use-package racket-mode)
> (add-to-list 'auto-mode-alist '("\\.rkt\\'" . racket-mode))
> (require 'racket-xp)
> (add-hook 'racket-mode-hook #'racket-xp-mode)
> (add-hook 'racket-xp-mode-hook
>(lambda ()
>  (remove-hook 'pre-redisplay-functions
>#'racket-xp-pre-redisplay
>t)))
>
> Has anyone had any luck getting these two things to play nice?
>
>
>

-- 
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/4b92fe6d-d642-4f69-b751-908a5b414d20o%40googlegroups.com.


[racket-users] Re: Racket-mode (emacs) get coverage without using test submodule

2020-10-20 Thread Greg Hendershott
Racket Mode was recently enhanced in this neighborhood:

  
https://github.com/greghendershott/racket-mode/issues/316#issuecomment-691586485

If you upgrade it and that works for you, great.

If not feel free to open a GitHub issue about it. (Right now I'm not really 
able to download that pl.plt file and try it myself.)

On Tuesday, October 13, 2020 at 3:53:52 PM UTC-4, Julian wrote:
>
> Hi,
>
> For reasons X and Y that I won't get into I'm using Emacs instead of 
> DrRacket for writing racket code for the Programming languages class that 
> I'm taking. I have found that racket-mode (as recommended by 
> https://docs.racket-lang.org/guide/Emacs.html) is able to do a lot of 
> neat things and most of what I need to code. 
>
> The one limitation that I have run into is running my code and getting any 
> kind of coverage information, whether that's visual highlighting or a 
> printout in the REPL. At the moment I use DrRacket exclusively for this 
> task. Back in the racket-mode Emacs world the closest thing that I have 
> found is this: 
> https://racket-mode.com/#racket_002dtest
>
> However, this method not flexible enough since it requires me to put my 
> tests in the following form, which differs from the test writing convention 
> that I have to follow for this class:
> (module+ test (require rackunit) (check-true #t))
>
> I have heard that xrepl should be able to help me since I should be able 
> to use
> ,coverage
> but when I try to require it in the repl I get the following:
>
> hw4.rkt> (require xrepl)
> ; hw4.rkt::424: Type Checker: missing type for top-level identifier;
> ;  either undefined or missing a type annotation
> ;   identifier: require
> ;   in: require
> ; Context:
> ;  /usr/racket/collects/syntax/private/id-table.rkt:454:11 
> free-id-table-ref
> ;  /usr/racket/collects/syntax/private/id-table.rkt:454:11 
> free-id-table-ref
>
> The racket language I'm using is a custom teaching language (#lang pl 04) 
> available here .
>
> Does anyone have any ideas on how I could get coverage to work directly 
> with racket-mode or with xrepl still inside of Emacs?
>
> Background: I'm not experienced with Racket (only have knowledge of 
> [B/I]SL languages and what I'm learning in this class) and I'm also not an 
> Emacs wizard.
>
> Thanks for the help.
> - Julian
>
>

-- 
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/2ed8f669-d2d6-4e3d-a349-3201ff7f42a5o%40googlegroups.com.


[racket-users] Re: provide-if-not-defined

2020-09-03 Thread Greg Hendershott
What if you instead rename the lang's imports (e.g. with prefix-in), and 
rely on the fact that your definitions override those supplied by the lang?

That way you could write the exact same provide for all the files: 
"provide-if-not-defined" is simply provide. However, you would need to 
manually use the renamed imports in your implmentation.

Rough sketch:

#lang racket/base

(module v1 racket/base
  (provide +))

(module v2 racket/base
  (provide +)
  (require (prefix-in rkt: racket/base))
  ;; At this point, both + and rkt:+ are aliases.
  ;; But after the the following definition, + is yours:
  (define (+ . vs) ;; like racket/base + but wrapped in a list
(list (apply rkt:+ vs

;; (require 'v1)
;; (+ 1 2) => 3

;; (require 'v2)
;; (+ 1 2) => '(3)


On Wednesday, September 2, 2020 at 10:29:12 AM UTC-4, Shriram Krishnamurthi 
wrote:
>
> Related to my previous post [
> https://groups.google.com/g/racket-users/c/OqyqDFxwhf0], I have several 
> cases where I have this kind of pattern:
>
> V1:
>
> #lang racket
> (provide +)
>
> V2:
>
> #lang racket
> (provide [rename-out (my-+ +)])
> (define my-+ …)
>
> Each variant provides some/all primitives directly from the module's lang, 
> while a sibling variant changes their behavior.
>
> Since there are a lot of names, it gets tiresome to remember which things 
> have and haven't been exported. Duplicates are of course caught statically, 
> but missing names are not "caught" at all at module definition time.
>
> It'd be nice to be able to write, say a block like
>
> #lang racket
> (provide-if-not-defined +)
>
> at the top of BOTH files. In V1, this turns into provide; in V2 I'd still 
> write the rename-out, but would only need to do this for the (usually) 
> small number of operations that I am overriding. Having a common block at 
> the top of each variant would ensure that the variants provide the same 
> language.
>
> Shriram
>

-- 
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/fbdc80bf-fe01-441d-af93-e7d614374b56o%40googlegroups.com.


[racket-users] Re: find-expr: find a corresponding expression in the definition window

2020-08-31 Thread Greg Hendershott
I might be misunderstanding and the following isn't some fully-thought-out 
proposal, but:

IIUC both #%module-begin and read-eval-print-loop use current-print.

What if current-print accepted a new, optional srcloc parameter?

And the default #%module-begin were changed to supply this?

That way, a print handler for a plain-text tool^1 could use the srcloc to 
create some sort of "link", as well as Racket GUI tools like DrRacket using 
it to create some fancier UI.

^1: This includes TUI tools like emacs, as well as GUI tools like vscode 
using a text serialization format like JSON.

-- 
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/6e1d2180-288d-4789-88fc-2980aaf03650o%40googlegroups.com.


[racket-users] Re: combining require, build-path, and namespaces

2020-07-21 Thread Greg Hendershott
Do you definitely want *only* definitions explicitly provide-ed by the 
module, or is it acceptable (or even desirable) to see *all* module 
definitions?  If the latter, you could use module->namespace.

On Tuesday, July 21, 2020 at 11:45:38 AM UTC-4, Shriram Krishnamurthi wrote:
>
> How I can combine these three? I want to do something like this:
>
> (define n (make-base-namespace))
> (define p (build-path f))
> (eval `(require ,p) n)
>
> Racket doesn't like that: bad syntax for require sub-form because p is a 
> path-typed value.
>
> Essentially, I want to inject the module at f into n so that the provided 
> identifiers of f are visible inside n. (I haven't been able to get 
> dynamic-require working either, nor is it an entirely satisfactory 
> solution because I may not always know what names f is providing.)
>
> Thanks,
> Shriram
>

-- 
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/aa4d274a-3617-42f7-8e5a-666b45f8b227o%40googlegroups.com.


Re: [racket-users] Re: Is there an easy way to daemonize a thread?

2020-05-21 Thread Greg Hendershott
Maybe I need more coffee, but a possible heads-up: The current 
implementation doesn't seem to match the documentation -- wouldn't the 
with-handlers need to move inside the loop, for it to be infinite?

https://github.com/Kalimehtar/thread-utils/blob/master/main.rkt#L35-L41

On Tuesday, May 19, 2020 at 9:11:54 PM UTC-4, David Storrs wrote:
>
> Perfect, thank you.
>
> On Tue, May 19, 2020 at 5:28 PM George Neuner  > wrote:
>
>> On Tue, 19 May 2020 12:01:54 -0400, David Storrs
>> > wrote:
>>
>> >I'm using the file-watchers module to keep an eye on a directory tree and
>> >trigger various actions whenever something changes.  I had an issue where
>> >an exception was thrown, the thread died, and file watching therefore
>> >stopped.  The immediate solution is to wrap a with-handlers around it so 
>> it
>> >doesn't end up killing the thread, but this made me wonder if there's an
>> >easy way to do this automatically?
>> >
>> >What I'm thinking of is "Create a thread that will do something in a 
>> loop.
>> >Ensure that the thread remains running and restart it if it dies for any
>> >reason.  Also, make sure that it runs periodically."  I can think of a
>> >solution involving multiple threads, channels, and polling to ensure that
>> >the 'daemonized' threads are running, but I was wondering if there's a
>> >built-in or existing answer.
>>
>> There is a package called "thread-utils" which claims error safe
>> looping threads.
>> https://pkgs.racket-lang.org/package/thread-utils
>>
>> *Disclaimer*  I have never tried it.
>>
>>
>> I can think of a some possible implementations, but they all involve
>> monitoring by a separate thread (which could be the main thread).
>> Channels aren't necessary - monitoring can be done using events.
>>
>> Restarting a (possibly failed) computation IN a running thread is
>> relatively simple - if you know what errors or events might occur. The
>> problem is that a thread can't restart itself if somehow it gets
>> suspended or killed.
>>
>> George
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/uvi8cftuuvfkq0cqm27m0icvhhq5mpupuo%404ax.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/a1eba505-25f5-4ced-8f40-644fbced1e07%40googlegroups.com.


[racket-users] Re: Question about generating urls with dispatch-rules from imported modules

2020-04-28 Thread Greg Hendershott
Although I haven't tried to use it hands-on, the description of the 
imperative flavor makes me think it might be intended to help with this?

  
https://docs.racket-lang.org/web-server/dispatch.html#%28part._.Imperative_.Dispatch_.Containers%29


p.s. In general you *can* do mutual requires with lazy-require. However you 
defer some errors to runtime, and, you need to list explicitly each 
definition you want to import. IMHO it's better for when the motivation to 
be lazy is about deferring loading and initializing a module, than it is 
for mutual imports. For the latter I tend to just try to move the shared 
definitions to some new module that the others require.

-- 
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/091f3749-8a4f-457b-ac29-37c3f581f798%40googlegroups.com.


Re: [racket-users] Logger shows lots of info messages about collapsible-contract-bailout and collapsible-value-bailout

2020-04-03 Thread Greg Hendershott
In case it's useful here are some levels for various loggers.


  '((cm-accomplice   . warning)
(GC  . info)
(module-prefetch . warning)
(optimizer   . info)
(racket/contract . error)
(sequence-specialization . info)
(*   . fatal))


Based on experience, this filters out "noise" when you're not actively 
working on one of those systems (as opposed to just using them). 

These are the defaults in Racket Mode's racket-logger-mode buffer:

  
https://github.com/greghendershott/racket-mode/blob/master/racket-custom.el#L349-L379

-- 
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/d0d4e978-ec16-42fa-8e37-c916d443139a%40googlegroups.com.


[racket-users] Re: Best way to handle different versions of Racket?

2020-04-03 Thread Greg Hendershott

>
> Is there a standard/recommended way to handle multiple versions of Racket 
> in library code?
>

1. You can use dynamic-require to see if the new thing is actually provided 
by a module, and in a with-handlers clause substitute your not-found, 
default behavior.

If you do that frequently you could wrap that in a little macro like this:

  
https://github.com/greghendershott/racket-mode/blob/master/racket/util.rkt#L86-L101

2. You could run tests using Travis CI or similar, against multiple/older 
versions of Racket.  For example:

  https://github.com/greghendershott/racket-mode/blob/master/.travis.yml

  https://github.com/greghendershott/travis-racket

-- 
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/1abd44b5-cec8-4c1a-a7d1-e2096f5a839d%40googlegroups.com.


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-07-25 Thread Greg Hendershott
> I've taught the exact same material at the start of a 3rd year CS PL
> course, and the students there didn't find the syntax as easy as one would
> hope for students with that much CS “experience”. In fact, unsurprisingly,
> many find the syntax as hard as expected for having trained on very
> different syntaxes (especially when they are unclear about the semantics
> that were attached to those syntaxes). Although the switch to teaching the
> start of the course with literally the same materials, with the students
> knowing that, seems to have reduced resistance substantially (presumably
> they don't want to be seen as complaining about something 1st year
> humantities students are fine with).

This makes me wonder if some experienced programmers dislike simple
syntax, not just because it is unfamiliar to them, but also because it
is too simple to serve as an effective in-group filter. If humanities
students are comfortable, we must raise the barrier to entry. ;)


p.s. I just now stumbled across the Iron Ring obtained from the Ritual
of the Calling of an Engineer. Probably everyone has heard of this
except me, but if anyone hasn't:

  https://en.wikipedia.org/wiki/Ritual_of_the_Calling_of_an_Engineer

-- 
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/87a7d1mv0t.fsf%40greghendershott.com.


Re: [racket-users] Racket v7.3.0.900 is available for testing

2019-07-24 Thread Greg Hendershott


> This release is the first one to include Chez-Scheme-based builds
> (labeled “Racket CS” on the pre-release page), and we’d be
> interested in hearing about any issues you encounter with these
> builds.

OK, I added a new "RELEASECS" target to travis-racket:

  https://github.com/greghendershott/travis-racket/issues/36

So now in a .travis.yml matrix, RACKET_VERSION can be any of:

  HEAD HEADCS RELEASE RELEASECS 7.3 7.2 7.1 7.0 6.12 6.11 6.10 6.9 6.8
  6.7 6.6 6.5 6.4 6.3 6.2 6.2.1 6.1 6.1.1 6.0 6.0.1 5.93 5.92 5.3 5.3.6
  5.3.5 5.3.4 5.3.3 5.3.2 5.3.1.

Plus there are boolean flags RACKET_MINIMAL and RACKET_NATIPKG.


> If all goes well, we will turn this version into a v7.4 release
> within a couple of weeks.

If anyone wants to say whether to handle that as RACKET_VERSION values
"7.4" and "7.4-CS", or, as a new boolean flag like "RACKET_CS":

  https://github.com/greghendershott/travis-racket/issues/37

-- 
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/87k1c7myb1.fsf%40greghendershott.com.


[racket-users] Message in the meantime?

2019-07-23 Thread Greg Hendershott
Although I'm still skeptical that changing the surface syntax will be a
sufficiently big net gain, and ought to be the next, highest priority?
I'm running with that idea for the following.

It seems like there are at least two "flavors" or "strengths", of giving
Racket a non-sexpr syntax someday:

1. The new syntax will be a choice, fully co-equal with sexprs. Both are
   "first class", "forever". Any great new Racket features work with
   either.

2. The new syntax will become the preferred syntax, used in
   documentation and advocacy. ("Change the culture" is the phrase I
   thought Matthew used initially -- but I welcome him
   clarifying/correcting/revising.) Sexprs and #lang racket will get a
   status that's not as weak as "deprecated", but not really as strong
   as co-equal with the new syntax.

Regardless of how it might turn out, years from now -- it seems to me
there are some pretty big gotchas with the latter choice in the
meantime. Especially for "advocacy" or "marketing" during the N years
until the new thing is ready.

TL;DR: How would we promote Racket in the meantime??

Example worry: Something similar to an "Osborne Effect".

- Effectively we'd be telling not-yet users, "You're right not to like
  sexprs! Go away and come back in N years after we've fixed that flaw."
  We're "validating the objection" -- justifying any inclination not
  even to try Racket, yet, despite everything it offers, already.

- As for existing users, they might hear, "Yes, some of you might not
  like this change. Or even if you don't hate it, might be disappointed
  we're changing that instead of doing something else you feel is a
  higher priority. We realize we might lose some of you. But we feel we
  have so little to lose, it's worth that risk." So, yeah. Effectively
  telling existing users they're "little to lose" isn't great. (Even if
  that's not the intent, that's what some people will hear/feel. There
  will be somewhat greater attrition.)

- During the years' wait, who would invest time doing more tutorials and
  books and advocacy, using the old syntax? Some might. Many would say,
  why bother; I'll wait.

In short, it seems like the "strong" version would freeze advocacy and
adoption during the N year transition.

Whereas I think something like the first version -- fully co-equal
syntaxes -- would be easier to talk about and minimize short-term harm.

---

Ignoring the implementation difficulty (which I realize is a ridiculous
thing to ignore, but just for a thought experiment): I've seen some SDK
or API docs with a "choose your language" UI that changes function
signatures and code examples.

- Could there be some reasonably good mechanical two-way enforestation /
  deforestation? Maybe I'm misusing those terms. I mean, convert
  documentation between the two syntaxes, on the fly.

- Even better, could this work well enough not just to display usable
  documentation, but to transform actual source code? (I don't know if
  this would need to impose something like the Go printer, to "enforce"
  coding styles, for acceptable round trips. I don't even know if that
  would be unfortunate or fortunate.)

If any of this is feasible, then talking about it now and during the
long wait, would help send a more positive message:

People could keep on keeping on, knowing that someday there will be
tools to help them convert (or not convert, as they wish). As opposed to
worrying they're investing time on something scheduled for cultural
deprecation.

---

Again, I'm still skeptical whether new syntax is the most effective,
highest priority. At the same time, I'm trying to contribute
constructively to refining that plan, in case it is chosen. In
particular I'm concerned about what happens to the community in the
meantime.

-- 
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/87muh4n112.fsf%40greghendershott.com.


Re: Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-22 Thread Greg Hendershott


 [[ Note: I sent this yesterday but the Google list server bounced it.
Although I told Matthew I was fine leaving it that way, with only
him seeing it, he encouraged me to post it again. ]]


Thank you for replying, Matthew.

It sounds like surface syntax, other back-ends, and better tooling and
documentation are the available ideas for enabling more people to use
Racket.

Of these, the one for which you have energy and enthusiasm is as I said
before a valid and extremely important consideration.

Within that decision space I wouldn't prolong the discussion.


> Improved tooling also seems high-effort -- medium-risk --
> medium-reward. I'll defer to those who concentrate more on tools,
> including the author of Racket mode for Emacs, to suggest a priority
> for this one.

Speaking of that, I had some plans what to do next. Even explore some
modest open-source funding. But Sunday morning hit the Pause button.

On Twitter I'm seeing some parody of old, sour, inflexible lispers who
only love sexprs. You know, fighting the inevitable electric car, which
is apparently on their lawn. Funny and unfair, both.

Although there are many ways and reasons to caricature me -- and I
heartily encourage anyone to do so, it's great fun! -- this doesn't
happen to be one of them. I spent a couple decades with C/C++. As my
mid-life crisis, instead of buying a sports car I learned Racket and
Emacs. Sexprs weren't a big deal; the new (to me) concepts were. Yes,
I've grown to really enjoy sexprs for editing (paredit), richer
identifier names, and not needing to check the tiresome board game rules
for operator precedence. But it's not like I can't use C or JS or Rust
or Haskell or Python or whatever syntax productively, especially when
not creating macros. In fact I can use those syntaxes by, say, using
those languages.

So for me, it's more like, "Well. If Racket will change that way, and
I'm skeptical it will help adoption, that feels like an inflection
point; a nudge to look around. Maybe spend more time with Rust or
Haskell or X, for the next ~10 years."

I'm not saying this is strictly logical. It's how I feel now. I'm also
not claiming it should be any input whatsoever into decisions made,
except maybe to the extent I'm representative of more people (and maybe
not even then).

Even if I decided to spend less time with Racket, I expect it would be
more like a slow cross-fade. This is not an abrupt, "So Long and Thanks
for All the Standard-Fish" announcement. :)

But seriously I feel like I need to wait for the dust to settle, digest,
understand where things will be in a couple years.

---

To answer your question, things like paredit, parinfer and fructure are
very interesting. With respect to adoption? Paredit seems like something
people try/abandon several times before it "sticks". I did; four times.
Since he was RacketCon, I should have mentioned Phil Hagelberg's
wonderful comment: "If you don't think paredit is for you, then you need
to become the kind of person paredit is for." :) So my uninformed first
question is, are structured editing tools equally as hard/easy as text
sexprs, for beginners? And OMG what about people who've already learned
the "obvious" syntax? I don't know. I'll mull that over and other
tooling ideas.

And as I already mentioned in my talk, support for indentation probably
needs to be per-module not just per-lang.

-- 
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/87tvbemazp.fsf%40greghendershott.com.


Re: Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-17 Thread Greg Hendershott
Thank you for replying.

I didn't mean to suggest I thought these things were already happening.
I don't.

And I'm sorry my attempt to express gratitude by saying you had every
right to decree it, sounded like I thought you actually would do it that
way. I don't.

I (mis?)understood that working groups would be to hash out technical
details -- not to set the basic direction and goals for the whole
project. I've seen that latter kind of discussion can be difficult even
in a small group. So I would understand *if* you decided to do that part
in private. OTOH if you decided to try it in public, that's great, too.

Whatever way the discussion would take place, I was suggesting some
questions to discuss. That's what I was trying to say even if I didn't
write as clearly as I hoped.

-- 
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/8736j5chez.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-16 Thread Greg Hendershott
p.p.p.s or whatever level of "p" I'm on:

The core team including Matthew have put decades of work into Racket.
The effort and dedication is amazing. So if Matthew wanted to decree
that he's been working on this a quarter century and just wants to
change surface syntax, next, dammit? I would have no possible
counter-argument or complaint. Really. I am incredibly grateful for
everything I've been able to learn and do with Racket.

At the same time, this seems like a juncture where Racket has an
opportunity to say who it is for, mostly. That is often a difficult
discussion because you can't be all things to everyone. And people can
feel some anxiety or irritation about change that they may or may not
want. I think the best thing to be done is go ahead and articulate who
Racket is for, people can digest and do whatever they need to do, and
things will eventually sort out fine.

-- 
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/874l3lct16.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-16 Thread Greg Hendershott
The stated purpose of this change was to increase Racket's popularity.

Someone asked, if Racket were already more popular, would this proposal
be made? The answer was, probably not.

It seems we're jumping over some questions:

1. More popular, among who?

   [About "research language": Is it primarily popularity in "academia",
   e.g. see more Racket in classrooms, in papers, and on conference
   slides. Or in "industry"? Of course both is nice, but if we ever must
   choose one as a priority, which one?]

2. How popular? Are we aiming for as popular as Clojure? Haskell?
   Python? Java? JavaScript?

3. What are various possible ways to achieve this popularity, including
   -- but not limited to -- changing the surface syntax?

4. Which are most likely to succeed? Which are most likely to backfire?

   [Backfire? See e.g. New Coke. Or Lotus 1-2-3 vs. Excel. Also, I have
some experience trying to make software products more popular.
Sometimes successfully. Sometimes not. It's difficult. Most things
you try, don't help. Some hurt. It is pretty typical for e.g.
salespeople to complain, "How can we sell more if we don't add
certain exact features the competition has?". This is the way of
salespeople. ;) Often the features are added, at great effort, and
it turns out not to help at all. Sometimes, it actually alienates
existing customers, who chose you for the distinctive feature the
salespeople wanted killed. No more customers, just worse
word-of-mouth.]

4. Do we have some sense of how to rank them on effort and risk?

5. Given all that, what should we do?


I think it would be a mistake to skip this discussion.

Of course, if the PLT team wants to discuss and decide, privately,
that's their prerogative. In that case I wish they'd share some of the
choices considered and rationale. This would help folks understand who
Racket is intended for, going forward.


-

p.s. I am NOT saying the following is what the decision should be. It is
only AN example. I don't even know if it would be my first choice --
because having the discussion is the whole point of figuring that out.
Having said that:

Let's say we wanted to aim (next, for now) for roughly "Clojure" level
of popularity. There are multiple companies using it, jobs, etc. It's
not nearly as popular as Java or Python, which is both good and bad.
Anyway, Clojure is relatively popular, "in spite of" sexprs, at least
partly because it runs on the JVM and JavaScript. As the Racket-on-Chez
effort concludes, and we wonder, what next, maybe a next step would be
to work on other backends, which IIRC was one of the stated benefits of
doing R-on-C.

Again, I'm not saying this is necessarily my preference or "vote". I'm
saying it's an example of a plan that flows from the previous plan.
People can understand why, immediately. It builds on top of Racket's
existing identity and "fan base", and keeps a distinctive feature.


p.p.s. The syntax proposal also seems to muddy the LoP and DSL messsage.
Maybe it's not strictly a contradiction. But it's a little confusing:
"LoP is great! You can choose the best way to express each part of each
program. Now, only some parts of some programs do a lot of math, for
which infix is nice. So guess what? We're going to urge everyone to
switch the default/public/core language to infix syntax. Just please
update documentation and books and tutorials and blog posts and gists
and Stack Exchange and"  So if this proposal indeed goes forward,
there probably needs to be some explainer or FAQ for this.

-- 
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/875zo1ctmw.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Advice for porting Interactive Brokers API to Racket

2019-07-11 Thread Greg Hendershott
Some systems provide a way to query for a capability: COM has
QueryInterface, Racket dynamic-require, Emacs fboundp, and so on. When
such a query method is available, you can simply ask for the thing you
need or prefer. If it's available, great. If not, act appropriately:
Fail, or use your own "back fill" that does something similar or is just
a no-op, or whatever is appropriate.

[IMHO this is more sensible than using version numbers as proxies for
the thing you really care about. Especially lawyerly systems like
so-called semantic versioning. But I digress. :)]

The Racket flavor is something like the following. Let's say
some/module/path maybe has a new fribble function. If that's not
present, or if indeed that whole module isn't even installed, we want to
use our own our-fribble function as a default:

(define (our-fribble _x)
  'some-default-value)

(define fribble
  (with-handlers ([exn:fail? (λ _ our-fribble)])
(dynamic-require 'some/module/path
 'fribble)))

For example, I use this and also Emacs' fboundp in Racket Mode, to
support various versions of Racket and Emacs, both.


I don't know if/how this would help your case. Their API uses the
futzing-with-version-numbers approach. Even so, _maybe_ you'd want to
localize the version number checks in one module, which provides the
functions for your other code to use? The functions will end up being
either the real broker thing, or your own default.

-- 
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/87ftncpvke.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Auto-generated AWS SDK

2019-07-10 Thread Greg Hendershott
It's definitely an interesting and smart approach, today.

I hope the following doesn't sound defensive; it's just context and
observations.

Keep in mind that my package dates back to 2012.

1. There were a half dozen AWS services. Of those few, S3 was the 90% use
   case.

2. There was no API spec for machine-generation. Because 1; why bother.


For most services, the only truly tricky and difficult part is
request-signing. Most services need one core function: You give it an
HTTP request, it gives you back the signed request (or makes the signed
request and gives you back the response). You could add many little
"wrapper" functions around this. But some users would be fine just
forming the request and using the core function to sign it. Especially
for the services that just consume and excrete blobs of JSON.


So, I can imagine at least two packages for each of the ever-growing
number of AWS services:

1. A tiny core request-signing library.

2. A wrapper library. Machine-generated. It uses 1.

Some people use 2. Others just use 1 directly.


As to who will plant the seed, harvest the wheat, grind the flour, and
bake the bread: My casual opinion is that most users of AWS are
eventually paying Amazon, and, many of the newer services are especially
clearly things that commercial entities will use. As a result, I think
that one or more companies using Racket with AWS to (try to) make money,
should do and/or fund any new work in this area.


p.s. Machine-generating wrappers doesn't mean there still won't be
non-trivial work, even if "just housekeeping". For N AWS services, there
are N*2 packages to maintain. Even more if one does the {lib doc test
meta} package split. CI scripts need to be updated for new versions of
Racket. And so on.

p.p.s. Although I wouldn't object if commercial entities using my
existing package wanted to recognize my work with a donation, I also
don't mind if they don't.

-- 
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/87muhmotga.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Greg Hendershott
I'll chime in only because some of the usual suspects who could best
answer this might be busy with the Racket summer school this week.


I believe that function contracts can be about as fast as the sort of
checks you'd code by hand, provided that:

- The parameter contracts are simple, flat, first-order predicates like
  `string?` and combinators thereof like `(or/c number? string?)` or
  `(and/c number? positive?)`.

- The return value is `any` -- not even `any/c`, just `any`. Effectively
  don't check the return value(s).

If callers already have contracts that will check the value as it is
used, then maybe the only thing a non-`any` return value contract would
get you is more precise blame in the error message. Whether that is
worth the probably somewhat slower speed, is your choice.


If you want the contact to protect the function itself, not merely
as-provided by a module, you can use `define/contract`.

You could also move some definitions into a sub-module, and contract the
provide from there.

In any case, the nice thing is that you can use or create any boundary
you prefer to put the contract on.

-- 
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/87tvbwpafx.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] requirements for streaming html parser

2019-06-06 Thread Greg Hendershott
Although I don't think I currently /need/ a streaming parser for speed
or space reasons, I can imagine using one.

I'd suggest making something where the user supplies an "on-element"
"callback", which is called with each element -- plus the "path" of
ancestor elements. The user's callback can do whatever it wants.

That could be its own, focused library. I won't say "simple" because
you're parsing HTML!! :)

I can imagine other libraries built on top of that. One I would want to
use (or write myself, share, and use) would offer something like CSS
selectors. Not their syntax. Just some simple function combinators to
express the equivalent. (Because xml/path is close, and maybe enough for
XML, but not quite enough for real-world HTML.) In fact I already do
this, on the full HTML. I can imagine doing this on top of a streaming
parser, instead.

So those are my quick thoughts. I hope that's helpful, and also, other
people will have even better feedback for you.


p.s. One suggestion I have, which you might not like: I think it would
be good if you host Racket packages on GitHub, GitLab, or similar other
site you find least objectionable. I respect your rationale for not
doing that, to-date. On the other hand, people these days like to see
the full git commit history, issues, and pull requests. It helps them
evaluate a package, and feel good about future availability. When they
don't, it can be a speed bump to adoption. If you're aware of all this
but still don't want to do that, again I 100% respect that. Just my
opinion and perspective.

-- 
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/87blza17t5.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Greg Hendershott
It seemed like most of your question was about creating the name
identifier for the `define`. I focused on (and hopefully answered) that
part. But I didn't pick up on what you said the error message was:

>> attempts to use with-syntax* also fail with errors like "modified-rst:
>> unbound identifier in module (in phase 1, transformer environment)".

So, this part isn't about `magic-name`. It's about `modified-rst`
in your second clause:

  (define-syntax (named-query stx)
(syntax-case stx (name-line)
  [(_ (name-line (_ 0) (_ "name") magic-name))
   (with-syntax ([name (string->symbol (syntax->datum #'magic-name))])
 #'(define name
 (lambda () (void]
  [(_ (name-line (_ 0) (_ "name") magic-name) . rst)
   (with-syntax ([name (string->symbol (syntax->datum #'magic-name))]
 [modified-rst (cons (datum->syntax #'rst always-true-line) 
#'rst)])
 #'(define name
 (lambda () (query . modified-rst]))

A few things:

1. The invocation you mentioned:

>> The macro invocation will look something like this:
>>
>> (named-query
>>(name-line (offset 0) (name-type "name") "tga-image"))

doesn't seem to match that second clause? So I'm not sure how that
invocation is giving you that error message. Is it actually some other
invocation example?

2. I don't see where `always-true-line` comes from. Where is that
defined? What kind of values will it have?

3. Could you say more about what you're trying to do here?

  `(cons (datum->syntax #'rst always-true-line) #'rst)`

-- 
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/87k1eb8a2j.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Greg Hendershott
If users of your `named-query` macro will supply the name as an
identifier -- an unquoted symbol like some-name in this example:

  (named-query (name-line (_ 0) (_ "name") some-name))

Then what your macro needs to do with the pattern variable is... just
use it -- as is -- in the template. (It is already a piece of syntax
that could be a valid identifier. You're all set.)


If the idea is that users will supply the name as a string like
"some-name", then yes your macro would need to do the

  (string->symbol (syntax->datum #'magic-name))

thing you already have -- but *also* convert that result back to syntax:

  (datum->syntax #'magic-name
 (string->symbol (syntax->datum #'magic-name)))


p.s. That (datum->syntax _ (string->symbol (syntax->datum _))) triplet
has an equivalent handy shortcut -- `format-id`:

  (format-id #'magic-name "~a" #'magic-name)


p.p.s. I had similar questions before and wrote this:



-- 
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/87lfyr8f0q.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket Mode documentation

2019-05-24 Thread Greg Hendershott
Sorawee Porncharoenwase  writes:
> Hmm. I'm seeing "This site can’t be reached" (DNS_PROBE_FINISHED_NXDOMAIN).

Instead please try with "www" subdomain:

  https://www.racket-mode.com/


Although the zone apex (racket-mode.com) was working for me, yesterday,
probably I don't have it configured correctly to work for all of the
people all of the time. Will consume more coffee and take a look.

-- 
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/87o93r9a1d.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Racket Mode documentation

2019-05-24 Thread Greg Hendershott
That also looks cool! Definitely a lot of overlap. Maybe some
differences:

- I'm documenting Emacs major modes (an "app" vs. a lib). So my doc is
  less concerned with example code that ought to be tested. More
  concerned with stuff like showing default key bindings.

- I wanted the README to get shorter not longer. Instead I wanted users
  to get a local/offline Info, and also, produce HTML to host online.


I started out a couple weeks ago, with the vague idea of making a
doc-only Racket package. However the local Info, plus the existing happy
paths to do org->texi->info and org->html, tipped me back to the Emacs
side.

Otherwise and in general I still love using Scribble and scribble/srcdoc
for Racket apps and libs.

-- 
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/87pno79a4r.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Racket Mode documentation

2019-05-23 Thread Greg Hendershott
Recently I consolidated and updated Racket Mode documentation.

It is generated in two formats:

- Info: Installed locally. View in Emacs with `C-h i`.

- HTML: View at .


If you're curious how it's prepared:
.

-- 
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/87sgt48q9r.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] First class compound datatypes that can Racket

2019-05-22 Thread Greg Hendershott
Apparently I was too specific and pragmatic.

Let me try the opposite: Maybe more general than you want. :)

After spending some years with Racket, I've noticed certain things are
very popular targets of extension or customization. One is `define`.
Another is `struct`.

The catch is, these various customizations don't necessarily
combine/compose well, if at all.

I haven't thought about this very much. My first question would be,
could there be something roughly like define-match-expander -- a
"define-struct-expander" and a (ouch) "define-define-expander" -- that
would help? I don't even know if is a very difficult problem, or, very
easy and someone has already figured it out and it just needs more
"promotion" and uptake.

For example, I believe David Storrs has been working a lot recently on
struct-plus-plus. What if someone wanted to use some aspects of that and
also of what you're doing, that weren't inherently incompatible. And of
course also, as you mentioned, use aspects of plain old `struct`. Is
that even possible? How would that even work?

-- 
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/87zhnd9amk.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] First class compound datatypes that can Racket

2019-05-22 Thread Greg Hendershott
Just spitballing here, trying to start with "what's the simplest
possible thing that could work?":

You could let the user flag a field as the event. I don't know your
surface syntax, but maybe using an `#:as-evt` keyword would be OK?

You could link/refer the user to the `prop:evt` docs, or, copypasta the
relevant bullet points. (~= "the field must be an event?, or, a
procedure that takes an instance of the struct, yada yada...").

`never-evt` is a reasonable default value if the user hasn't generated
any. Unless you think `always-evt` would be. :)

IIUC this is a struct _type_ property, so it won't waste space
per-struct to specify `#:prop:evt never-evt` as the default. I think.


p.s. While you "have the hood open", you might also want to do something
similar for `prop:procedure`?

-- 
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/874l5ma2qe.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] tip for promoting racket on yc hacker news

2019-05-20 Thread Greg Hendershott
I agree it's good to promote Racket everywhere.

At the same time, I recommend folks not take HN too seriously. :)

Scanning the links? Often worthwhile.

The comments? Sometimes good. Often epic Dunning-Kruger.

If you're busy you can instead just read this weekly summary:

  http://n-gate.com/

You're welcome. :)

-- 
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/878sv0wjph.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Keeping my mind sharp

2019-05-11 Thread Greg Hendershott


Greg Hendershott  writes:
> Idea: The cool kids these days tend to create an account on GitHub or
> GitLab. That way, other folks can see the code and more easily offer
> advice. Plus, the commit history is itself a story about your journey
> doing this. The commit messages can even be sort of mini blog posts,
> draft material for real blog posts.

To expand on this. I mostly wrote Turbo Pascal and C code in the 80s.
Today I mostly write Racket. Going from C/Pascal to Racket, is a big
change. :)

But also important: In the 80s I mostly didn't use version control. (In
the 90s, I mostly used version control systems that mostly were awful.)

So: Git is also a change. A big change. At least for me. I commit early
and often. It's a way to leave a trail of breadcrumbs. What was I
thinking? How the heck did I get here? How can I back up and get out?
You could think of it as a kind of persistent undo system. (Plus it can
be an undo _tree_: You can quickly/cheaply make branches to explore
different approaches, in parallel.)

That change may or may not be something that you want to embrace. I just
wanted to clarify that using Git{Hub Lab} as a kind of "coding social
network" is only part of the story when it comes to Git.

-- 
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/87sgtk3gg1.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Keeping my mind sharp

2019-05-11 Thread Greg Hendershott


Others will have better advice, but a few thoughts:

Josh Rubin  writes:
> I have questions.
> (1) Should I be trying to *port* old Scheme code to Racket (a big job) or
> should I be *creating a language* that mostly runs the old code as is?

As an early "warm-up" step, maybe try to port some small chunk(s) of
your old Scheme code to Racket, by hand? You'll start to learn some of
the issues -- get a feel for what might be involved if you were to port
the rest by hand, or, depend more on "adapter" code, or, even create a
full #lang.

To attempt the last of these right off the bat, might be overwhelming?
It would be, to me. But I guess it depends on your learning style. Also
it depends whether you like to work more "top down" vs. "bottom up".

People who know older Scheme dialects better than me might have
more-specific tips.

> (2) Should I record all my false starts and confusions in a blog called "An
> old man tries to learn Racket"?
> Might interest struggling racketeers, or people who try to teach them.

That would be great!

Idea: The cool kids these days tend to create an account on GitHub or
GitLab. That way, other folks can see the code and more easily offer
advice. Plus, the commit history is itself a story about your journey
doing this. The commit messages can even be sort of mini blog posts,
draft material for real blog posts.

-- 
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/87tve03hkv.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: tilda - a threading macro full of itself

2019-05-07 Thread Greg Hendershott


> I like this. Reminds me of `rackjure/threading`, but more involved.

A few years ago, after Alexis released

  https://github.com/lexi-lambda/threading

I updated rackjure to re-provide that.

Speaking of which, a couple issues there might be interesting for you,
Vlad.

For example, it's better if a threading macro expands using the `#%app`
bound at the macro use site. (Whereas by default, macros expand using
identifiers bound where the macro is defined.)

  https://github.com/lexi-lambda/threading/issues/3

Also you might want to treat `quote` forms specially, and not "thread
into" them.

  https://github.com/lexi-lambda/threading/issues/2

-- 
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/87r29axhzq.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Module not updating on the package server?

2019-05-01 Thread Greg Hendershott
> Sure.  But I'm not looking for the package server to do tests for me, I'm
> looking for it to not discourage people from using my package because
> there's a red 'fails' next to the name when there shouldn't be.  Especially
> when it hasn't tried to rebuild the package for two weeks.

Probably the daily build server didn't try to build it for two weeks,
because the package catalog said it didn't change for two weeks, because
the repo didn't have any new commits between March 16 and April 30.

(I actually thought the daily build server built everything daily.
Apparently it only rebuilds when the outcome could be different, which I
guess makes sense.)

It looks like the daily build server noticed yesterday's package catalog
update and built this morning:

  

> The time is now Wednesday, May 1st, 2019 8:15:04am

As for the dependency problems:

  

> raco setup: --- summary of package problems ---
> raco setup: undeclared dependency detected
> raco setup:   for package: "test-more"
> raco setup:   on package:
> raco setup:"base"
> The time is now Wednesday, May 1st, 2019 8:15:14am

I think you simply need to add to your `info.rkt` something like

(define deps '("base"))

or, if you know you need a version of Racket >= something like (say) 7.2:

(define deps '(["base" #:version "7.2"])

And then... wait up to 24 hours. :)


p.s. Not to flog it but AFAIK the easiest way to discover any such
minimum version requirement is to set up Travis CI with a bunch of
Racket versions and let it discover and tell you. For example:

  

-- 
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] Module not updating on the package server?

2019-04-30 Thread Greg Hendershott
Not to speak for Jay, but I think the package server's primary role is
to be a catalog server -- "given a package name, I'd like to cash that
in for some code". For projects hosted at Git{Hub Lab}, that means the
package server needs to know the project URL and the commit digest. It
refreshes the latter automatically (hourly, I think?). But if you're in
a hurry, you can click Refresh Packages.


One consumer of the package/catalog server -- but a distinctly separate
thing -- is the build server, which runs daily. This does "CI" testing.
Since part of building packages with docs is rendering the docs, it
saves the results to use for docs.racket-lang.org.


I think it's usually a good idea to set up your own CI, using something
like Travis CI (or Circle CI, or the CI built into GitLab). That will
give you quicker feedback. Also it can run automatically on code you
push to topic branches and run on pull-request branches -- before it
even gets merged to master. (I like to set GitHub repos to protect the
master branch, so that even I the repo owner can't push directly to
master, until things pass CI on a topic branch. This saves me from
lazy-didn't-run-the-tests-Greg more often than I would like to admit.
Also it helps me discover problems on an older version of Racket that I
am still trying to support.)

So, I think of the daily build server more as a last line of defense,
when it comes to CI.

Admittedly, when it comes to docs, it can be frustrating to wait up to a
day for those to be refreshed on racket-lang.org. However people who
install or update the package will get the new docs built locally.

-- 
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] make extensions or replacements

2019-04-21 Thread Greg Hendershott
On Sat, Apr 20, 2019 at 12:02 PM Norman Gray  wrote:
> On 20 Apr 2019, at 1:11, 'John Clements' via Racket Users wrote:
>
> > There’s a paper at the most recent ICFP from Simon Peyton Jones (et
> > al., I’m guessing) on make languages, IIRC.
>
> Very interesting -- thanks!  The paper is Andrey Mokhov, Neil Mitchell,
> and Simon Peyton Jones. 2018. Build Systems à la Carte. _Proc. ACM
> Program. Lang._ 2, ICFP, Article 79 (September 2018), 29 pages.
> 

>From a quick read of the paper:

- Many silly things have happened in the last 10 years due to people
wanting to believe they have same challenges as Google, Facebook,
Microsoft. "But is it web scale?" :)

- The Shake "dynamic" example is interesting, but I'm pretty sure I
recently did the same thing in Make using variables. I tried to follow
the two links to learn more details, but the RIAA sorry MPAA sorry ACM
paywall blocked me.

Having said all that, I'm not here to defend Make as a delightful surface DSL.

-- 
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] make extensions or replacements

2019-04-16 Thread Greg Hendershott
I have a shallow understanding of GNU Make, which is only somewhat
less-shallow as a result of recently redesigning my blog to be
Makefile-driven.

In the process I learned to like using make variables. I learned that
a variable can be populated from make functions like $(wildcard)
$(patsubst) and the ultimate escape hatch $(shell).

So, if you have (say) 5 unique stanzas, it might be possible to
arrange this as 5 variables -- each of which is a list of that kind of
source or target files. Then you can state the build recipe once in a
single rule for each.

If the 5 kinds of things have distinct file extensions, or are in
distinct subdirs, this is fairly easy to do with $(wildcard) and/or
$(patsubt).  Otherwise (if you can't or prefer not to give them
distinct extensions or locations), then potentially you can use
$(shell) to run something that knows how to distinguish them. Maybe a
find or grep command. Maybe even a little .rkt program.

So my guess is that the means of abstraction you need, does exist in
GNU Make. But even so, it sounds like you might not enjoy using it.

On Tue, Apr 16, 2019 at 4:13 PM Hendrik Boom  wrote:
>
> On Tue, Apr 16, 2019 at 09:54:03PM +0200, da...@erl.nu wrote:
> > Hendrik,
> >
> > What is that you are trying to do, maybe you are misunderstanding some
> > concept about make?
> >
> > It seems to me that the whole point of make is to "run a program" whenever
> > some of the files have changed.
>
> Yes, that part of make is easy.
>
> The problem comes when you have many files that have to be made
> depending on many files and there is a repetitive nature to the
> dependencies.  The kind of similarity that is handled by abstraction in
> any normal programming language.
>
> And make itself has rules that can be used to do things like make *.out
> files from *.in files based on the file types, a long as the rules can
> be expanded by filling in the rest of the file names.  These are used
> when it provides, say, default rules to compile .c files to .o files
> and the like.
>
> This is, I guess, a kind of abstraction.  But abstraction that takes
> only one parameter is a poor kind of abstraction.
>
> There seems to be no mechanism to provide additional parameters to
> these rules, to accomodate slight variations in the stanzas.
>
> I've thought of using Racket to generate stanzas.  Or to avoid
> generating Makefiles altogether and directly implement make-like
> semantics in Racket using its profound flexibility and then to use
> Racket code to Make whatever I want.
>
> But maybe, just maybe, there are already better tools than GNU make.
>
> -- hendrik
>
>
> >
> > Regards,
> >
> > David
> >
> > On 2019-04-16 21:25, Hendrik Boom wrote:
> > > I'm sending this here, not because it's directly related to Racket,
> > > nor because i think you all are experts in make or GNU make, but
> > > because you are reasonable erudite in language appreciation.
> > >
> > > I, like many others, have been using a Makefile as a recipe to make a
> > > lot of files from other files.
> > >
> > > The trouble is that a lot of the stanzas are quite repetitive.  I want
> > > to refactor.
> > >
> > > If I were writing this in any other language then make,  i would just
> > > define a function with about three or four short parameters and call it
> > > many times, each time doing the equivalent of several of these stanzas.
> > >
> > > Roughly speaking, the abstraction tools of GNU Make are terrible.
> > >
> > > I'd like to ask you, what other tools might you actually recommend to
> > > used in addition to make, or instead of it, that make the build
> > > process more like normal programming?
> > >
> > > If I could get make to run a program to make another makefile and then
> > > execute that new makefile, I suppose I could write the program that
> > > makes all the repetitive (but not quite the same) stanzas.  But that
> > > would likely make the build process somewhat obscure.
> > >
> > > Sure, I could invent something.  But chances are, someone else already
> > > has invented something better than I'd improvise.
> > >
> > > -- hendrik
> >
> > --
> > 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 

Re: [racket-users] Is there a way to find where some feature is implemented in racket?

2019-04-16 Thread Greg Hendershott
DrRacket: In addition to the open defining file feature that Matthias
mentioned, you might like the File | Open Require Path command.

racket-mode: M-. aka racket-visit-definition and C-c C-x C-f aka
racket-open-require-path are the respective equivalents. [Also C-M-.
aka racket-visit-module when you have point on a relative or absolute
path inside a `require` form. (Although this doesn't yet know how to
handle `multi-in` forms.)]

For general spelunking I've found the interactive search from "open
require path" to be pretty great.


On Tue, Apr 16, 2019 at 8:44 AM Matthias Felleisen
 wrote:
>
>
>
> On Apr 16, 2019, at 8:31 AM, zeRusski  wrote:
>
> I suspect I'm not the first to ask, but my search-fu has failed me here. 
> Apologies if the question has already been answered on that list.
>
> When I read Racket docs I sometimes wonder how a particular feature is 
> implemented. Looking at the source sometimes shed light or simply teaches you 
> things. However I find myself grepping Racket source and very often failing. 
> Is there a better way? Latest such encounter was s-exp meta language. I 
> assume its implemented somewhere, but grep mostly just shows scribblings or 
> its use sites. What "algo" should I employ to find relevant source of a 
> thing? Would be grand to have links from docs,  but its probably quite 
> involved.
>
>
>
> Open DrRacket.
> Use the feature in a syntactically correct way.
> Click (depending on your OS) on the identifier to open defining file.
>
> Like so.
>
> #lang racktet/base
> (provide)
>
> Right-click on provide.
> See
>
> (module reqprov '#%kernel
>   (#%require "define.rkt"
>  (for-syntax '#%kernel
>  "stx.rkt" "stxcase-scheme.rkt" "small-scheme.rkt"
>  "stxloc.rkt" "qqstx.rkt" "more-scheme.rkt"
>  "member.rkt"
>  "../require-transform.rkt"
>  "../provide-transform.rkt"
>  "struct-info.rkt"))
>
>   (#%provide lib file planet submod
>  for-syntax for-template for-label for-meta
>  require
>  only-in rename-in prefix-in except-in combine-in only-meta-in
>  relative-in
>  provide
>  all-defined-out all-from-out
>  rename-out except-out prefix-out struct-out combine-out
>  protect-out
>  local-require)
>   .. .. ..
>
> --
> 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] Error location in test submodules

2019-04-04 Thread Greg Hendershott
> Are you using emacs racket-mode? I have experience this issue only in that 
> mode since it does not (to my knowledge) implement all the error anchoring 
> features of DrRacket.

It might just be that you have DrRacket set to user a higher
errortrace level than racket-mode?

That is, in DrR, Language | Choose Language | Dynamic Properties, you
may have chosen one of the "Debugging"  radio buttons and checked
"Preserve stack trace".

In racket-mode, the equivalent is the `racket-error-context` variable:

  
https://github.com/greghendershott/racket-mode/blob/master/Reference.md#racket-error-context

If you have it set to 'low or 'medium, you might not get as much error
context as with 'high (just like if you had "weaker" options in that
DrR dialog box, DrR wouldn't show you as good error context).

As Eric notes, you can leave this set to 'low or 'medium, and do C-u
C-c C-c to re-reun with it temporarily set to 'high. This can be a
nice way to get the best of both worlds: Normally things build and run
faster (errortrace can be slow). If you experience an error, and the
message isn't ideal, you can C-u C-c C-c.


Finally, racket-repl-mode tries to notice Racket error messages in the
output and "linkify" them. You can click them with the mouse, or use
the standard M-x next-error (often bound to C-x `) to go to the error
location. This works with rackunit failures as well as errors.

Of course, it helps if the error file is /path/to/foo.rkt instead of
foo.rkt. Sometimes Racket tries to be helpful and abbreviate long
pathnames to be . racket-mode tries to defeat this abbreviation
so go-to-error can work. :)

Also, some macros don't do the ideal thing -- i.e. don't use e.g.
syntax/loc or quasisyntax/loc -- and the error location is inside the
macro when it might make more sense for it to be the macro use site.
There's not much racket-mode can do about that, AFAICT.


p.s. I didn't feel like you were dissing racket-mode, so I hope the
above doesn't sound defensive. I want to explain what it attempts to
do. I dogfood it heavily and I don't like it to annoy me. :)  However
I know it's far from perfect.  Also there are sometimes long stretches
where I have to be mostly just another user of racket-mode for $WORK,
and can't really detour to work on racket-mode much. Fortunately there
are other people who help contribute fixes and improvements (although
sometimes I get so busy I can barely keep up with their offered help,
and feel doubly guilty).

-- 
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] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread Greg Hendershott
If I understand correctly, the fourth paragraph here is relevant?

  
https://docs.racket-lang.org/reference/syntax-model.html#%28part._transformer-model%29

So, `foo-impl` is a binding introduced by the macro and gets that
macro invocation's fresh macro-introduction scope.

Whereas for example `name` is syntax coming from outside the macro,
and doing `(define-foo (blerg ___) ___)` twice would be an error due
to redefining `blerg`.

On Thu, Apr 4, 2019 at 4:45 PM zeRusski  wrote:
>
> I know in principle but on occasion I fail to understand the implications.  
> Let me think aloud. I don't have to be perfectly accurate, maybe just about 
> right. Hygiene here means that every symbol there e.g. arguments my macro 
> receives carry their "environment" with them. There exists some oracle which 
> can tell when two symbols refer to the same thing probably by checking 
> environments somehow. Since I just typed that foo-impl there in the template 
> it must be getting some fresh tag or "environment" attached to it to avoid 
> capturing something with the same name defined at the macro call site, right? 
> Ok. How the define before foo-impl is special then? We both know the "define" 
> I mean. Or is the newly attached "environment" is in fact not empty and comes 
> enriched with a bunch of Racket stuff? How do I reason when its safe to just 
> type a name and when it isn't? In fact, here. I just defined a foo-impl 
> outside. If I now remove the macro-defined foo-impl the code will still work 
> correctly and grab the outer definition. So define inside a template refers 
> to the usual define, but foo-impl doesn't? Why?
>
> (define (foo-impl op a b) (op a b))
>
> (define-simple-macro (define-foo (name:id formal:id ...) body:expr ...)
>  ... same ...
>
> (define-foo (bar op a b) (op a b))
> (define-foo (baz op a b) (op a b))
> (bar + 1 2)
> ;; => 3
>
>
>
> On Thursday, 4 April 2019 21:02:58 UTC+1, Ben Greenman wrote:
>>
>> Racket's macros are hygienic. They'll gensym for you.
>
> --
> 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] Error handling for the GUI

2019-03-26 Thread Greg Hendershott
My paragraph after that was ~= I don't understand the need to do
anything with a exn:fail:contract except show the user and exit.

IIUC that's already the default behavior for non-GUI Racket apps, when
some code is being hopeless.

1. Some other codes notices and raises exn:fail:contract.
2. The uncaught exception handler displays the details.
3. The app exits -- before it can do any more harm.

Can we agree that 2 and 3 is the best (or anyway least-worst) thing to
do?  That normally, no good step 4 exists?

If not: No worries, I won't try to convince you here.

If so: There might be conditions where 2 and 3 aren't happening at
all, or well-enough. We could dig into that.  (Maybe there aren't
enough details for a good "crash report". Maybe a handler somewhere is
eating exns. Maybe a GUI app, when run outside DrRacket, the user
doesn't necessarily see the message (??). And so on.)

On Mon, Mar 25, 2019 at 12:00 PM James Platt  wrote:
>
>
> On Mar 23, 2019, at 5:49 PM, Greg Hendershott wrote:
>
> > But -- contract violations aren't like that. They're about some code
> > surprising some other code. I think the only hope here is, run the
> > code enough (before the user ever does) to flush out the bad code
> > assumptions and fix them. Realistically that means having enough
> > automated tests, and running them frequently enough (like on every
> > code commit, or at least push, and you can't merge to master if tests
> > don't pass, etc.).
>
> Yes, but contract violations are also, by definition, problems that have been 
> anticipated.  You may not know why a function is, for example, being passed a 
> specific parameter that is the wrong data type or is empty when you said it 
> should be non-empty but you do know that that is what happened.  It's enough 
> to go on for an error message.  My hope was that contracts would provide a 
> more granular set of predicates to test for each of the possible violations.
>
>
> --
> 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] Error handling for the GUI

2019-03-23 Thread Greg Hendershott
Using `exn->string` from `racket/exn` should usually include context
("stack trace")?

  
https://docs.racket-lang.org/reference/exns.html#(def._((lib._racket%2Fexn..rkt)._exn-~3estring))

Also there will be more context to see, if in DrRacket or racket-mode
you've selected that higher level.


p.s. It's probably worth considering that many exceptions are
surprises about the world outside the program. File or network ports
couldn't be opened, read, written. Files didn't exist, or can't be
made not to exist. And so on. A program must deal with those, somehow.
Usually the exns will be something the user needs to see in the (G)UI,
ideally with a simplified message in their language, then the program
can hopefully resume just fine.

But -- contract violations aren't like that. They're about some code
surprising some other code. I think the only hope here is, run the
code enough (before the user ever does) to flush out the bad code
assumptions and fix them. Realistically that means having enough
automated tests, and running them frequently enough (like on every
code commit, or at least push, and you can't merge to master if tests
don't pass, etc.).

Because, there's rarely any good thing to tell the user, beyond
"internal error" + cryptic data for them to give tech support. In some
cases, the program is even in a state where it shouldn't continue
running and should exit. Taking the "do nothing" branch followed by
"do something" might be bad times for the user and their data. For
example, not saving new changes they made, is bad -- but it's not as
bad as also corrupting previously saved data.  Even when it's not that
dire, a contract violation usually means there aren't any great
choices.

I'm sorry if any of that sounds preachy!  TL;DR: Although it makes
sense for contract violations to be exn:fail:contract, but they're
really unlike most exn:fails. Contracts are more like ASSERTs in old
school C, and the traditional way to handle assertion failures is to
abend.

On Sat, Mar 23, 2019 at 4:03 PM Ben Greenman
 wrote:
>
> On 3/23/19, David Storrs  wrote:
> > Alex makes good points, but I'm curious about the original question:  Is
> > there a straightforward way to tell which function it was whose contract
> > was violated, aside from parsing the message?  Or, more generally, where a
> > specific exception came from?
>
> For blame errors, it might help to grab the blame object and ask it
> some questions.
>
> ```
>   #lang racket
>
>   (module a racket
> (provide (contract-out (f (-> symbol? symbol?
> (define (f sym)
>   (symbol->string sym)))
>   (require 'a)
>
>   (with-handlers ((exn:fail:contract:blame?
> (lambda (blame-err)
>   (define b (exn:fail:contract:blame-object blame-err))
>   (printf "bad value = ~s~n" (blame-value b)
> (f 'X))
>   ;; bad value = f
> ```
>
> Docs:
> https://docs.racket-lang.org/reference/Building_New_Contract_Combinators.html#(part._.Blame_.Objects)
>
> --
> 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] Thread safe operations and shared memory

2019-03-22 Thread Greg Hendershott
I think this is a pretty good overview of the "stock" choices:

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

On Fri, Mar 22, 2019 at 8:21 AM George Neuner  wrote:
> Message passing avoids most share locking issues, so it is better to 
> implement that way when possible.

I agree. Usually I start with a channel or async-channel. And usually
that turns out to be all I think need.

If you really need to, you can build things using semaphores, but
that's tricky and I'd suggest something like:

  http://greenteapress.com/wp/semaphores/

-- 
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: Pretty display of tabular data?

2019-03-15 Thread Greg Hendershott
This is a great idea. Also I want to point out that:

1. Sometimes it's OK to start by sharing a repo on Git{Hub Lab}. Not
everything needs to go on pkgs.racket-lang.org immediately, to be
visible and share, especially early on.

(To be clear, I'm not saying, "oh only perfect 1.0 things should be a
package". I'm just pointing out that pkgs.r-l.org isn't fantastic for
discoverability, so if that's the main motivation, it's not your only
or even your best option.)

2. If you do have a package that does XYZ, and someone then makes a
package for X, sometimes it's OK to change your package just to
re-`provide` their module for X (and yours still does Y and Z).

For example, my rackjure package had a threading macro. Then Alexis
made a `threading` package. It was 99% compatible, she took a PR for
the 1%, and I changed rackjure to re-provide that. And the docs say
so. So, it didn't break users of rackjure. Plus people could switch to
using `threading` directly, if/when they wanted. And the Racket world
had one less bit of duplicate code. I think that worked out well.

(In fact if that continued to where rackjure was "merely" a
"meta-package" that re-provided focused packages, I'd be fine with
that!)

Maybe that idea could apply here?

-- 
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] Pretty display of tabular data?

2019-03-15 Thread Greg Hendershott
> 90% of the reason I made `raart` is because of this.
>
> https://docs.racket-lang.org/raart/index.html#%28def._%28%28lib._raart%2Fdraw..rkt%29._table%29%29
>
> (require raart
> (draw-here (table (text-rows THE-TABULAR-DATA)))

Although I didn't see one in the docs, it looks like you have an
example in the tests:

  https://github.com/jeapostrophe/raart/blob/master/t/draw.rkt#L24-L39

-- 
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] What is the best way to "raco make" all *.rkt files in a directory tree?

2019-03-11 Thread Greg Hendershott
I think the best practice (at least my usual practice these days) is
to make a package.

Say the top of your tree is /path/to/project.

Once:

  raco pkg install /path/to/project

Thereafter your "make" is:

  raco setup --pkgs project


This also works fine for c:\path\to\project.

(Making it a local package like this doesn't mean you must publish it
to pkgs.r-l.org.)

On Mon, Mar 11, 2019 at 3:00 PM 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.

-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Greg Hendershott
To be fair:

As a new user, it's possible to have the intuition that `define` is
just a way to avoid indentation -- that it "writes a `let` for you,
from the point of the define to 'the end of the enclosing scope'".

And it's possible for that intuition to seem correct for a very long
time -- until you hit an example like Brian did. And then you need to
learn about `letrec`.

(As a non-new user, 99.9% of the time that I use a local `define` I
actually wish it were "like `let`" not `letrec`, but I use it anyway
and try to be careful.)


On Mon, Mar 11, 2019 at 12:29 PM Matthias Felleisen
 wrote:
>
>
>
> > On Mar 11, 2019, at 11:21 AM, Brian Adkins  wrote:
> >
> > I just discovered that define will fail at runtime, where let would fail at 
> > compile time. Besides helping to keep the indentation level from marching 
> > to the right "too much", what are the benefits of define over let?
> >
> > --- snip ---
> > #lang racket
> >
> > (define (f n) (+ n 1))
> >
> > (define (foo)
> >   (define b (f a))
> >   (define a 7)
> >
> >   b)
> >
> > (define (bar)
> >   (let ([b (f a)]
> > [a 7])
> >
> > b))
> > --- snip ---
>
>
>
> I think your characterization is a bit misleading here.
>
> In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly 
> signal at compile time.
>
> In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive scope. 
> But, when Racket evaluates (foo) it notices that ‘a’ is bound but 
> uninitialized, which is two different things.
>
> If you want to compare apples to apples, use a ‘letrec' instead of a ‘let' in 
> ‘bar'. Then you have (1) the same semantics and (2) the same error.
>
> — Matthias
>
> --
> 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] How to fix typos in documentation?

2019-03-08 Thread Greg Hendershott
I have a dumb question. Why can't doc pages have links whose label is
something like "Want to improve the docs?", and the URL goes directly
to the appropriate .scrbl file on GitHub?

- A .scrbl file knows its own syntax source file path.
- defmodule forms know how to make links to the package server.
- The package server has a catalog that knows where the source repo is.
- Often it knows, when a pkg is split -{lib doc test}, where the -doc
repo for a -lib is (although ironically "Documentation" for
scribble-lib is blank when I check now.)

Could these elements be combined to provide the direct link on the doc page?

Admittedly people still need to know how to use GitHub and do a PR.
But I think in my own case, the main speed bump feels like finding the
scrbl file to modify. If that were one click, I'd be more likely to
act even on low ROI tiny prose typos I might notice.

On Fri, Mar 8, 2019 at 11:52 AM Matthew Butterick  wrote:
>
> Perhaps this would be good material for a CONTRIBUTING.md at the top level of 
> the repo, where it would be more likely to be found by future contributors. 
> GitHub will automatically show a link to the file at arguably appropriate 
> times. [1]
>
> [1] https://github.blog/2012-09-17-contributing-guidelines/
>
> > On Mar 8, 2019, at 8:44 AM, Marc Kaufmann  wrote:
> >
> > Let me (ab)use this thread to add some more details on how to submit pull 
> > requests (PR) on GitHub to racket using the GitHub web interface for other 
> > noobs - which includes myself in another month or two. Ideally I would 
> > write this up elsewhere to help with onboarding, but that won't happen 
> > soon, so here we go. We are talking ELI5 (Explain Like I'm 5) level 
> > explanations, so this will be painfully obvious to the vast majority 
> > (although it would be good for someone who knows what they are doing to 
> > correct whatever kludgy workflow I've come up with). I copy most of the 
> > steps from Paulo earlier, but add some that I still had to figure out.
>
> --
> 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] Macros that conditionally generate code

2019-03-07 Thread Greg Hendershott
This reminds me of a similar thread on Slack yesterday.

When a macro `define`s something, it's usually better for everyone if
the identifier is supplied to the macro. It's nicer for you as the
macro writer because you don't need to think so hard about scope and
hygiene. And it's nicer for the user of the macro, not to have
identifiers injected.

It's usually OK to bend this rule, and make new identifiers based off
one supplied to the macro. For example, `(struct foo (bar))` will
define a `foo-bar` accessor. If you do something similar, using
format-id correctly to make `foo-bar` given `foo`, it should
"just-work". The format-id docs have a simple first example:
https://docs.racket-lang.org/reference/syntax-util.html#(def._((lib._racket%2Fsyntax..rkt)._format-id))

So I usually try to start on that happy, simple path.

On Wed, Mar 6, 2019 at 11:42 PM David Storrs  wrote:
>
> On Wed, Mar 6, 2019 at 11:31 PM Sorawee Porncharoenwase
>  wrote:
> >
> > Isn’t this because of hygienity in general?
>
> *headdesk*
>
> Of course.  Thanks, I should have recognized that.
>
> --
> 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] Is one path a direct or indirect subdirectory of another path?

2019-03-02 Thread Greg Hendershott
What is a portable, correct, efficient way to check whether one path
is "under" -- a direct or indirect subdir of -- another path?

AFAICT there's no racket/path function for this. Over the years I've
done various ad hoc things that seem non-ideal. Including: 1. Use
path->string and regexp. 2. Use split-path recursively. 3. Use a
combination of explode-path and split-common-prefix.  And either way,
hopefully remember to use simple-form-path to cleanse/simplify the
starting inputs.

I was thinking about this again when looking at security guards
recently. A file guard might want to check that the access is in/under
some approved directory. This usage ups the ante on both speed and
correctness.

Any suggestions or advice?

-- 
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] Cannot use case+else inside match+else

2019-02-25 Thread Greg Hendershott
Yep, I also spent a non-zero number of years not even realizing "else"
wasn't a magic literal for match. And then remembering to use _
instead, as Sorawee suggested.


I think this shows why it's usually better for syntax to use
#:keywords instead of literals? If cond and case used #:else, this
wouldn't be a problem.

(Racket inherited those from Scheme. But we don't have to follow that
example in our own, new macros.)

-- 
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: Help with generators from python land!

2019-02-23 Thread Greg Hendershott
I have zero mileage with Python generators and I don't teach CS. But
my understanding is:

Sometimes you have a problem where it is nicer to express the solution
as two independent pieces: a producer and a consumer that run
concurrently.

("Concurrently" doesn't necessarily mean actually in parallel, as with
an OS thread or process. In fact it's often simpler if it _doesn't_
mean that.)

In Racket you might run the producer and consumer in different threads
that talk over a channel. The producer does `channel-put` instead of
`yield`, and the consumer does `channel-get` or `sync`.

If you squint, it's all variations or specializations of continuations:

http://matt.might.net/articles/programming-with-continuations--exceptions-backtracking-search-threads-generators-coroutines/

-- 
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] Use cases for tables and records

2019-02-22 Thread Greg Hendershott
The overall idea sounds great. I don't really understand the
motivation for "records" with #:keywords?

Maybe you could add a quick explanation about how/when/why they would
be preferred over "more Rackety" choices:

When the keys aren't known at compile time:

- hasheq hash-tables with symbol keys, like jsexprs
- association lists

When the keys are known at compile time:

- structs


p.s. None of the above isn't about the name. But about that: I'm not a
"classic Scheme" person but I think "record" ~= "struct" there so that
might be confusing?

On Thu, Feb 21, 2019 at 2:59 PM  wrote:
>
> Hi folks! I'm looking for use cases for a few small data structure libraries 
> I'm working on:
>
> - Records, which are dictionaries mapping keywords to values. Keys must be 
> keywords, which allows for more efficient behavior in various cases and 
> sometimes cooperates nicely with keyword arguments. Example:
>
> > (define rec (record #:person "Joe Schmoe" #:age 30 #:favorite-color 'blue))
> > (record-ref rec '#:age)
> 30
>
> - Tables, which are like a list of records that all have the same keywords. 
> Tables are similar to dataframes and are intended to make it easy to process 
> spreadsheet-like data such as CSV files. Example:
>
> (table (columns #:name #:population #:capital-city)
>  (row "Argentina" 4380 "Buenos Aires")
>  (row "Greece" 1080 "Athens")
>  (row "Nigeria" 19860 "Abuja")
>  (row "Japan" 12640 "Tokyo"))
>
> The libraries are really just bare-bones skeletons at the moment and are 
> missing a lot of core features. Still, if they seem like things that you 
> would use, please let me know how! Pointers to code "in the wild" where you 
> think these libraries would help are especially useful. Pointers to similar 
> libraries (like the data-frame package) and discussions about their 
> advantages / disadvantages are also helpful.
>
> --
> 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] test user-interact function dont work

2019-02-17 Thread Greg Hendershott
What does it do? Does `check-equal?` show a failure message? If so,
what does it say?


I don't know what `refine-main` does, but this simple version works for me:

#lang racket

(require rackunit)

(define (refine-main)
  (display (read-line))) ;echo

(check-equal?
 (with-output-to-string
   (lambda ()
 (with-input-from-string "input"
   (lambda ()
 (refine-main)
 "input")

On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
 wrote:
>
> Hi everyone. I have a test of a user-related function that I don't can see 
> why don't work :
>
> #lang racket
>
> (require rackunit)
> (require "../../main.rkt")
>
>
>
>
> (check-equal?
> (with-output-to-string (lambda ()
> (with-input-from-string
> "exit 0"
> (lambda () (refine-main)
> ""
> "Consigo sair antes de comecar o tutorial")
>
>
>
>
> I think that this will call refine-main and, when refine-main do a readline, 
> will receive "exit 0" as string, and when display something, will appear as 
> return of with-output-to-string, but this code don't work :(
>
> --
> 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] Running raco setup from within DrRacket?

2019-02-16 Thread Greg Hendershott
p.s. If you wanted to do a general thing, for DrRacket, this is what I
was referring to. The README is probably enough of a hint, you don't
need to read the Emacs Lisp. :)

https://github.com/purcell/exec-path-from-shell

On Sat, Feb 16, 2019 at 10:07 PM Greg Hendershott
 wrote:
>
> From unsophisticated searching the source, it looks like the code to
> implement deps checking is in setup/private/pkg-deps.rkt -- "private"
> meaning you're not supposed to use it directly.
>
> It seems to be called from the `setup-core` function provided by
> (non-private) setup/setup-core.rkt. That seems to be controlled by a
> variety of parameters, including `check-dependencies`. You could
> probably figure out which ones to set, to approximate `raco setup
> ` as opposed to `raco setup` everything.
>
> Or...  system* raco is sounding nicer. But how to find its path.
>
> Are you on macOS?  If so, that's probably why raco isn't on the PATH.
> Every OS has odd things. Windows has it's share. macOS has one, which
> is that GUI apps' PATH doesn't inherit what you see in bash. (That's
> why emacs has exec-path-from-shell.)
>
> I'd suggest (find-system-path 'exec-file), which would be great in
> command-line racket. But in DrR that's something like
> "/Applications/Racket 7.0/DrRacket.app/Contents/MacOS/DrRacket".  Well
> I suppose you could do something like:
>
>(build-path (find-system-path 'exec-file) 'up 'up 'up 'up "racket"
> "bin" "raco")
>
> On Sat, Feb 16, 2019 at 12:34 AM  wrote:
> >
> > Using setup/setup works partially, but it doesn't seem to support package 
> > dependency checking (and the #:pkgs keyword argument isn't documented). I 
> > can't seem to find any programmatic alternative to the --check-pkg-deps and 
> > --unused-pkg-deps flags.
> >
> > On Friday, February 15, 2019 at 8:35:17 PM UTC-8, Matthias Felleisen wrote:
> >>
> >> See 
> >> https://docs.racket-lang.org/raco/setup-plt-plt.html?q=setup#%28def._%28%28lib._setup%2Fsetup..rkt%29._setup%29%29
> >>
> >> (require setup/setup)
> >>
> >> I think that’s what you want — Matthias
> >
> > --
> > 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] Running raco setup from within DrRacket?

2019-02-16 Thread Greg Hendershott
>From unsophisticated searching the source, it looks like the code to
implement deps checking is in setup/private/pkg-deps.rkt -- "private"
meaning you're not supposed to use it directly.

It seems to be called from the `setup-core` function provided by
(non-private) setup/setup-core.rkt. That seems to be controlled by a
variety of parameters, including `check-dependencies`. You could
probably figure out which ones to set, to approximate `raco setup
` as opposed to `raco setup` everything.

Or...  system* raco is sounding nicer. But how to find its path.

Are you on macOS?  If so, that's probably why raco isn't on the PATH.
Every OS has odd things. Windows has it's share. macOS has one, which
is that GUI apps' PATH doesn't inherit what you see in bash. (That's
why emacs has exec-path-from-shell.)

I'd suggest (find-system-path 'exec-file), which would be great in
command-line racket. But in DrR that's something like
"/Applications/Racket 7.0/DrRacket.app/Contents/MacOS/DrRacket".  Well
I suppose you could do something like:

   (build-path (find-system-path 'exec-file) 'up 'up 'up 'up "racket"
"bin" "raco")

On Sat, Feb 16, 2019 at 12:34 AM  wrote:
>
> Using setup/setup works partially, but it doesn't seem to support package 
> dependency checking (and the #:pkgs keyword argument isn't documented). I 
> can't seem to find any programmatic alternative to the --check-pkg-deps and 
> --unused-pkg-deps flags.
>
> On Friday, February 15, 2019 at 8:35:17 PM UTC-8, Matthias Felleisen wrote:
>>
>> See 
>> https://docs.racket-lang.org/raco/setup-plt-plt.html?q=setup#%28def._%28%28lib._setup%2Fsetup..rkt%29._setup%29%29
>>
>> (require setup/setup)
>>
>> I think that’s what you want — Matthias
>
> --
> 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] Questions about Scribble docs

2019-02-16 Thread Greg Hendershott
p.s. As another example of the current breakage: All my own packages
that do have documentation, have yellow "This package needs
documentation" demerit badges, at the moment.

On Sat, Feb 16, 2019 at 9:17 PM Greg Hendershott
 wrote:
>
> The package web site seems to think no packages have been built: The
> "Most recent build results" item is blank for every of the dozen
> packages I just checked.
>
> So I think that's one problem.
>
>
> When that's working normally, as it usually does, there are two levels
> of refresh:
>
> 1. The package catalog server points to e.g. your most recent commit
> on Git{Hub Lab}.com. You push a new commit. The package catalog might
> take an hour before it notices. This is the thing you can "kick" by
> logging in and choosing "Rescan my packges".
>
> 2. The build server runs daily. This is what builds your docs as part
> of building your package. So, even if it were working, now, it might
> take 24 hours. There's no way to nudge this AFAIK.
>
>
> On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
> >
> > Do I need to do something particular to make the package server notice
> > my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> > but the package server is still listing it as "needs documentation".
> >
> > Separate but related, when I install a module and it builds the
> > documentation, is there a way to make it integrate with the built-in
> > docs so that I can load it in the browser and search?
> >
> > --
> > 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] Questions about Scribble docs

2019-02-16 Thread Greg Hendershott
The package web site seems to think no packages have been built: The
"Most recent build results" item is blank for every of the dozen
packages I just checked.

So I think that's one problem.


When that's working normally, as it usually does, there are two levels
of refresh:

1. The package catalog server points to e.g. your most recent commit
on Git{Hub Lab}.com. You push a new commit. The package catalog might
take an hour before it notices. This is the thing you can "kick" by
logging in and choosing "Rescan my packges".

2. The build server runs daily. This is what builds your docs as part
of building your package. So, even if it were working, now, it might
take 24 hours. There's no way to nudge this AFAIK.


On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
>
> Do I need to do something particular to make the package server notice
> my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> but the package server is still listing it as "needs documentation".
>
> Separate but related, when I install a module and it builds the
> documentation, is there a way to make it integrate with the built-in
> docs so that I can load it in the browser and search?
>
> --
> 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: Autocomplete from a list

2019-02-15 Thread Greg Hendershott
If the user will choose very frequently (and you want the fastest UX),
and the choices in the database don't change very frequently: It might
be worth experimenting with caching the choices in memory. For
auto-complete I imagine something like a trie, or whatever the latest
hotness might be.

The memory use might be too much to accept. But if the choices have
enough redundancy, the size of the trie might not be awful.

The cache can get stale. How much this matters, depends on your app
and the data. Refreshing every N minutes might be fine? If it's not
fine, and if you're using postgresql, the db lib's postgresql-connect
accepts a notification-handler.

-- 
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] Wishlist for regexen: x mode, named captures, embeddable regexn

2019-02-14 Thread Greg Hendershott
I often prefer writing non-trivial SQL as s-expressions (using Ryan's
`sql` package).

I feel the same way about non-trivial regular expressions, and often
use the `rx` macro in Emacs Lisp.


In Racket, I tend not to write super complicated regular expressions.
For example, I started to write a markdown parser that way but...
um... yeah. I ended up using `parsack`.

When I do use regexps in Racket, I almost always use them with `match`
and the `pregexp` pattern, to bind the groups to identifiers.


There is some space between trivial regexps and a full/"real" parser.
Something like the `rx` macro, and it's also a match pattern, is
something I could imagine using.

-- 
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] Some concern about ChezScheme...

2019-02-06 Thread Greg Hendershott
> * As an aside, one of the few times I remember Kent Dybvig making a "joke" in 
> class was when he introduced the pass "remove complex operands." It was 
> called "remove-complex-opera*." At Indiana, where Opera is a Thing, I think 
> it was particularly funny as an inside joke of sorts. He devolved for a 
> moment into what I can only describe as giggles---but, it was subtle just the 
> same. It brings me a certain amount of joy to see "np-remove-complex-opera*" 
> in [3].

/me changes all his passwords from "correct horse battery staple" to
"remove complex opera"

-- 
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] get-pure-port/headers very slow

2019-01-24 Thread Greg Hendershott
Trying now, it finishes within 1 second for me. I tried on macOS with
all of 6.10, 7.1, and a recent-ish build of HEAD, 7.2.0.2.

On Thu, Jan 24, 2019 at 5:18 PM Sam Tobin-Hochstadt
 wrote:
>
> I investigated this (on linux) by killing the process after 1 and
> after 10 seconds, and both were in the `ssl-connect` function in
> `openssl/mzssl`. So my guess is it's something there.
>
> Sam
>
> On Thu, Jan 24, 2019 at 5:07 PM P. Baillet  wrote:
> >
> > Hello Racketeers,
> >
> > With Racket 7.1 on macOS, the following snippet takes some time to run:
> >
> > #lang racket
> > (require net/url)
> > (require net/url-string)
> > (get-pure-port/headers (string->url "https://video.blender.org;))
> >
> > time racket plop.rkt
> > #
> > "Access-Control-Allow-Origin: *\r\nContent-Length: 13080\r\nContent-Type: 
> > text/html; charset=utf-8\r\nDate: Thu, 24 Jan 2019 22:03:48 GMT\r\nEtag: 
> > W/\"3318-iMh3Y+6f+0qSo/4RXYkvd/3uy68\"\r\nTk: N\r\nX-Content-Type-Options: 
> > nosniff\r\nX-Dns-Prefetch-Control: off\r\nX-Download-Options: 
> > noopen\r\nX-Frame-Options: DENY\r\nX-Xss-Protection: 1; mode=block\r\n\r\n"
> >76.40 real 0.43 user 0.11 sys
> >
> > The same request with curl takes around 3ms server side and less than 1s 
> > term time.
> >
> > What’s the right way to investigate this issue?
> >
> > Thanks for your time,
> > —
> > P.
> >
> > --
> > 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] Collections and data structures wishlist?

2019-01-23 Thread Greg Hendershott
>> - A separation between using lists as homogeneous collections and using 
>> lists as fixed-size tuples. So there'd be a separate `tuple?` data type 
>> that's structurally equivalent to a list but meant to be used differently. 
>> For example, `(list/c number?)` would mean a list of many numbers, but 
>> `(tuple/c number?)` would mean a tuple of size 1 containing a number.
>
> "It is better to have 100 functions operate on one data structure than 10 
> functions on 10 data structures.” 
> http://www.cs.yale.edu/homes/perlis-alan/quotes.html
> "It is better to have 100 transducers operate on one data structure interface 
> than 10 functions on 10 data structures.” Rich Hickey, History of Clojure

Well also, I thought `list/c` already means "tuple"?

(listof number?) is a list of many numbers.
(list/c number?) is a list of one number.


I think it's within the Racket spirit to make a little #lang for
certain audiences or projects. At some org, "tuple/c" might be a
helpful alias. Or, for some other team, it's not, and in fact even
"list/c" is redefined to raise an error, "Please use structs instead
of ad hoc tuples."

-- 
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] Scribble: ugly spacing due to missing SIntrapara

2019-01-15 Thread Greg Hendershott
On Tue, Jan 15, 2019 at 10:04 AM Sorawee Porncharoenwase
 wrote:
>
> Yup. This is exactly the proposal I made above, but you stated it far more 
> clear :)

Whoops. Insufficient coffee. Sorry!

-- 
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] Are the terms "function" and "procedure" synonymous in Racket?

2019-01-15 Thread Greg Hendershott
I feel like every traditional term is subject to "how many angels can
dance on the tip of a parenthesis?" debates.

For example I prefer "function" but if we rename procedure-arity to
function-arity there will be people who complain that 1 is the only
correct value. :)

There are terms like "callable", but we have tail elimination.
"callable-and/or-jumpable" seems like a name that is both more
accurate and more horrible.

Something like "apply-able" or "applicable" seems better?  But we have
things like structs with prop:procedure, instances of which can be
applied.

So. Yeah. :)

I agree with you, George, what's most interesting is the possibilities
and the history trying them.

-- 
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] Scribble: ugly spacing due to missing SIntrapara

2019-01-15 Thread Greg Hendershott
It seems to me that each of those `defthing`s has reasonably good text.

The problem is that the text is in the preceding paragraph, instead of
inside `defthing`.

The motivation is it's in "user's guide" style not "reference" style.

But I'd argue these `defthing` forms belong in reference docs -- not guide docs.


Showing the "blue box" in this guide is a neat idea.

Using `defthing` to do so is where it gets a little weird?

Instead how about a new form -- called "refthing"? or "refbox"? --
that simply recapitulates the blue box from any `def*`?

-- 
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: Functional augmenting

2019-01-09 Thread Greg Hendershott
On Tue, Jan 8, 2019 at 4:35 PM Jens Axel Søgaard  wrote:
>
> Den tir. 8. jan. 2019 kl. 21.40 skrev David Storrs :
>>
>>
>> This.  In an ideal world, before/after/around would be parameterized so that 
>> you can make the change only for a defined scope.
>>
>> Still, the intent was never that it would extend its effects outside the 
>> current module.
>
> In that case you can use let-syntax and to redefine #%app.

If we're talking module scope, there's (require (rename-in racket/base
[+ rkt:+])), then define + as you prefer, using rkt:+ or not as you
like.

If we're talking local scope, there's local-require. Or simply (let
([+ my-plus]) (+ 1 2 3)).

Both are syntactically apparent. (The first is more apparent when the
require is at the top and the module isn't too long.) In terms of
cognitive load, it's just roses by other names.


If we're talking dynamic scope, then it sounds like generics / classes
/ passing a function as an argument, are likely to be better than
"monkey-patching" or "advising". That kind of stuff has its place for
emergency hot-fixes or endless mutable balls of end-user mud like
Emacs. But it's refreshingly sane not to have it as part of the
language or package ecosystem, I think?

-- 
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] Reasons not to use match or define/match?

2018-12-20 Thread Greg Hendershott
There is also the `struct*` pattern:

  
https://docs.racket-lang.org/reference/match.html#(form._((lib._racket%2Fmatch..rkt)._struct*))
On Thu, Dec 20, 2018 at 12:48 AM Philip McGrath
 wrote:
>
> On Mon, Dec 17, 2018 at 4:08 PM Jens Axel Søgaard  
> wrote:
>>
>> However if you add a field to a struct foo, then you need to a new field to 
>> all patterns matching foos.
>> If on the hand you used foo-bar then adding a field baz requires no changes 
>> to the existing code.
>
>
> You can avoid this issue by writing a custom match expander. If needed, you 
> can even overload the same identifier to serve as a match expander, static 
> struct information, and constructor function, just as `struct` would normally 
> do.
>
> For example, if you had a struct:
> (struct dog (name age))
> and then added a field to make it:
> (struct dog (name age color))
>  you could arrange so that, as a match pattern,
> (dog n a)
> would effectively expand to:
> (dog n a _)
> This would keep you from having to update any existing code.
>
> Doing this takes some work, even with macros to take care of the boilerplate, 
> so it seems to make most sense when you have a struct that's part of an API 
> (public or between parts of your project) and you want to avoid breaking 
> backwards compatibility. In such cases I often want to abstract as much as 
> possible anyway over how the datatype is implemented as a struct and present 
> the nicest interface possible to client code: for example, I will often make 
> the match pattern use optional keywords, because I don't like keeping track 
> of the order of fields in large and potentially-changing structs. I would 
> also note that, if you expose the struct-ness of your datatype to clients, 
> adding a field creates a similar compatibility problem with the 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.

-- 
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] typed racket backend/ir & gpu computing

2018-12-19 Thread Greg Hendershott
What is the "e" in "eDSL"?

-- 
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 (de)serialize PKI keys for storage?

2018-12-18 Thread Greg Hendershott
Maybe it is a limitation of libgcrypt? All three return #t for me when
using libcrypto:

(require crypto crypto/libcrypto)
(crypto-factories libcrypto-factory)

Although I don't know the pros and cons of each, it seems the
libcrypto pros include this working, as well as it being installed by
default on macOS (at least for me on 10.11.6)?

On Tue, Dec 18, 2018 at 5:36 PM David Storrs  wrote:
>
> I'm trying to persist public/private keys to our database and having some 
> trouble:
>
>
> Welcome to Racket v6.11.
> > (require crypto crypto/gcrypt)
> > (crypto-factories gcrypt-factory)
> > (define key (generate-private-key 'rsa))
> > key
> (object:gcrypt-rsa-key% ...)
> > (define pub (pk-key->public-only-key key))
> > pub
> (object:gcrypt-rsa-key% ...)
> > (public-key=? key pub)
> #t
> > (public-key=? key (datum->pk-key (pk-key->datum key 'OneAsymmetricKey) 
> > 'OneAsymmetricKey))
> #f
> > (public-key=? key (datum->pk-key (pk-key->datum key 'RSAPrivateKey) 
> > 'RSAPrivateKey))
> #f
> > (public-key=? key (datum->pk-key (pk-key->datum key 'rkt-private) 
> > 'rkt-private))
> #f
>
> The docs state that GCrypt does not have the ability to recompute a public 
> key component form the data in a 'PrivateKeyInfo format, so that's no good.
>
> pk-keys are objects, not structs, and there doesn't appear to be any way to 
> say "here's a private key and a public key, composite them".
>
> This has to be a thing that people do, so what am I missing?
>
>
> --
> 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] 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] 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 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] Loggers that don't prepend?

2018-11-26 Thread Greg Hendershott
make-log-receiver returns a synchronizable event; you start a thread
to loop and sync on that. Formatting and disposition is up to you.

1. Example from XREPL, displaying to stdout with `;` comment chars prepended:

  
https://github.com/racket/xrepl/blob/master/xrepl-lib/xrepl/xrepl.rkt#L1286-L1307

2. Example from racket-mode, writing to a TCP port...

  
https://github.com/greghendershott/racket-mode/blob/b977873e6128f8399432dcd60cc39f6a6f803d9c/racket/logger.rkt

...for the Emacs front-end to read from, and do things like color-code
the log levels, then display in a dedicated window:

  https://github.com/greghendershott/racket-mode/blob/master/racket-logger.el

3. I have also done a log-receiver that ships log events as JSON to
AWS CloudWatch Logs, for https://deals.extramaze.com but that code
isn't open source now.

Log receivers are fun.

Anyway you could certainly take 1, and omit the logger name and/or level.

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


Re: [racket-users] Racket application servers

2018-11-25 Thread Greg Hendershott
I just want to point out the possibility that your Racket web app
might not be CPU-bound. Some "generic" web sites are IO-bound. Blocked
on IO for the HTTP requests and responses. Blocked on IO talking to a
database server like Postgres.

In cases like that, you might not need more than one process. (Indeed
you might even get away with running on a t2.micro instance, which
throttles horribly after a short CPU burst, because you never come
close to that threshold even under your maximum traffic loads.)

It's a real possibility you might want to measure/see, first. Of
course it depends on how much work your Racket web app does (itself,
not farmed out to DB or other out-of-process servers), as well as on
the traffic loads you expect.

Having two or more servers might be convenient for non-load reasons.
For updates (to let the old "drain" as you described, or blue/green
deploys, etc.).  Or for fail-over (although I'm not sure 2 procs on
same box is the way to go, if you even really need many 9s (many sites
really don't if we're being honest with ourselves)).

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


Re: [racket-users] Racket application servers

2018-11-23 Thread Greg Hendershott
In my experience a Racket web server will just stubbornly continue to
work for months at a time, if you let it.

(Reminds me of the aviation joke. In the future, cockpits will have
just one human pilot and a dog. The dog is there to bite the human if
they try to turn off the autopilot.)

I have a site on one little t2.micro at AWS.

It is behind an AWS application load balancer -- but mainly just as an
easy way to do SSL termination.

I also added WAF to filter script kiddies who don't bother to supply a
valid Host header while they try to log into phpadmin or whatever. For
non-FANG sites honestly that will be a large proportion of your
traffic in terms of number of requests. It wasn't making the Racket
web server sweat, I just wanted to noise out of my logs and stats.

-- 
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] Destructuring a list in (for ...)

2018-11-23 Thread Greg Hendershott
> The trouble, sadly, is that this grammar is ambiguous. In
>
>   (for ([(x y) s])
> )
>
> should (x y) be parsed as a single match pattern or as two binders for a 
> two-valued sequence (such as one produced by in-hash, for example)?

Unless I'm being dense, (x y) isn't a valid single match pattern?

[Quasipatterns like `(x y) or `(,x ,y) would be.]

But even if it is grammatically possible, like I said at the end, I'm
not sure it's worthwhile.

-- 
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] Destructuring a list in (for ...)

2018-11-22 Thread Greg Hendershott
> (define-syntax (match-for stx)

That's nice.

Sometimes I wish I could do the general thing -- use `match` patterns
in the binding clauses for any `for`-family form.

I often do something like this:

(define xs (list (cons 1 2) (cons 3 4)))

(for ([x (in-list xs)])
  (match-define (cons a b) x)
  (use a b))

Instead it would be nice to write:

(for ([(match-define (cons a b)) (in-list xs)])
  (use a b))

Or even just:

(for ([(cons a b c) (in-list xs)])
  (use a b))

In the grammar, `id` becomes `id-or-match-pattern`.

On the other hand, this would only really help in simple
`match-define` destructuring -- as opposed to using `match` to handle
variations in the data. And although I do the former a lot, I do the
latter even more.

-- 
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] unit testing output

2018-11-06 Thread Greg Hendershott
On Fri, Nov 2, 2018 at 3:38 PM Neil Van Dyke  wrote:
> * Should such a failing message also have some way of click navigating
> to the test failure in DrRacket, like for exceptions? (Note that the
> answer to the next might be involved.)

Yes please! It is no fun finding a failing test source in an
unfamiliar code base.

I'd suggest writing to stderr the same location format used by rackunit.

That way people in emacs can add to compilation-error-regexp-alist items like:

 ;; rackunit check-xxx
 ("#]+\\)> \\([0-9]+\\) \\([0-9]+\\)" 1 2 3)
 ;;rackunit/text-ui test-suite
 ("^location:[ ]+\\(\\([^:]+\\):\\([0-9]+\\):\\([0-9]+\\)\\)" 2 3 4 2 1)

And people using other editors can do the equivalent.

-- 
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] distributed computation support for handin-server?

2018-10-23 Thread Greg Hendershott
Have you considered some sort of yield-management incentive, such as
offering a higher grade to students who submit during less-busy
periods? :P


Although I don't know anything about the handin server, or very much
about load-balancing, just riffing:

A simple round-robin HTTP proxy probably won't maximize processor
utilization. Maybe that doesn't matter. If it matters, I might start
with a single HTTP server that puts jobs in a queue, and let dedicated
racket-process-per-cpu processes pull them out one by one.

I might try just using the filesystem for the queue. Something like:
Handin jobs are saved to files under a "to-do" dir. Workers claim jobs
by renaming a files into an "underway" dir, one"), and later clean
delete that and plop a result file into a "done" dir. The HTTP server
watches that, sends the response. (You could instead use a "real"
database, or even a whole messaging system. But this might be one of
those cases where the filesystem is the least-worst choice.)

-- 
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] Scribble xref links in frog

2018-10-08 Thread Greg Hendershott
Is this for .md or .scrbl sources?

If scribble: It's been some years since I worked on this, but at a
quick glance Frog is running Scribble with --redirect-main
http://docs.racket-lang.org/


https://github.com/greghendershott/frog/blob/master/frog/private/read-scribble.rkt

So I'm not sure what's going on. Maybe easier (for me anyway) if you
open an issue there to discuss and investigate more?

p.s. It would probably be nice to update the docs.racket-lang.org URL
to use https, if that's an easy PR you wanted to do?

On Mon, Oct 8, 2018 at 2:50 PM Eric Griffis  wrote:
>
> My frog-generated blog is almost ready, but there's one detail stopping
> the show:
>
> Is there a way to make frog link to docs.racket-lang.org for all scribble
> cross-references?
>
> Exports from the "special" modules (racket/base, racket, ...) already
> point to docs.racket-lang.org, but cross-referencing into other
> locally-installed packages produces relative URLs to the local docs.
>
> In the Scribble docs (7.2 Handling Cross-References), I found this:
>
> The --redirect-main flag for HTML output redirects links to the local
> installation’s documentation to a given URL, such as
> http://docs.racket-lang.org/.
>
> Is there some way to pass this flag or emulate its behavior in frog?
>
> Eric
>
> --
> 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] Should #; comments be colored as comments or code in Dr Racket?

2018-10-08 Thread Greg Hendershott
p.s.

On Mon, Oct 8, 2018 at 11:41 AM Greg Hendershott
 wrote:
> Another use case (that Mattias might not love) is somewhere for "usage

Apologies for the typo, Matthias!

-- 
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] Should #; comments be colored as comments or code in Dr Racket?

2018-10-08 Thread Greg Hendershott
Sexpr comments are interesting because people want them to act mostly
like sexprs -- for indentation, and for structural editing/display
like paredit or rainbow-parens.

At most they should look like comments. Or not even that. As this
thread shows. :)


Another use case (that Mattias might not love) is somewhere for "usage
examples" to live during middle age.

- The usage examples are born when you casually type them into the REPL.

- They get copied to the file, so that, as you refine what they call,
they run to show the results you hopefully expect.

- Before graduation to some initial commit, people often sexpr-comment
them out. They can still be run via something like C-x C-e or C-M-x.

- Eventually, if the examples are good, ought they be moved to test,
srcdoc, and/or examples submodules?  Probably someday yes. But
retirement planning is hard work and people often postpone this. :)

TL;DR sexpr comments are sometimes used for things that TDD folks
might write up-front as formal tests.

-- 
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] add set-subset?

2018-10-05 Thread Greg Hendershott
Could we add a macro to allow defining alias names? Could call it
`set!-set-subset?`.

And probably want a way to see all such aliases:
`get-set!-set-subset?-set-subs`.


p.s. In all seriousness, the doc redirect is a great idea.

-- 
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] servlet development in REPL

2018-10-04 Thread Greg Hendershott
I just wanted to chime in and say I share Philip's preference.

I think programming is hard enough without multiple sources of truth.


p.s. Replacing expensive startup items with a no-op is a good idea. Or
sometimes, keep the "real-op" but postpone using one of:

- `delay/sync` and `force` from `racket/promise`:


https://docs.racket-lang.org/reference/Delayed_Evaluation.html#(form._((lib._racket%2Fpromise..rkt)._delay%2Fsync))

- `lazy-require`:


https://docs.racket-lang.org/reference/lazy-require.html#(form._((lib._racket%2Flazy-require..rkt)._lazy-require))

The former for individual definitions, the latter for entire modules.

-- 
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] Why does my package have no build status?

2018-10-04 Thread Greg Hendershott
> As to the dependency, there's no reason that people need to have 
> handy/test-more (the testing framework I use for struct-plus-plus) installed 
> in order to use the module.

Would it help to put `handy` in `build-deps` instead of `deps`?


> It's not clear to me how to use compile-omit-files in an info.rkt file.  Are 
> there examples I could look at?

Near the bottom of https://docs.racket-lang.org/raco/setup-info.html
where the compile-* options are mentioned, it links to the docs for
`compile-collection-zos` where there's more explanation:

  
https://docs.racket-lang.org/raco/API_for_Raw_Compilation.html#%28def._%28%28lib._compiler%2Fcompiler..rkt%29._compile-collection-zos%29%29


As for usage examples: I usually grep the Racket source and/or use
GitHub search:

  https://github.com/search?=Codel=Racket=compile-omit-paths

[ In fact I should probably make that into a little Emacs command that
prompts for the last query parameter then does `browse-url`. :) ]

-- 
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] Is there a way to enter! a file from the command line?

2018-09-08 Thread Greg Hendershott
> racket --repl --eval '(enter! "foo.rkt")'

Also, you could simply `racket --repl` once. In recent versions of
Racket, XREPL is enabled by default. It has commands like `,enter`
that you could use if you can arrange for vscode to send text to the
racket input port. (This is how very early versions of racket-mode
worked.)

Also, have you seen:  ?

-- 
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] Is there a way to enter! a file from the command line?

2018-09-08 Thread Greg Hendershott
You could do

racket --repl --eval '(enter! "foo.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] What does `raco test file.rkt` do by default if no `test` submodule?

2018-09-06 Thread Greg Hendershott
> I am starting to use raco test for testing, and found out that in a file 
> without (module test ...), it may run some kind of test on the file. But for 
> some files, raco test reports that it ran a test, for others however no test 
> is run.
>
> Right now I am now adding a (module test racket/base) at the end of files I 
> have no tests for which leads to 0 tests (as it should). Nonetheless out of 
> curiosity, I am wondering why raco reports running a test for `pages.rkt`, 
> but not `tools.rkt`, even though both of them are essentially defining a 
> bunch of functions and providing them to other files, without running any 
> code.

You can also use -x with raco test: `raco test -x file.rkt`.

Relevant snip from `raco help test`:

/ --run-if-absent, -r : Require module if submodule is absent (on
by default)
\ --no-run-if-absent, -x : Require nothing if submodule is absent

I believe the default is --run-if-absent to support the traditional
approach of putting tests in dedicated files under test/ subdirs.

There are some other interesting flags to check out. You can specify
the submodule name (not just "test"). For example you could have
submodules like `slow-test` or `except-on-ci`, and your makefile or CI
script runs raco test for those submodules (or not) in various
circumstances.

-- 
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] Security of continuation web server?

2018-09-02 Thread Greg Hendershott
1. The web server FAQ has a brief section about this:

https://docs.racket-lang.org/web-server/faq.html#%28part._.What_special_considerations_are_there_for_security_with_the_.Web_.Server_%29


2. SSL is good to use in any case. Even if you believe your site
doesn't handle any sensitive user information. For example you
probably don't want third parties to inject their own content like ads
or phish bait.

-- 
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] Using match on hash tables with optional keys

2018-09-01 Thread Greg Hendershott
>(define not-found (gensym 'not-found))
>(define (not-not-found? x) (not (eq? x not-found)))
>  ...
> #'(app (lambda (h) (hash-ref h key not-found))
>(? not-not-found? value-pattern)))

Oh dang. I shouldn't not have thought of that.

Nice!

-- 
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] Using match on hash tables with optional keys

2018-08-30 Thread Greg Hendershott
A general trick for optional values with match is something like (or
pat (app (λ _ default-value) pat)). But that doesn't work for
hash-table which uses [pat path] for each mapping. (At least I
couldn't see how.)

Here's _a_ way you could write this as a match pattern:

(define ((hash-has-keys? keys) ht)
  (for/and ([key (in-list keys)])
(hash-has-key? ht key)))

(match (hash 'a 0 'b 1)
  [(? (hash-has-keys? '(a b))
  (app (λ (ht)
 (values (hash-ref ht 'a)
 (hash-ref ht 'b)
 (hash-ref ht 'c 'c-default)))
   a b c))
   (list a b c)])

[I really don't like the hash-has-keys? business, and the resulting
double lookups. But (=> id) is available only to bodies, and
`failure-cont` didn't work for me. So I don't know how else to handle
the case where it should _not_ match.]

Obviously the above is tedious. But, it works solely in term of match
patterns, and it could be the kind of syntax that a
define-match-expander emits for some nicer surface syntax. Where each
mapping is either required [k v], or, optional and you must supply a
default [k v d].  It might also be nice to have syntax like id, no
brackets, meaning the hash key is 'id and the pattern id is #'id.


How Clojure handles destructuring maps, IIRC, is to supply defaults as
`:or {k v ...}` separate from the main matching map. (I don't love
that separation).  If you don't supply a default, it does the typical
Clojure thing where a missing value isn't an error it is nil. (I also
don't love that.)

Clojure does however have the nice thing where :key is bound to a key
identifer (like that 3rd variation with no brackets I just mentioned)
to avoid repetition.

-- 
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] Where to put scribblings in 'multi package?

2018-08-29 Thread Greg Hendershott
Also there's some history, IIRC: Early on, multi collection packages
were the only kind. Even an actively maintained package might stick
with this, to continue to support older versions of Racket. Same story
for info.rkt files using #lang setup/infotab instead of #lang info.

-- 
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] Legal/Business Case Management DSLs

2018-08-25 Thread Greg Hendershott
Hi, Richard.

My initial reaction is that the full scope of what you described would
be a very ambitious project -- it would take a lot of time and people
to do and maintain over time.

Are there existing commercial or open-source software systems to run a
small to medium sized law practice? If so, I'd suggest try to find one
that's extensible and build on that. That way, you could focus on your
first section, "Documents", without needing to build everything else
up-front. Depending on how that goes, you could someday/maybe proceed
to replace the rest of the system over time.

Cheers,
Greg

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


Re: [racket-users] From Clojure to Racket

2018-08-23 Thread Greg Hendershott
Sorry -- realized I missed your last paragraph. I like other people's
suggestions so far and will try to write up more later.

On Thu, Aug 23, 2018 at 3:47 PM Greg Hendershott
 wrote:
>
> This is a bit rough and old but:
>
> https://github.com/greghendershott/racket-clojure-cheat-sheet

-- 
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] From Clojure to Racket

2018-08-23 Thread Greg Hendershott
This is a bit rough and old but:

https://github.com/greghendershott/racket-clojure-cheat-sheet

-- 
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] Converting Windows line-endings for arbitrary ports

2018-08-16 Thread Greg Hendershott
Could you use `read-line`, supplying 'any for the optional `mode` argument?

  
https://docs.racket-lang.org/reference/Byte_and_String_Input.html#(def._((quote._~23~25kernel)._read-line))


If reading in line-sized chunks would be awkward for your existing
code: I suppose you add a second pipe just to do this aspect? :)

-- 
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] Question about style

2018-08-16 Thread Greg Hendershott
Have you ever considered extending the grammar of define from this:

(define id expr)
(define (head args) body ...+)

To this:

(define id expr ... ...); <-- like e.g. `hash`
(define (head args) body ...+)

So we could write things like:

(define x 0
y 1
z 2)

Sometimes so much writing/reading of "define" feels like too low a
signal:noise ratio.

Or would this cause problems?


p.s. I guess it's a slippery slope. For instance what I'd like even
more is for `match-define` extended that way, and given a name like
`define` or `def`:

(define pat expr ... ...)

-- 
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 to show raco full (non-abbreviated) error messages

2018-08-13 Thread Greg Hendershott
p.s. You could run using errortrace. Although the lambda inferred name
is still elided, the errortrace context should still have a useful
location, which M-x next-error can find if you do it a second time. As
below:

racket -l errortrace -t
srclocasdfasdfaaa.rkt
map: argument mismatch;
 the given procedure's expected number of arguments does not match
 the given number of lists
  given procedure: ....rkt:10:7
  expected: 1
  given: 2
  errortrace...:
   
/tmp/srclocasdfasdfaaa.rkt:10:2:
(map (lambda (x) (/ x 1)) (list 1 2 3) (list 1 2 3))
  context...:
   
/tmp/srclocasdfasdfaaa.rkt:
[running body]

p.p.s. There are still ways Racket can hide paths you might find
useful for Emac's next-error -- such as replacing a long path with
"" or "". In racket-mode for Emacs, I use a custom
error-display-handler to catch such lossy transforms and "undo" them:
https://github.com/greghendershott/racket-mode/blob/master/error.rkt

Also in racket-mode, if you C-c C-c to racket-run and get an unhelpful
error context, you can C-u C-c C-c to rerun again with full errortrace
context.  (You can also set racket-error-level to 'high to run with
errortrace all the time; the gotcha is your program will run more
slowly.)


On Mon, Aug 13, 2018 at 1:25 AM Greg Hendershott
 wrote:
>
> > given procedure: ...amm-3.1/util.scm:58:6
>
> It seems you had something like `(map (lambda (x) x) (list 1 2 3)
> (list 1 2 3))` and the error message wants to show the name of the
> function.
>
> What is the name of an anonymous function?  That sounds like a Zen
> koan. But there is an automatically inferred name, using the source
> location:
>
>   https://docs.racket-lang.org/reference/syntax-model.html#(part._infernames)
>
> So `(object-name (lambda (x) x))` is something like
> `'/path/to/file.rkt:11:22`.  But it seems to be elided for
> /somewhat/long/pathname/for/file.rkt.
>
> How to avoid this? I suppose you could do (procedure-rename (lambda
> (x) x) 'shorter-name). But then you might as well just `define` a
> named function or bind the lambda to a value using `let`.

-- 
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 to show raco full (non-abbreviated) error messages

2018-08-12 Thread Greg Hendershott
> given procedure: ...amm-3.1/util.scm:58:6

It seems you had something like `(map (lambda (x) x) (list 1 2 3)
(list 1 2 3))` and the error message wants to show the name of the
function.

What is the name of an anonymous function?  That sounds like a Zen
koan. But there is an automatically inferred name, using the source
location:

  https://docs.racket-lang.org/reference/syntax-model.html#(part._infernames)

So `(object-name (lambda (x) x))` is something like
`'/path/to/file.rkt:11:22`.  But it seems to be elided for
/somewhat/long/pathname/for/file.rkt.

How to avoid this? I suppose you could do (procedure-rename (lambda
(x) x) 'shorter-name). But then you might as well just `define` a
named function or bind the lambda to a value using `let`.

-- 
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] Question about style

2018-08-12 Thread Greg Hendershott
As others said, naming intermediate values can make things clearer.
(Taken too far, maybe it's hard to see the forest for the trees? I
think it depends on the audience and the domain.)

You happened to choose an example that illustrates a reason maybe not
to do this with let* or define -- cleaning up resources like input
ports. I would write this particular thing using call/input-url.

  
https://docs.racket-lang.org/net/url.html#(def._((lib._net%2Furl..rkt)._call%2Finput-url))

For instance, I'd probably change construct-url to return a url struct
like its name suggests, then write something like:

(define (get-data input)
  (define url (construct-url input))
  (call/input-url url get-pure-port read-json))

or perhaps just:

(define (get-data input)
  (call/input-url (construct-url input)
  get-pure-port
  read-json))

This takes care of closing the port, even if read-json errors.

Also, I like the way it reads: "From this URL, connect this way, and
read this way."  So, this is another way to name pieces, taking
advantage of well-chosen names for the functions.

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


  1   2   3   >