[racket-users] pollen?

2019-08-04 Thread Hendrik Boom
On Sun, Aug 04, 2019 at 02:17:33AM -0700, Simon Schlee wrote:
> I have not completely read this thread in detail, but to me it seems like 
> it could be useful to you, to experiment with pollen and custom tags and 
> try to capture more semantic meaning with those tags.
> I think you would have an easier time creating templates that layout the 
> code exactly like you want, it might be some more work to transition but 
> you would have more control over how things are rendered.
> Have you already checked-out/considered using pollen?

I've seen a web page about it but I haven't yet looked into it seriously.
Will look again, in more detail.

I gather that it's built upon scribble.  The manual ( 
https://docs.racket-lang.org/pollen/ ) seems to be one meta-level above 
the level of the scribble tutorials I've found.  Instead of descibing 
how to put together a manuscript that can produce, say, both html and 
pdf (possibly via TeX) output it seems to describe how you could define 
notations that could to that.

Now you need that for any kind of sophisticated use (which I gather is 
what I'll be doing) but it's really nice to know what's *already* 
available to produce documents.  Have I somehow missed that in the 
documentation bundle?

Also... pollen seems to be somewhat based on scribble.
Does is share scribble's problem of not being able to nest @include-section 
within another tag, like
@italic{
  @include-section["other-file"]
}

-- 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20190805041210.zk7aonuutslxqw7m%40topoi.pooq.com.


Re: [racket-users] Alternative UI toolkits

2019-08-04 Thread Martin DeMello
Not used it myself, but there's this IUP binding:
https://chust.org/repos/scheme-iup/index

martin

On Sat, Aug 3, 2019 at 4:42 AM Stephen De Gabrielle 
wrote:

> Hi
>
> Has anyone done any work on using racket with other UI toolkits?
>
> I don’t think so but I thought it was worth asking - just in case.
>
> Stephen
> --
> 
>
> --
> 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/CAGHj7-LvuH3rjm1x7O-iwR33CfW3xuV0Yz2S7SX_eTu%2Bjr%2Ba3g%40mail.gmail.com
> 
> .
>

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


Re: [racket-users] Here are many examples for learning Racket for new folks

2019-08-04 Thread Stephen De Gabrielle
Awesome!

You should post this on https://www.reddit.com/r/Racket/ the facebook page,
twitter, etc.

s.

On Sun, Aug 4, 2019 at 11:59 PM Brian Adkins  wrote:

> Here is a github repository of many examples of Racket code including:
>
> * "Exercises for Programmers" by Brian P. Hogan
> * exercism.io
> * Project Euler
> * Puzzles e.g. n-queens, parallel n-queens, Cracker Barrel pegboard, etc.
> * etc.
>
> https://github.com/lojic/LearningRacket
>
> If you're new to Racket, and you like to learn from examples (like me),
> this may be of value to you. I'm working through SICP (sorry die-hard htdp
> fans :), so I may add a directory for those solutions also.
>
> I coded up most of these a few years or more ago, so I expect there are
> much better ways to implement them, and with a more idiomatic Racket style,
> but they should provide some nice exposure into various Rackety things.
>
> I'm happy to update them with better code, and now that I've been using
> rackunit daily, I may go back and add a bunch of tests which could be
> instructive.
>
> Brian Adkins
>
> P.S. I don't think I've posted this before, but if I have, excuse me
>
> --
> 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/2024a62b-3b90-44bc-afd2-dcd78bcc220e%40googlegroups.com
> 
> .
>

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


[racket-users] Re: DrRacket2?

2019-08-04 Thread Stephen De Gabrielle
I had a go with nextjournal but sadly there was no way to create racket 
'nextjournal runtime'.

s.


On Saturday, August 3, 2019 at 1:04:34 PM UTC+1, tbrooke wrote:
>
> I corresponded briefly with Martin Kavaler at https://nextjournal.com/  a 
> notebook platform that supports Clojure and several other languages about 
> Racket -- It s
>

-- 
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/07674e90-2a8b-41de-824f-399014b1afa7%40googlegroups.com.


[racket-users] Here are many examples for learning Racket for new folks

2019-08-04 Thread Brian Adkins
Here is a github repository of many examples of Racket code including:

* "Exercises for Programmers" by Brian P. Hogan
* exercism.io
* Project Euler
* Puzzles e.g. n-queens, parallel n-queens, Cracker Barrel pegboard, etc.
* etc.

