Re: [racket-users] Why are these @defthing blocks typeset incorrectly?

2020-09-23 Thread Philip McGrath
I have encountered this problem. I don't have a real solution, but maybe my hacky solution will be good enough. On Wed, Sep 23, 2020 at 7:37 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > I think Scribble uses source location equipped with syntax objects to > figure out spacing.

Re: [racket-users] package manager woes on Windows 10?

2020-09-10 Thread Philip McGrath
Also, this is happening over encrypted HTTPS: no one is sniffing the User-Agent header. My initial attempt to reproduce in the GUI package manager was foiled because I’d first tried installing at the command line, and the package manager used a cached copy of the repository. From Shriram’s update

Re: [racket-users] locally linked package name doesn't match info collection name

2020-09-09 Thread Philip McGrath
There was a `pkg-name` info.rkt item added in 20672cd , but it only seems to be used by `make-dirs-catalog`

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Philip McGrath
On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber < cweb...@dustycloud.org> wrote: > Unfortunately I can't use #:methods with struct/contract so I'm stuck > with the slow one if I want a contract on the struct? > For another option (though you may already know this), I'd advocate for

Re: [racket-users] abstraction suggestion?

2020-08-31 Thread Philip McGrath
tty clever! A bit painful, but clever! > > On Mon, Aug 31, 2020 at 1:32 PM Philip McGrath > wrote: > >> There might be a better way, but I'd probably make a language for writing >> this kind of module, in the spirit of `#lang syntax/module-reader`, where >> its `#%module-be

Re: [racket-users] abstraction suggestion?

2020-08-31 Thread Philip McGrath
There might be a better way, but I'd probably make a language for writing this kind of module, in the spirit of `#lang syntax/module-reader`, where its `#%module-begin` would expect the module body to be ``, similar to the way that the body of `(module reader syntax/module-reader

Re: [racket-users] lsp server

2020-08-16 Thread Philip McGrath
On Fri, Jul 31, 2020 at 2:46 PM Catonano wrote: > I'm playing with a toy project in #Racket > > I'd like to use the lsp server… > how do I connect to it from my Emacs based client ? > Just in case by "use the lsp server" you meant "set up Emacs to work on a

Re: [racket-users] Advice wanted about new opengl binding

2020-08-03 Thread Philip McGrath
Is this what you're looking for? https://pkgs.racket-lang.org/package/sgl -Philip On Sun, Aug 2, 2020 at 5:51 PM Hendrik Boom wrote: > Time to rethink everything before I go further. > > So far I've found several opengl bindings. > There's opengl, documented here: >

Re: [racket-users] pictures in code?

2020-08-03 Thread Philip McGrath
On Mon, Aug 3, 2020 at 9:47 AM Hendrik Boom wrote: > On Sun, Aug 02, 2020 at 08:58:54PM -0700, Sorawee Porncharoenwase wrote: > > For DrRacket, it's possible via "Insert > Insert Image". It's been used > in > > HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html > > Now that's presumably

Re: [racket-users] Working out which directory the current code was loaded from?

2020-07-27 Thread Philip McGrath
For this particular purpose, you want `define-runtime-path`: https://docs.racket-lang.org/reference/Filesystem.html#%28part._runtime-path%29 -Philip On Mon, Jul 27, 2020 at 9:38 PM Peter W A Wood wrote: > I have a short racket program/script that reads a file from the directory > in which it

Re: [racket-users] Are Regular Expression classes Unicode aware?

2020-07-09 Thread Philip McGrath
On Thu, Jul 9, 2020 at 10:32 AM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > Racket REPL doesn’t handle unicode well. If you try (regexp-match? > #px"^[a-zA-Z]+$" "héllo") in DrRacket, or write it as a program in a file > and run it, you will find that it does evaluate to #f. > See

Re: [racket-users] Re: Andy Wingo's fold

2020-06-25 Thread Philip McGrath
On Sun, Jun 14, 2020 at 2:20 PM Catonano wrote: > I'm referring to a paper titled: "A better XML parser through functional > programming" > > by Oleg Kiselyov > Ah, I see. I'm not deeply familiar with it myself (I mostly use Racket's `xml` library), but there is a Racket port of Oleg's SSAX,

Re: [racket-users] Re: Andy Wingo's fold

2020-06-12 Thread Philip McGrath
On Fri, Jun 12, 2020 at 2:46 AM Catonano wrote: > the original paper Andy Wingo refers to uses Haskell to express this > operator and I can't read Haskell and I'm not willing to learn > I'm confused about what you mean: in the version of "Applications of Fold to XML Transformation", on Andy

Re: [racket-users] syntax woe with typed Racket 'let'

2020-06-02 Thread Philip McGrath
On Mon, Jun 1, 2020 at 3:48 PM Sam Tobin-Hochstadt wrote: > (define (f [x : Number] . [y : String *]) : Number (+ x (length y))) > Another way to write this, which I often prefer, is: > (: f (-> Number String * Number)) > (define (f x . y) > (+ x (length y))) > -- You received this

Re: [racket-users] Re: Is it possible to make submodules with private names?

2020-05-23 Thread Philip McGrath
On Sat, May 23, 2020 at 5:04 PM Simon Schlee wrote: > I also would find it interesting to have something functor like, in the > sense of being able to create parameterized module instances. > My guess is that constructs like that are difficult to optimize and the > separation between runtime and

Re: [racket-users] trickiness about the order of definitions in GUI code

2020-05-06 Thread Philip McGrath
On Wed, May 6, 2020 at 8:49 PM Jon Zeppieri wrote: > It's a bit trickier to define these things in separate files, because > their definitions refer to each other (though indirectly in this > case), and the module system does not tolerate cyclic dependencies. > The most straightforward way to

Re: [racket-users] Matching groups of optional elements

2020-05-04 Thread Philip McGrath
Depending on your requirements, I would consider using `syntax-parse` at runtime: this is easily written with its `~seq` patterns, and you get nicer error reporting. Here's an example—I use syntax classes for clarity, but they aren't necessary, if you prefer to be more concise: #lang racket

Re: [racket-users] multiple-value version of in-value

2020-05-04 Thread Philip McGrath
Glad it was useful! There is a variant `in-value*/expression` that works like your `in-values`: https://docs.racket-lang.org/adjutor/Stable.html#(form._((lib._adjutor%2Fmain..rkt)._in-value*%2Fexpression)) -Philip On Mon, May 4, 2020 at 10:12 PM Jos Koot wrote: > To Philip McGrath, Hi ag

Re: [racket-users] multiple-value version of in-value

2020-05-04 Thread Philip McGrath
My package `adjutor` has a few variants of this, like `in-value*`: https://docs.racket-lang.org/adjutor/Stable.html#(part._.Sequence_.Constructors) They can all be used as first-class procedures, but that does involve a little runtime overhead, so they use `define-sequence-syntax` to cooperate

Re: [racket-users] Do I misunderstand set! ?

2020-04-23 Thread Philip McGrath
I think you are running into the (very confusing!) issue Ben describes here: https://groups.google.com/d/msg/racket-users/UD20HadJ9Ec/mDd4x8Y1BwAJ -Philip On Thu, Apr 23, 2020 at 5:00 PM Hendrik Boom wrote: > extract from code: > > (fprintf anomaly "resEEEulttyope was ~s~n"

Re: [racket-users] Examples of sending HTML email w/ Racket?

2020-04-09 Thread Philip McGrath
I put up an example taken from my code for Digital Ricoeur in response to an old mailing list thread . It is not ready for general-purpose use—in particular, I basically only have to deal with trusted input—but here it is:

Re: [racket-users] Scribble citations for art history dissertation (AJA style)

2020-03-19 Thread Philip McGrath
On Thu, Mar 19, 2020 at 12:40 PM Matthew Flatt wrote: > At Thu, 19 Mar 2020 12:38:39 -0400, Christopher Lemmer Webber wrote: > > I will spend the rest of the day looking at what scriblib's bibliography > > stuff does in further detail and think about how to accomplish what we > > need. It could

Re: [racket-users] Types for formlets

2020-02-24 Thread Philip McGrath
Hi Marc, You're right that there will be some challenges in using formlets in Typed Racket. The easiest approach will probably be to keep defining formlets in untyped modules and importing them with `require/typed`, perhaps with helper functions or macros to eliminate some of the boilerplate.

Re: [racket-users] Starting syntax highlighter project

2020-02-19 Thread Philip McGrath
You don't need a `#lang` to use `color:text<%>`: I've used it to do basic syntax highlighting for XML. In fact, you don't even need a GUI for the relevant part of the protocol, which is what `#lang`s implement. The requirements are described in the documentation

Re: [racket-users] cast on mutable hash table...

2020-02-15 Thread Philip McGrath
On Sat, Feb 15, 2020 at 1:23 PM 'John Clements' via users-redirect < us...@plt-scheme.org> wrote: > Yes, absolutely. One reason that students in my class wind up using cast > quite frequently in their parsers is that they use patterns like (list (? > symbol s) …) which (as I recall) expand into

Re: [racket-users] Re: How to convert String to Integer

2020-02-11 Thread Philip McGrath
On Tue, Feb 11, 2020 at 3:28 PM Alain De Vos wrote: > But first i need a list of characters. :) > Does the language has a conversion operator ? > Yes, `string->list`: https://docs.racket-lang.org/reference/strings.html#(def._((quote._~23~25kernel)._string-~3elist)) But read on … On Tue, Feb

Re: [racket-users] How to convert String to Integer

2020-02-11 Thread Philip McGrath
Others have tried to be more Socratic in pointing you this way, but here's an attempt at being more explicit. As you note, the result of `string->number` has the type `(U Complex False)`. If we try to think about about this in a version of the HtDP design recipe, we have a few cases: 1.

Re: [racket-users] [racket users] Macro literal "|"

2020-02-03 Thread Philip McGrath
You're right that `|` isn't a valid terminal with the normal reader, but, as it happens, the zero-length identifier can be written as `||`. (I don't think the concept of a zero-length identifier is common in other languages: it corresponds to the empty string.) -Philip On Mon, Feb 3, 2020 at

Re: [racket-users] Web server + authentication

2020-01-22 Thread Philip McGrath
I configure Postfix to send external mail via Amazon's "Simple Email Service," then use `net/sendmail`. Having a working mail-transfer agent means you can easily send yourself mail from other tools on the system, too, like a cron job to renew the TLS certificates. (I haven't looked at Postmark, so

Re: [racket-users] Can I somehow connect to and update values in a specific hash table used by a running web server?

2019-12-22 Thread Philip McGrath
The other advice here is good and could help to implement a more principled solution. But, if you want to do something equivalent to editing a running application's database on the fly, just using Racket values instead of a DB, I would build on `file-box`:

Re: [racket-users] Change error message of web server continuations from "Sorry, this page has expired. Please go back."

2019-12-22 Thread Philip McGrath
You can probably use `make-threshold-LRU-manager ` with a much higher memory threshold than the default from `serve/servlet`, which is about

Re: [racket-users] xml library clarification - "" symbol parsing

2019-11-22 Thread Philip McGrath
On Fri, Nov 22, 2019 at 8:50 AM Neil Van Dyke wrote: > That hypothetical parser assembling the parsed representation *could* > then concatenate sequences of 2 or more contiguous strings representing > CDATA, but that could be expensive, and might not be needed. Consider > how large some XML and

Re: [racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Philip McGrath
On Fri, Nov 8, 2019 at 5:06 PM Christopher Lemmer Webber < cweb...@dustycloud.org> wrote: > Huh... somehow I had thought that I had heard that Racket has mutable > strings by default. It cropped up on my TODO list because of that. I > wonder what gave me that impression? > Racket strings are

Re: [racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Philip McGrath
On Fri, Nov 8, 2019 at 2:58 PM Matthew Flatt wrote: > More precisely, the reader (via `read-syntax`) creates immutable > strings. > > If a macro constructs a mutable string and converts it to a syntax > object, the string is not converted to an immutable string. Maybe it > should be. > I see

Re: [racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Philip McGrath
On Fri, Nov 8, 2019 at 9:56 AM Jay McCarthy wrote: > On Fri, Nov 8, 2019 at 9:51 AM Christopher Lemmer Webber < > cweb...@dustycloud.org> wrote: > >> I have a need to do two things in a #lang: >> >> - Most importantly, make all strings that appear in the source code >>immutable >> > > Make

Re: [racket-users] eq? of quoted expressions

2019-10-25 Thread Philip McGrath
On Fri, Oct 25, 2019 at 1:27 PM wanderley.guimar...@gmail.com < wanderley.guimar...@gmail.com> wrote: > On Fri, Oct 25, 2019 at 9:28 AM Alexis King wrote: > >> Unlike eq? on symbols, eq?’s behavior on quoted lists is unspecified … >> Is there a reason you would like the answer to be #t? > > Not

Re: [racket-users] Re: Structured Concurrency in Racket

2019-10-10 Thread Philip McGrath
On Thu, Oct 10, 2019 at 2:42 AM Zelphir Kaltstahl < zelphirkaltst...@gmail.com> wrote: > … If that works for arbitrary serializable-lambda with only serializable > parts, I could continue my process pool project. > Yes, this would work for any value created by `serial-lambda`. > The only issue

Re: [racket-users] How do I typeset mixed-code for docs.racket-lang.org?

2019-10-09 Thread Philip McGrath
The way I would approach this would probably be to: 1. Create a #lang that accepts your source Markdown+Racket syntax. 2. Add a color lexer as you would for DrRacket, probably using ` syntax-color/racket-lexer

Re: [racket-users] Re: Structured Concurrency in Racket

2019-10-09 Thread Philip McGrath
On Wed, Oct 9, 2019 at 2:09 PM Zelphir Kaltstahl wrote: > I was wrongly under the impression, that serializable-lambda are supposed > to work out of the box, when sending them over channels, without needing to > do any further work ("are serialized automatically" instead of "can be >

Re: [racket-users] gen:equal+hash on hashes or other non-struct data structure

2019-10-01 Thread Philip McGrath
On Tue, Oct 1, 2019 at 10:21 PM David Storrs wrote: > For example, there's a hash, hasheqv, and hasheq. Is there a way to > have a hash with a user-provided key-comparison function? > You probably want `define-custom-hash-types` and the related functions:

Re: [racket-users] syntax-parse and iterecursion

2019-09-21 Thread Philip McGrath
I'm not sure if I understand your question; do you mean something like this? #lang racket (require syntax/parse/define) (define-syntax-parser macro-list [(_) #'null] [(_ x0 x ...) #'(cons x0 (macro-list x ...))]) (macro-list 1 2 3 4 5) -Philip On Sat, Sep 21, 2019 at 4:29 PM Hendrik

Re: [racket-users] syntax-parse ellipsis question

2019-09-21 Thread Philip McGrath
Use `~@` (sine Racket 7.0): (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+ x) ...) #'((~@ n ... x) ...)]) -Philip On Sat, Sep 21, 2019 at 4:15 PM Jonathan Simpson wrote: > Given this macro that I'm experimenting with: > > (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+

Re: [racket-users] Distributing raco command without `raco`

2019-09-15 Thread Philip McGrath
In your "info.rkt", define `racket-launcher-names` and `racket-launcher-libraries`, or `gracket-launcher-names` and `gracket-launcher-libraries` for a GUI app: https://docs.racket-lang.org/raco/setup-info.html#(idx._(gentag._14._(lib._scribblings%2Fraco%2Fraco..scrbl))) Note that this is handled

Re: [racket-users] Downloadable tutorials (e.g. on github)? Tutorial example source codes samples attached to DrRacket instalation?

2019-09-10 Thread Philip McGrath
On Tue, Sep 10, 2019 at 1:31 AM Prokop Hapala wrote: > "File > Open Require Path …" ... "/usr/share/racket/pkgs/games/" > > it is strange ... on one computer (at work) it works, on other (at home) > it does not want to open that directory (the dialog is a bit too > minimalistic so I don't know

Re: [racket-users] Simple macro issues

2019-09-10 Thread Philip McGrath
`On Tue, Sep 10, 2019 at 1:19 AM Simon Haines < simon.hai...@con-amalgamate.net> wrote: > This is a rather unpleasant pitfall of the REPL. If you try to evaluate >> the expression `(if #f some-unbound-identifier 1)`, you will see that it >> evaluates to `#f` in the REPL but raises an unbound

Re: [racket-users] Simple macro issues

2019-09-09 Thread Philip McGrath
On Mon, Sep 9, 2019 at 8:17 PM Simon Haines wrote: > What wasted a lot of time for me is that, despite the macroexpander's > results, the macro works as expected in the REPL. If you paste my original > macro into DrRacket, run it, then type '(hex a)' into the REPL you get the > expected result.

Re: [racket-users] Downloadable tutorials (e.g. on github)? Tutorial example source codes samples attached to DrRacket instalation?

2019-09-09 Thread Philip McGrath
For pedagogical examples, you may like the games that go along with the "Realm of Racket" book, which are also in the main Racket distribution. For example, try "Open Require Path …" for `realm/chapter2/source`, or here is the whole collection on GitHub: https://github.com/racket/realm On Mon,

Re: [racket-users] Simple macro issues

2019-09-09 Thread Philip McGrath
On Mon, Sep 9, 2019 at 2:42 AM Simon Haines wrote: > I'm still trying to figure out why my original, terrible macro behaved the > way it did, but I suspect I'll never know. I would have wasted a lot of > time on that awful construct. I appreciate your help, many thanks. > A great way to

Re: [racket-users] [racket users] make-keyword-procedure follow-up

2019-08-30 Thread Philip McGrath
Hi Kevin, This is interesting! A number of people have wanted conveniences around `keyword-apply` and accepting the same keywords as some other function. (The trouble is, different people have different ideas of what those conveniences should be.) To start with, I had a few small suggestions

Re: [racket-users] [racket ursers] Keyword question

2019-08-23 Thread Philip McGrath
If they do what you want, `curry` and `curryr` support keyword arguments (as of Racket 7.1) and handle lots of cases. If you do need to use `make-keyword-procedure`, you may want to combine it with `procedure-reduce-keyword-arity-mask`. -Philip On Fri, Aug 23, 2019 at 10:03 PM David Storrs

Re: [racket-users] Re: Is it possible to sell commercial use rights to an open source Racket package?

2019-08-23 Thread Philip McGrath
One issue you would encounter is that deciding what is a "commercial" use can be difficult. This comes up with Creative Commons licenses ( https://creativecommons.org/faq/#does-my-use-violate-the-noncommercial-clause-of-the-licenses ): > … there will always be uses that are challenging to

Re: [racket-users] Re: [standard-fish] Summer competiton 2019

2019-08-17 Thread Philip McGrath
This contest is a bright idea, so here's a standard lightbulb: [image: default-lightbulb.png] The code is at https://gist.github.com/LiberalArtist/4d0059f5af23043515a3cc74bd4928c2 -Philip On Wed, Aug 14, 2019 at 10:05 PM Stephen De Gabrielle < spdegabrie...@gmail.com> wrote: > Amazing face!

Re: [racket-users] web-server: how to save database results in memory across all requests?

2019-08-13 Thread Philip McGrath
The relevant chapter of the reference is "Concurrency and Parallelism" ( https://docs.racket-lang.org/reference/threads.html): > All constant-time procedures and operations provided by Racket are > thread-safe because they are atomic. For example, set! >

Re: [racket-users] Why custom-display of printable<%> interface is called twice?

2019-07-28 Thread Philip McGrath
Someone had a very similar question about `printable<%>`, including both the confusion about multiple calls and the bug of failing to use the `out` port, on Stack Overflow recently: https://stackoverflow.com/questions/55975708/racket-equivalents-of-pythons-repr-and-str/56759937#56759937 Since

Re: [racket-users] Message in the meantime?

2019-07-24 Thread Philip McGrath
On Wed, Jul 24, 2019 at 4:16 PM Matthew Butterick wrote: > Support for alternative notation in the documentation system is a missing > piece in Racket's LOP tooling: > > … primary forms like `defproc` assume that the language uses > S-expressions. > > Examples: `#lang datalog` [1] and `#lang

Re: [racket-users] Building "#lang dungeon"

2019-07-24 Thread Philip McGrath
I wonder if the unit system, or something like it, could be a basis for implementing this, especially the aspect of avoiding too much explicit argument passing. Signatures can define bundles of identifiers, like file IO primitives. This lets you avoid having to know which specific primitives are

Re: [racket-users] Re: Racket2 possibilities

2019-07-23 Thread Philip McGrath
I thought one of the most compelling parts of Matthew's proposal was at around 37:41 in the video , when he said, I've seen students in my class genuinely struggle with just the syntax. I think it would be very useful to hear more (from Matthew

Re: [racket-users] Specializing functions accepting keywords

2019-07-11 Thread Philip McGrath
The easiest way I know is to use `curry`, since Alexis fixed its keyword argument support last year: #lang racket (define (fish #:name[name #f] #:color [color #f] #:studio

Re: [racket-users] Language-Specific Plugins: Toolbar button functionality to call drracket:eval:expand-program

2019-07-01 Thread Philip McGrath
On Mon, Jul 1, 2019 at 11:40 AM Thomas Dickerson < thomas_dicker...@alumni.brown.edu> wrote: > On Fri, Jun 28, 2019 at 5:50 PM Philip McGrath > wrote: > >> Again, this part works just fine. In particular, because of the way Racket's >> submodules >> <https:/

Re: [racket-users] Language-Specific Plugins: Toolbar button functionality to call drracket:eval:expand-program

2019-06-28 Thread Philip McGrath
If you're sure you want to get the raw program source and deal with it manually, you can use the method `get-definitions-text ` on the DrRacket

Re: [racket-users] Language-Specific Plugins: Toolbar button functionality to call drracket:eval:expand-program

2019-06-25 Thread Philip McGrath
The functionality you describe—in particular, setting up clean evaluation contexts—sounds a lot like what the "Run" button already does. Unless you have some other notion of "running" in mind for programs in your DSL, I think what you describe could be accomplished nicely with a "main" submodule,

Re: [racket-users] how to uninstall Racket 5.3.6?

2019-06-21 Thread Philip McGrath
One possibility is that you might have installed Racket via apt. A command like: sudo apt list --installed | grep racket should help to see if that is the case. If so, I think uninstalling the apt package would be sufficient. -Philip On Fri, Jun 21, 2019 at 3:23 PM Norman Ramsey wrote: > I

Re: [racket-users] Re: Git-Backed Racket Packages, git archive

2019-06-13 Thread Philip McGrath
According to §2.2 Package Sources , for a Git package source in the syntax ‹scheme›://‹host›/.../‹repo›[.git][/][?path=‹path›][#‹rev›], "the package’s checksum is the hash identifying ‹rev› if ‹rev› is a branch or

Re: [racket-users] What is the difference between foo/c and foo? when creating contracts?

2019-06-05 Thread Philip McGrath
To add a bit to what Alexis said about flat contracts: On Wed, May 22, 2019 at 1:23 PM Alexis King wrote: > Your intuition is right, but let me make it more precise: foo? is used > when something is a flat contract, and foo/c is used otherwise. Flat > contracts only check *first order

Re: [racket-users] Typed Racket segmentation fault

2019-06-05 Thread Philip McGrath
On Wed, Jun 5, 2019 at 12:26 PM James Geddes wrote: > Annoyingly, my colleague had got the same speedup by using Numpy, but that > does require a change to the way one arranges the calculation (and the > change is unnatural, to my eye). > Also, that's cheating! Numpy is mostly written in C,

Re: [racket-users] Typed Racket segmentation fault

2019-06-05 Thread Philip McGrath
ar`, then the program also works correctly. > > The program also works correctly with the JIT off, and under RacketCS. > > https://gist.github.com/samth/683042c4754c1c5ce284794b19dd37e3 > > > > On Wed, Jun 5, 2019 at 11:02 AM 'Paulo Matos' via Racket Users > > wrote:

Re: [racket-users] Typed Racket segmentation fault

2019-06-05 Thread Philip McGrath
What version of Racket are you using? I get a segfault in 7.2, but 7.3 works for me. -Philip On Wed, Jun 5, 2019 at 10:42 AM James Geddes wrote: > Dear All, > > The following Typed Racket program is intended to produce an image of the > Mandelbrot set (but it doesn't bother actually displaying

[racket-users] Reading comments

2019-04-28 Thread Philip McGrath
Is there a way to interpose on reading `#;`, `#|...|#`, and `#!` comments with the standard e-expression reader? I can override the handling of normal `;` line comments by adding a terminating macro to the reader, but adding dispatch macros for the others doesn't seem to work (see below). I

Re: [racket-users] Re: How to install local dir package replacing pre-installed one

2019-04-05 Thread Philip McGrath
>From the output you showed, you seem to have only replaced the "rackunit" package, which is just a stub to depend on the "rackunit-lib", "rackunit-doc", "rackunit-gui," and "rackunit-plugin-lib", packages—those you still have installed in the installation default place. It also looks like you

[racket-users] Example "RealWorld" web application

2019-03-27 Thread Philip McGrath
The RealWorld project defines a simple but realistic client–server web application (a Medium-like blogging platform) for different front- and back-end frameworks to implement as an extended tutorial example. The API is standardized, so different front- and back-ends can be

Re: [racket-users] Does Racket have a sexp-syntax regular expressions?

2019-03-27 Thread Philip McGrath
You'll want to look at `parser-tools/lex-sre`: https://docs.racket-lang.org/parser-tools/Lexers.html#(mod-path._parser-tools%2Flex-sre) -Philip On Wed, Mar 27, 2019 at 8:45 AM zeRusski wrote: > No wait. I meant SRE-like to match strings, not TRX to match trees. Messed > up there, sorry > > --

Re: [racket-users] Error handling for the GUI

2019-03-26 Thread Philip McGrath
As Ben pointed out, if the exception is a `real exn:fail:contract:blame`, you don't even need to parse the message string: #lang racket (define/contract (wants-exact x) (-> exact? exact?) x) (define/contract (wants-inexact x) (-> inexact? inexact?) x) (define (show-which-was-violated

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

2019-03-18 Thread Philip McGrath
On Mon, Mar 18, 2019 at 9:14 AM Matthew Flatt wrote: > I wonder whether the solution is an extension of `scribble/lp2` to > support a `require-for-chunk` form where `chunk` records any such > imports in its context and adds then to the stitched-together program. > > (require-for-chunk (only-in

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

2019-03-18 Thread Philip McGrath
I don't use `include-template` (I've come to love x-expressions), but I believe this would work: @,(if #true @`{ This will be displayed if true } @`{ This will be displayed if false }) -Philip On Mon, Mar 18, 2019 at 11:48 AM Jérôme Martin wrote: > > On Monday, March 18, 2019

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

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

Re: [racket-users] How to launch image display from racket REPL?

2019-03-16 Thread Philip McGrath
Here's one way: Welcome to Racket v7.2. > (require 2htdp/image racket/gui/base (only-in pict show-pict)) > (show-pict (empty-scene 100 100)) (The require of racket/gui/base seems to be needed for side-effect only, to prevent a "racket/gui/base is not available" error. That seems like it might be

Re: [racket-users] define fails at runtime, where let fails at compile time

2019-03-11 Thread Philip McGrath
I think it's fair to say that the Racket style guide is not as rigid as some other style guides for some other languages: as it says itself in the introduction, it "isn’t complete and it isn’t perfect" and is more a set of "guidelines and best practices" than binding universal rules. I think it is

Re: [racket-users] how to use union types

2019-02-25 Thread Philip McGrath
An alternative to figuring out how to satisfy the type checker is to use `cast`, e.g.: #lang typed/racket (require typed/json) (string-join (cast (string->jsexpr "[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]") (Listof String))) Obviously this has pros and cons, the main pro being that it

Re: [racket-users] Use cases for tables and records

2019-02-22 Thread Philip McGrath
On Fri, Feb 22, 2019 at 8:14 AM Matt Jadud wrote: > However, I'm happy to push to Github as well as Bitbucket (which > apparently does not play well with the package distribution system?), so > that it can be poked at by others. > On Fri, Feb 22, 2019 at 8:47 AM Sam Tobin-Hochstadt wrote: >

Re: [racket-users] test user-interact function dont work

2019-02-17 Thread Philip McGrath
Well, if you call `(exit 0)`, your Racket program really will exit with code 0 without doing anything else: the function `exit` never returns, so, in your case, `execute` never returns, `refine-main` never returns, and Rackunit never gets a chance to look at any output it may or may not have

Re: [racket-users] Running raco setup from within DrRacket?

2019-02-17 Thread Philip McGrath
I've written and use a `find-executable-path*` inspired by Emacs' `exec-path-from-shell` (which I'm pretty sure I learned about from Greg on this list) that gives the same API as `find-executable-path`, but with a special case for Mac OS:

Re: [racket-users] Re: Loading foreign libraries on Windows

2019-02-12 Thread Philip McGrath
lly comes up > when a 32 bit application tries to load a 64 bit DLL. > > Alex. > > On Tuesday, February 12, 2019 at 2:18:55 PM UTC+8, Philip McGrath wrote: >> >> I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The >> problem appears to be specific to

[racket-users] Loading foreign libraries on Windows

2019-02-11 Thread Philip McGrath
I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The problem appears to be specific to Racket, as I seem to be able to load the same DLL from Python. Specifically, I'm trying to build platform-specific packages for libgit2. I can build the library and run its test suite

Re: [racket-users] Wishlist for regexen: x mode, named captures, embeddable regexn

2019-02-11 Thread Philip McGrath
On Mon, Feb 11, 2019 at 2:32 PM David Storrs wrote: > It would be great if Perl's / pcre's "x" mode could be pulled into > Racket, ideally with modifiers on the end of the regexp instead of > inside it. This mode specifies that all whitespace in the pattern > should be ignored, so if you want

Re: [racket-users] raco distribute creating too many subdirectories

2019-02-10 Thread Philip McGrath
I think this is probably a consequence of the quirk of `define-runtime-path` with directories that I reported at: https://github.com/racket/racket/issues/2336 I'm still not clear on whether the current behavior is intended and, if so, how one ought to do this sort of thing to work robustly with

Re: [racket-users] Re: nested for loops and suggested alternatives

2019-02-10 Thread Philip McGrath
You may also want to look into the math/array and math/matrix libraries. -Philip On Sun, Feb 10, 2019 at 3:42 AM Alex Harsanyi wrote: > This line looks suspicious: > > (define results

[racket-users] Pitfall for contracts with serializable structs

2019-02-05 Thread Philip McGrath
I was (relatively) recently bitten by an issue with putting contracts on serializable structs. What's worse, once I figured out what was going on, I realized that I'd run into this very issue before and even discussed it on this list

Re: [racket-users] Why would a value produced by eval-ing code not satisfy its type predicate? (Particularly, a SQL statement from the sql package)

2019-02-04 Thread Philip McGrath
On Sat, Feb 2, 2019 at 11:34 PM hashim muqtadir wrote: > > As long as you at least know the schema you're working with, you could > even generate select statements for all possible sets of columns at compile > time, and then just choose the right statement dynamically with a runtime > function.

Re: [racket-users] Real-world examples of XML usage?

2019-02-04 Thread Philip McGrath
On Mon, Feb 4, 2019 at 3:22 PM Neil Van Dyke wrote: > BTW, you *could* also do both XML and JSON. For example: for some Web > services, coming from a very complicated data model, IIRC, the > engineering process scenario was something like originally the > requirement was for XML, and then JSON

Re: [racket-users] Python's append vs Racket's append and helping novices understand the implications

2019-02-02 Thread Philip McGrath
I am certain people coming from Python are confused by this, since I was bitten by this very difference when I had to write some Python for the first time in a while. (What do you mean append has side-effects?!?) -Philip On Sat, Feb 2, 2019 at 10:30 AM Robby Findler wrote: > On Sat, Feb 2,

Re: [racket-users] Why would a value produced by eval-ing code not satisfy its type predicate? (Particularly, a SQL statement from the sql package)

2019-02-01 Thread Philip McGrath
On the original question: Racket's struct types are generative (except for #:prefab structs), meaning that each time you evaluate a `struct` form (or, at a lower level, each time you call `make-struct-type`), the you create a fresh type distinct from all other types. That can be a bit confusing to

Re: [racket-users] sxml vs xexpr frustrations

2019-02-01 Thread Philip McGrath
I've written a fair amount of XML processing code in Racket (sometimes one has to work with external standards and tools), and I thought I'd jump in to say that I've been content with xexpr. I don't mean that as a criticism of sxml, though: I happened to have learned xexpr first, and I've never

Re: [racket-users] Spritely awarded Samsung Stack Zero grant

2019-02-01 Thread Philip McGrath
Congratulations! This would be great news in any case, and it's even more exciting to know that you're doing it in Racket. -Philip On Thu, Jan 31, 2019 at 10:47 PM 'John Clements' via Racket Users < racket-users@googlegroups.com> wrote: > Truly excellent news! Can’t wait to hear about it at

Re: [racket-users] Multipart HTTP requests

2019-01-29 Thread Philip McGrath
I've put up the code I mentioned for email-sending and a proxy server at https://github.com/LiberalArtist/multipart-writing-examples As noted, these are not general-purpose solutions to either of those problems—I know of a bunch of cases I don't cover, and I basically only have to use these with

Re: [racket-users] Multipart HTTP requests

2019-01-29 Thread Philip McGrath
I don't think there's a multipart-writing library yet, and it would be a great thing to have. I've written little multipart-writing functions for a small proxy server built on `http-sendrecv/url` and for sending email using `net/sendmail` with html and text/plain alternatives. I'm happy to share

Re: [racket-users] web cells expiring unexpectedly quickly

2019-01-11 Thread Philip McGrath
On Thu, Jan 10, 2019 at 1:09 AM Jesse Alama wrote: > Playing around with stateless servlets, I find my web cells expiring > unexpectedly quickly. > I'm guessing you meant *stateful* servlets? Stateless web cells shouldn't expire. I will need to think about the rest more closely. -Philip --

Re: [racket-users] Functional augmenting

2019-01-04 Thread Philip McGrath
I can't think of "something similar in functional Racket" (of course you can write purely functional programs with racket/class, but I know what you mean). I think it would be fairly easy to implement "something similar," but I want to clarify what you have in mind, because augmentable methods

Re: [racket-users] hackernews

2018-12-29 Thread Philip McGrath
On Sat, Dec 29, 2018 at 1:48 PM Tomasz Rola wrote: > Where does Racket belong? I understand Racket community no longer > considers themselves as part of Scheme landscape, but I am unable to > say where I get this impression from. If I am wrong, then the first > thing for anybody willing to

Re: [racket-users] Re: hackernews

2018-12-29 Thread Philip McGrath
On Sat, Dec 29, 2018 at 10:31 AM BD1 a wrote: > I may be out of place here as I am a total beginner to programing. > I think hearing from an absolute newcomer is very useful: ignorance is a non-renewable resource! Respectfully, I would also concentrate on Rackets web presence. If I was > to

Re: [racket-users] Reasons not to use match or define/match?

2018-12-19 Thread Philip McGrath
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

  1   2   3   4   >