https://github.com/lojic/LearningRacket

If you're new to Racket, and you like to learn from examples (like me), 
this may be of value to you. I'm working through SICP (sorry die-hard htdp 
fans :), so I may add a directory for those solutions also. 

I coded up most of these a few years or more ago, so I expect there are 
much better ways to implement them, and with a more idiomatic Racket style, 
but they should provide some nice exposure into various Rackety things. 

I'm happy to update them with better code, and now that I've been using 
rackunit daily, I may go back and add a bunch of tests which could be 
instructive.

Brian Adkins

P.S. I don't think I've posted this before, but if I have, excuse me

-- 
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/2024a62b-3b90-44bc-afd2-dcd78bcc220e%40googlegroups.com.


Re: [racket-users] finding the expander at run-time

2019-08-04 Thread Jon Zeppieri
On Sun, Aug 4, 2019 at 2:40 PM Jesse Alama  wrote:
> [...]
>
> In secret.rkt I've essentially got this:
>
>   (define program (parse path))
>   (parameterize ([current-namespace (make-base-empty-namespace)])
>  (namespace-require '(file "expander.rkt"))
>  (eval program))
>

I thought I knew the solution, but when I tried it, it didn't work.

I thought you needed to produce a runtime module path for the module
that you're `namespace-require`-ing:

   (define-runtime-module-path-index expander-path expander-path "expander.rkt")

... and then use that in the `namespace-require`. But when I produce
an executable and run it, I always get a "require: unknown module"
error. (Also, it wasn't clear to me if this is supposed to work unless
you also use `raco distribute`, so I tried that. Same problem.)

So I'm also stumped.

-- 
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/CAKfDxxyk7omp6AzGijv0R54ZnFPzy7MqfETNg3wZmq8yHN1uiA%40mail.gmail.com.


[racket-users] finding the expander at run-time

2019-08-04 Thread Jesse Alama
I'm working on a #lang and having some trouble with run-time paths.

Before I desparately type increasingly improbable combinations of
tenuously related thing hoping that the next invocation will be the
right one, I thought I'd write here. I've tried looking around on the
mailing list archives for help, but I can't quite find what I'm looking
for. My problem is surely not new, so I apologize if I'm inadvertantly
re-asking a question with a well-known answer. If this has already been
definitively answered here or somewhere else, I'm happy with a link to
the discussion.

For context: the users of my #lang aren't Racket programmers, don't know
of Racket, and shoulnd't have to. I'm building a command line tool. It's
made with Racket, of course, but it's essential that this tool not
require DrRacket, and should not require command line invocations like
"racket my-cool-thing.rkt filename.whatever". It should work like this:

  $ coolthing file.whatever

where coolthing is my compiled Racket program.

I get that there are ways of making executables, but I'm getting
confused about paths. Specifically, the path for my expander.

My code works as a proper #lang. That is, I can happily work with it in
DrRacket, and I get a REPL for free. That's really great. But, again,
there should be no (immediately visible) Racket dependency.

Here's what I've got:

* expander.rkt: the expander. Provides definitions according to which
  raw S-expressions get their meaning.

* info.rkt: present, but contains -- to my knowledge -- nothing
  especially relevant. (I almost omitted info.rkt from this list,
  thinking it was definitely irrelevant, but then it occurred to me that
  I may need to add some paths here.)

* grammar.rkt: Brag grammar (provides parse)

* secret.rkt: the principal program. Uses command-line, takes a filename
  as its sole argument, parses it using grammar.rkt, and is intended to
  execute the program along the lines of expander.rkt.

When I work in DrRacket, I know that a couple other files (main.rkt,
reader.rkt for read-syntax) are being used. I omitted them from this
list because (I think) they're not necessary for what I'm trying to
do. (But who knows: that may be where I'm wrong.)

In secret.rkt I've essentially got this:

  (define program (parse path))
  (parameterize ([current-namespace (make-base-empty-namespace)])
 (namespace-require '(file "expander.rkt"))
 (eval program))

This works at the command line (if I'm in the right directory) using

  racket client.rkt whatever.foo

but fails when the program is compiled using raco exe:

  open-input-file: cannot open module file
module path: /Users/jesse/secret/examples/expander.rkt
path: /Users/jesse/sources/secret/examples/expander.rkt
system error: no such file or directory; rktio_err=3

It's clear to my that this fails, and why. The expander is missing. If I
try to be more clever and replace the '(file "expander.rkt") with '(lib
...) -- so that it looks like this:

  (define program (parse path))
  (parameterize ([current-namespace (make-base-empty-namespace)])
 (namespace-require '(lib "my-package/expander"))
 (eval expanded))

then I get aother error:

  standard-module-name-resolver: collection not found
for module path: (lib "secret/expander")
collection: "secret"
in collection directories:
 /Users/jesse/secret/lib/plt/secret/collects

I've tried things like using ++lib with raco exe and ++collects-copy
with raco distribute, but I can't figure it out; I always get something
essentially equivalent to: "Can't find your expander.". I feel up
against the ropes: adding a main module to expander.rkt so that
command-line processing happens there (!). That feels pretty weird, but
maybe that would work. (Did I mention that I'm turning to increasingly
improbable ideas in my quest for a solution?) I'm sure I'm missing
something really simple here. Any ideas?

Jesse

-- 
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/334D9C06-6406-42A1-AEEF-1FDC1930A1BC%40lisp.sh.


Re: [racket-users] Name of undefined identifier as string in macro

2019-08-04 Thread Zelphir Kaltstahl
Thank you!

I am not 100% sure I understood all about the different phases, but I
seem to have semi-understood and am able to use my understanding
combined with a little trial and error.

I've now got it working as follows:

#+BEGIN_SRC racket
#lang racket

(require (for-syntax racket/string))

(define-syntax define-api-route
  (lambda (stx)
    (define (identifier-name->string id)
  (symbol->string (syntax->datum id)))

    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
  [(_ route GET my-content-type)
   (string-contains? (identifier-name->string (syntax route)) "abc")
   (syntax (quote aaa))]
  ;; an else branch basically
  [(_ route GET my-content-type) #t
   (syntax (quote bbb))])))
#+END_SRC

However, the actual code is supposed to define some procedures. This
would be quite long all in one
macro. So I want to call another procedure in the cases of syntax-case.
In this other macro, `identifier-name->string` will not be available, so
I want to give the other macro already the route as string, which will
be used to send requests to an API.

#+BEGIN_SRC racket
#lang racket

(require (for-syntax racket/string))

(define-syntax define-api-route
  (lambda (stx)
    (define (identifier-name->string id)
  (symbol->string (syntax->datum id)))

    (define (identifier->symbol id)
  (syntax->datum id))

    (define another-macro
  (lambda (route http-method my-content-type route-as-string)
    (syntax (quote bbb

    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
  [(_ route GET my-content-type)
   (string-contains? (identifier-name->string (syntax route)) "abc")
   (syntax (quote aaa))]
  ;; an else branch basically
  [(_ route GET my-content-type) #t
   (another-macro (syntax route)
  'GET
  (syntax my-content-type)
  (identifier-name->string (syntax route)))])))
#+END_SRC

This works, but I was hoping to be able to not define everything inside
one macro, but instead split it up into multiple parts. Just imagine how
big that one macro could become. For example something like:

#+BEGIN_SRC racket
#lang racket

(require (for-syntax racket/string))

(define define-simple-api-route
  (lambda (route http-method my-content-type route-as-string)
    (syntax (quote bbb

(define-syntax define-api-route
  (lambda (stx)
    (define (identifier-name->string id)
  (symbol->string (syntax->datum id)))

    (define (identifier->symbol id)
  (syntax->datum id))

    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
  [(_ route GET my-content-type)
   (string-contains? (identifier-name->string (syntax route)) "abc")
   (syntax (quote aaa))]
  ;; an else branch basically
  [(_ route GET my-content-type) #t
   (define-simple-api-route (syntax route)
    'GET
    (syntax my-content-type)

    (identifier-name->string (syntax
route)))])))
#+END_SRC

But then the procedure `define-simple-api-route` will not be defined for
use in the syntax-case.

You already mentioned the `begin-for-syntax`. However, it is Racket
specific and not available in for example Guile Scheme or other Schemes.
I guess I will have to put things in separate modules then. Or is there
any other way?



On 8/3/19 11:53 AM, Ryan Culpepper wrote:
> On 8/3/19 10:48 AM, Zelphir Kaltstahl wrote:
>> Hi!
>>
>> I am trying to write a macro, which checks the name of an argument
>> for presence a substring. This is not the main purpose of the macro,
>> but I want to do different things depending on the substring being
>> contained or not contained.
>>
>> Here is what I've got so far:
>>
>> ~
>> ;; A macro to get the identifier name as string, shamelessly copied
>> from StackOverflow and renamed:
>>
>> (define-syntax identifier-name->string
>>    (lambda (stx)
>>  (syntax-case stx ()
>>    ((_ id)
>>     (identifier? #'id)
>>     (datum->syntax #'id (symbol->string (syntax->datum #'id)))
>>
>> ;; And the actual macro I want to write:
>>
>> (define-syntax define-api-route
>>    (lambda (stx)
>>  (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE
>> PATH)
>>    [(_ route GET my-content-type)
>>     (string-contains? (identifier-name->string (syntax route))
>> "abc")
>>     (println "abc is in the identifier name")])))
>> ~
>>
>> With this, Racket will complain, that I am referencing an identifier
>> before its definition:
>>
>> ~
>>  > (define-syntax identifier-name->string
>>  (lambda (stx)
>>    (syntax-case stx ()
>>  ((_ id)
>>   (identifier? #'id)
>>   (datum->syntax #'id (symbol->string (syntax->datum #'id)))
>>  >
>>    (define-syntax define-api-route
>>  (lambda (stx)
>>    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS
>> TRACE PATH)

[racket-users] HTDP question

2019-08-04 Thread Дмитрий
Hello.

I'm reading HTDP, and not understand one data definition in the chapter 
22.3:

; An XMachine is a nested list of this shape: 
; `(machine ((initial ,FSM-State)) [List-of X1T]) 

; An X1T is a nested list of this shape: 
; `(action ((state ,FSM-State) (next ,FSM-State)))

With this definition of XMachine you can't received result like in constant 
definition xm0 above in this chapter:

(define xm0 
'(machine ((initial "red")) 
(action ((state "red") (next "green"))) 
(action ((state "green") (next "yellow"))) 
(action ((state "yellow") (next "red")


I think it will be right to define XMachine like this:

; An XMachine is a nested list of this shape: 
; `(machine ((initial ,FSM-State)) ,@[List-of X1T])


Am I wrong?



-- 
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/178d21a8-56a0-48dd-bdaf-45d37c18bee0%40googlegroups.com.


Re: [racket-users] Scribble text included out of order

2019-08-04 Thread Simon Schlee
I have not completely read this thread in detail, but to me it seems like 
it could be useful to you, to experiment with pollen and custom tags and 
try to capture more semantic meaning with those tags.
I think you would have an easier time creating templates that layout the 
code exactly like you want, it might be some more work to transition but 
you would have more control over how things are rendered.
Have you already checked-out/considered using pollen?

-- 
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/db3a50bc-573f-400a-a792-87f688f36c7f%40googlegroups.com.


Re: [racket-users] Re: Racket + Graphviz

2019-08-04 Thread Neil Van Dyke

Hadi, that looks great so far!

There are some adornments you can still add, such as to indicate which 
attributes are candidates for being keys (or are keys), but those can 
just be added to existing text strings.


One important thing still to do is labeling the relations.  You might do 
it with a name for each relation (which usually is read in one 
direction), and/or with with names for the respective role each entity 
plays in each relation.  One reason for this (just mentioning it for 
racket-users) is that, in practice, it's not-unusual to end up with 
relations for which the purpose is not obvious, and even multiple 
relations among the same pair of entities (and in the case of multiple 
relations, each expressing role cardinalities in your meta-model, which 
one is which).


Another reason for naming associations, which might be more semantics 
than you want to get into for your immediate purpose, is that there's 
richer semantics one might use in analysis, which might end up conflated 
in current implementation, *but* that can be useful to capture for 
documentation, and maybe also sometimes useful as a cognitive prompt 
while working through it.


For an old example, if you're modeling a system involving multiple 
companies and their employees, you might start with Company and Employee 
entities, and maybe label the many-to-many relation between them 
Employment.  But, when you go place a Salary attribute, you see it could 
be considered an attribute of the Employment named relationship between 
a Company and a Person (optional role names: Employer and Employee), and 
you realize that it's useful for other parts of your system to talk 
about a Person as distinct from being an Employee (e.g., for 
representing multiple employments of a person, and things about a person 
distinct from any employment). And maybe, in your analysis model, 
attributions of a relation is how it appears (if your ER meta-model 
supports that), which preserves the roles, even though, in the 
implementation, that ends up mapping to implementation the same as an 
entity does (to, e.g., a table or object class).


--
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/eb94edd2-4a8b-e5bf-967d-9a28dd53e323%40neilvandyke.org.