Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Matt Jadud
Hi Brian,

In some ways, you did get a very good answer to your first question. You
were able to see the properties of a *syntax object*. But syntax objects
were, I think, only part of the picture you were looking for.

The questions "what does the *struct* form in Racket do, what bindings does
it introduce into the namespace, at what point in the macro-expansion tower
do those things happen, and how can I understand the mechanisms that are at
work in that expansion?" are... different questions, as you discovered.

If you're keen to understand the Racket macro system (not knowing your
background; apologies if this is all old news):

* Matthew B's *Beautiful Racket* has a nice section on Macros:
https://beautifulracket.com/explainer/macros.html
* Flatt's *Let's Build a Hygenic Macro Expander *will provide a conceptual
foundation that aligns with Racket's macro expander:
https://www.youtube.com/watch?v=Or_yKiI3Ha4
* Hendershott's *Fear of Macros *has an intimidating cat, and dives deeper
into the Racket tools of macro construction:
https://www.greghendershott.com/fear-of-macros/
* Clinger and Wand's *Hygenic Macro Technology* is a brief (100p) walk
through the history of macro expansion systems in the Scheme world:
https://dl.acm.org/doi/pdf/10.1145/3386330

These materials (in particular, Matthew's talk) might help give a sense for
what is involved in pulling back the curtain on a macro expansion, and the
kind of implementation details that are going on under the hood.

I would say that studying the code for *struct-plus-plus* could also be
informative, as it would provide a way to see how a struct system that
provides the kind of visibility you were looking for achieves that
visibility, and how it interacts with the macro expansion tower.

Cheers,
Matt


On Sun, Oct 31, 2021 at 11:52 AM Brian Beckman  wrote:

> Hi, Matt ... I'll try your ideas in a little while.
>
> Regarding "why," I want the ability, from a module or a REPL, to quickly
> dump the attributes of an instance without having to look things up. The
> need arose when I was barnstorming and trying to explain syntax objects to
> someone, and he asked "what are the attributes of a syntax object?" I
> replied, "let's just dump one out," and that turned out impossible. So we
> did an F1 lookup of the doc and were confronted with the general
> meta-syntactic definition
> file:///usr/share/doc/racket/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._syntax%29%29.
> Well, we weren't going to finish understanding that in the one-hour lunch
> meeting we had.
>
> Bottom line, I was unable to give a quick answer to a reasonable question.
>
> On Sunday, October 31, 2021 at 3:42:19 AM UTC-7 Matt Jadud wrote:
>
>> Hi Brian,
>>
>> Does this help move you forward?
>>
>> It has been a while since I've stared at macros in Racket, so this might
>> be easier...
>>
>> Also, make sure you're executing this code in a module. If you're working
>> in a REPL, I suspect all bets are off. It is certainly the case that you
>> could combine several of my exploration steps into a simpler/cleaner macro,
>> instead of generating lists of symbols, converting them back to syntax
>> objects, and so on.
>>
>> Also, as a solution/exploration, I... don't know how this would interact
>> with the full range of possible structs. Someone who knows more about
>> syntax and structs should be able to speak to how you'd find out all of the
>> defined functions that spawn from struct definition/creation. (It might
>> also be useful to know *why* you want to destructure structs this way?
>> Knowing that may illuminate some other path forward.)
>>
>> #lang racket
>> (require racket/struct-info)
>>
>> (struct A (b c))
>>
>> (struct B (e f) #:transparent)
>>
>> (require (for-syntax racket/struct-info))
>> (define-syntax (get-field-names stx)
>>   (syntax-case stx ()
>> [(_ sym)
>>  #`(quote
>> #,(struct-field-info-list
>>(syntax-local-value #'sym)))
>>   ]))
>>
>> ;; These let me see the field names
>> (get-field-names A)
>> ;; Returns '(c b)
>> (get-field-names B)
>> ;; Returns '(f e)
>>
>> ;;
>> https://stackoverflow.com/questions/20076868/how-to-know-whether-a-racket-variable-is-defined-or-not
>> (define-syntax (defined? stx)
>>   (syntax-case stx ()
>> [(_ id)
>>  (with-syntax ([v (identifier-binding #'id)])
>>#''v)]))
>>
>> (define-syntax (proc-names stx)
>>   (syntax-case stx ()
>> [(_ sym)
>>  (let ([names (map (λ (s)
>>  (

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Matt Jadud
Hi Brian,

Does this help move you forward?

It has been a while since I've stared at macros in Racket, so this might be
easier...

Also, make sure you're executing this code in a module. If you're working
in a REPL, I suspect all bets are off. It is certainly the case that you
could combine several of my exploration steps into a simpler/cleaner macro,
instead of generating lists of symbols, converting them back to syntax
objects, and so on.

Also, as a solution/exploration, I... don't know how this would interact
with the full range of possible structs. Someone who knows more about
syntax and structs should be able to speak to how you'd find out all of the
defined functions that spawn from struct definition/creation. (It might
also be useful to know *why* you want to destructure structs this way?
Knowing that may illuminate some other path forward.)

#lang racket
(require racket/struct-info)

(struct A (b c))

(struct B (e f) #:transparent)

(require (for-syntax racket/struct-info))
(define-syntax (get-field-names stx)
  (syntax-case stx ()
[(_ sym)
 #`(quote
#,(struct-field-info-list
   (syntax-local-value #'sym)))
  ]))

;; These let me see the field names
(get-field-names A)
;; Returns '(c b)
(get-field-names B)
;; Returns '(f e)

;;
https://stackoverflow.com/questions/20076868/how-to-know-whether-a-racket-variable-is-defined-or-not
(define-syntax (defined? stx)
  (syntax-case stx ()
[(_ id)
 (with-syntax ([v (identifier-binding #'id)])
   #''v)]))

(define-syntax (proc-names stx)
  (syntax-case stx ()
[(_ sym)
 (let ([names (map (λ (s)
 (string->symbol
  (format "~a-~a" (syntax-e #'sym) s)))
   (struct-field-info-list
(syntax-local-value #'sym))
   )])
   #`(quote #,names))]))

;; This...
(proc-names A)
;; Returns '(A-c A-b)

(define-syntax (names-exist? stx)
  (syntax-case stx ()
[(_ sym)
 (let ([names (map (λ (s)
 (string->symbol
  (format "~a-~a" (syntax-e #'sym) s)))
   (struct-field-info-list
(syntax-local-value #'sym))
   )])
   #`(andmap (λ (s)
   (equal? 'lexical s))
 (map (λ (s)
(defined? s))
  (quote #,names)))
   )]))

(names-exist? A)
(names-exist? B)


On Sat, Oct 30, 2021 at 10:33 PM Brian Beckman  wrote:

> Here are some of my latest (failed) experiments:
>
> #lang racket
>
> (require (for-syntax racket/struct-info))
> (require racket/pretty)
>
> (struct foo (a b) #:transparent)
>
> (displayln `("a foo object is transparent: I can see inside: \n
> (struct->vector (foo 1 2)) ~~> "
>  ,(struct->vector (foo 1 2
>
> (displayln `("syntax object is opaque I can't see inside: \n
> (struct->vector #'foo) ~~> "
>  ,(struct->vector #'foo)))
>
> ;;; Why do two copies of the syntax display? (One copy
> ;;; is a side-effect. The other is a result).
>
> ;;; At expansion time, I can get some graphics in Dr-Racket for
> ;;; definition of foo, but I cannot get likewise
> ;;; not into the definition of syntax.
> (begin-for-syntax
>   (displayln
>(extract-struct-info
> (syntax-local-value
>  #'foo  ; #'syntax
>
> ;;; But the access procedures for #'syntax are known!?!? (I just
> ;;; happen to know that there is a procedure named 'syntax-position';
> ;;; my whole issue is in trying to find out the list of all
> ;;; procedures defined in the system when the syntax type is created!)
>
> (syntax-position #'42)
>
> ;;; Whereas #'foo is known in this module scope,
> ;;; (syntax struct:foo) is not known! Looks like the shorthand
> ;;; #'whatever for making a syntax object is known, but the longhand,
> ;;; presumably (syntax 'whatever), is not known.
>
> (begin-for-syntax
>   (displayln
>(extract-struct-info
> (syntax-local-value
>  #'syntax
>
> 
>
> Welcome to DrRacket, version 8.2 [cs].
> Language: racket, with debugging; memory limit: 128 MB.
> (.# struct:foo>
> .# foo>
> .# foo?>
> (.# foo-b>
> .# foo-a>) (#f #f) #t)
> . .
> ../../../../../../usr/share/racket/pkgs/errortrace-lib/errortrace/stacktrace.rkt:690:2:
> extract-struct-info: contract violation
>   expected: struct-info?
>   given: #
> >
>
> On Friday, October 29, 2021 at 4:10:37 PM UTC-7 Siddhartha Kasivajhula
> wrote:
>
>> I was able to find this interface
>> ,
>> but it doesn't quite provide the same information. E.g. (struct-type-info
>> struct:foo)
>>
>> The ability to "introspect" values in a shell (or in the application) is
>> useful in languages like python (e.g. dir(object) tells you what methods
>> it provides, help(anything) gives you the interface/function signature,
>> docstrings, 

Re: [racket-users] Racket and Assembly

2020-12-30 Thread Matt Jadud
Hi Daniel,

As a start to answering your question(s), you might try the 2019 ICFP
experience report on rebuilding Racket on top of Chez Scheme is probably a
good place to look.

https://www.cs.utah.edu/plt/publications/icfp19-fddkmstz.pdf

This will give you an overview of the architecture of the language/runtime,
and should serve as a starting point for additional questions.

Cheers,
Matt


On Wed, Dec 30, 2020 at 2:10 PM Daniel Santos 
wrote:

> Hi.
>
> I really want to know is if Racket compiles code directly into assembly?
> Or does it do: Racket -> C -> Assembly ? Or something else ?
>
> Thank 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAL6VdkStOUmBoWb%3DD3cgVpGnDaZ2mHKoPHbzy4U8Yjq%2BkxTVwg%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/CAAGM457ige6J-EsnSSHF7Fuv3Vc9DxF%3DK9jdqP23%3DWyDkgZ5Yg%40mail.gmail.com.


Re: [racket-users] compiler books

2020-11-27 Thread Matt Jadud
On Fri, Nov 27, 2020 at 12:40 PM Hendrik Boom 
wrote:

> On Wed, Nov 25, 2020 at 09:46:21AM -0600, Tim Meehan wrote:
> I found a book by Dick Grune et al to be somewhat lighter than the dragon
> book.  Looking online, I discoered I was thinking of the first edition.  I
> haven't seen the second edition, but I'd guess the second edition would be
> similar, though it has rather more material:
>
> https://dickgrune.com/Books/MCD_1st_Edition/
> https://dickgrune.com/Books/MCD_2nd_Edition/
>
> When I saw the first edition, I decided that if I were teaching an
> introductory course in compilers, I would use it as textbook.
>
>
I've been fond of

https://www.nand2tetris.org/

for a while as a "soup to nuts" overview of computation from the NAND gate
up through a simple computer, a simplified assembly language, assembler,
compiler, VM, and so on. It's not an advanced text, but it does provide a
hands-on bottom-to-top view of the computational world that can help orient
someone who is exploring the space.

It's also why I keep wondering when I'm going to break down and pick up a
little FPGA board for myself and just play. :)

Cheers,
Matt

-- 
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/CAAGM454t_FNXj8RHTbLuC1pe-14i-rF%3DyQ_B%2BmSvoE4DGUyMAw%40mail.gmail.com.


Re: [racket-users] New to racket, help with coursework question

2020-04-19 Thread Matt Jadud
This is good. Your questions are good, and while the frustration/confusion
is real, don't let it get you down. It's just part of the process. (That
is, learning often involves confusion and frustration.)

This might step it back too far, but see if this helps a bit. Your question
about what you can put in the definition suggests that you're in a good
place, but you've got a lot of ideas swimming around all at once. Let's try
this.

A function definition has a pattern to it.

(define (__A__ __B__)
  __C__)

When you look at a definition, you want to look for that pattern. Use
DrRacket's highlighting to help you see the pieces if you need to. I find
it handy all the time.

"A" is the name of the thing you are defining, "B" is a parameter, and "C"
is the body. There can, of course, be multiple parameters. Then, the
pattern looks like:

(define (__A__ __B1__ __B2__)
  __C__)

assuming you have a function definition with two parameters.

Making it a bit more concrete, you could have a function like this:

;; CONTRACT
;; number -> number
(define (add-one n)
  (+ n 1))

which, if you paste that into the "Interactions" area in DrRacket, and hit
return, you will define the function. If you then type:

(add-one 3)

you will see that it evaluates to 4. That is because the value of '3' is
bound to the parameter 'n', and then the body is evaluated (or "run") with
n having the value 3. When you add one to three, you get four. Or, (+ 1 3)
evaluates to 4.

In the second pattern, you might have:

;; CONTRACT
;; number number -> number
(define (add-nums a b)
  (+ a b))

and then you could invoke or use that function as:

(add-nums 3 5)

Here, the value '3' is bound to 'a', 5 is bound to 'b', and then 'a' and
'b' are summed, giving you 8.

Coming back around to your question, you're wondering "but where do I put
the vector-ref?" Hopefully, along with the excellent questions you've been
asked so far, the great answers that have been provided, and my potentially
confusing message here, you're starting to think "perhaps I don't put the
vector-ref in the parameters..."

The contract for 'number-of-days-in-month' was given to you as

number number -> number

which means that 'number-of-days-in-month' takes two parameters. You need
to give each of those parameters names. Or, in a pattern:

;; CONTRACT
;; number number -> number
(define (number-of-days-in-month __B1__ __B2__)
 __C__)

You need to give names to the two parameters (which you know what they have
to be... and you've already said what those two parameters are, so naming
them is something I suspect you can do). Then, you need to *do stuff* in
__C__. Or, as John suggested, this is where you do the calculation that
needs to be done... if you can write it out, you're a long way along to
filling in __C__. When you're writing the body of the function (or __C__ in
my pattern), I suspect you're going to need to use those two
parameters---which represent a year and month---to do your calculation.

Then, you would run that function this way:

(number-days-in-month 2016 1)

(which I just copy-pasted from your first email) and 2016 would be bound to
the first parameter (whatever you called it), and 1 would be bound to the
second. It would then run the body of the function, and the parameters
would be bound to the values 2016 and 1.

That may, or may not, have helped. But hopefully it helps you step back
from the code, which may be looking like a whole bunch of symbols right
now, and encourage you to look for the patterns that are there, and what
the parts of the patterns mean.

Keep asking questions,
Matt





On Sun, Apr 19, 2020 at 4:21 PM Suz Renae  wrote:

> The months vector is representing each month and how many days are in that
> month.
> (define months (vector 0 31 28 31 30 31 30 31 31 30 31 30 31))
> 31 would be 1 or January (since all indexes start at 0, there is no 0th
> month), 28 would be 2 or February, and so forth and so on. So if we did
> (vector-ref months 1) -> 31
>
> I know how to read code, but writing it is my problem. This is my first
> coding class. So I don't know if I can write a parameter in the definition
> using vector-reflike
> (define (number-days-in-month year (vector-ref months x)
>  (cond
>   [if (= y leap-year?
>  29
>  28
>
> Or even with that above, how would it know that leap-year? only effects
> month 2. I am highly confused unfortunately.
>
> On Sunday, April 19, 2020 at 12:59:48 PM UTC-7, johnbclements wrote:
>>
>> First off: you’re very close.
>>
>> Thing two: I think you need a clearer comment on the meaning of the
>> “months” vector. Your description does not actually say what the vector
>> represents or contains.
>>
>> Thing three: Here’s my question to you. Suppose that I tell you a year
>> and a month and the result of (vector-ref months x).
>>
>> To be more concrete, suppose I tell you the year is 2234 and the month is
>> 4 and the result of (vector-ref months x) is 30. How many days would 

Re: [racket-users] Understanding P. Ragde's Proust

2020-03-15 Thread Matt Jadud
Hi Adrian,

I commented on the gist with a "new" version.

As far as I can tell, the type-check function only handles one structural
case: Lam. As a result, if you try and run a lone TA structure through it,
the code will fail. (See my comments in the code.)

The type-infer function handles more structural cases (e.g. Lam, TA, App).
Again, not having read the article, I don't know if it makes sense for this
tooling to be able to parse and do anything with a lone annotation.

In short, given the code as-is, this works:

(check-proof
 `((lambda x => x) : (A -> A)))

this does not:

(check-proof `((x : A) : A))

Hope that helps,
Matt



On Sun, Mar 15, 2020 at 10:21 AM Adrian Manea 
wrote:

> Hi Matt,
>
> Thank you very much for the details! What you're saying makes sense and is
> in accordance with my intuition. But the code doesn't work as it is.
>
> I created a Gist for it here:
>
> https://gist.github.com/adimanea/7aa7921c913e70fb9a8b1524b5bd2d3c
>
> Everything is from the article, except for the (struct TA (type var))
> which I created instead of the Ann ("type annotation") and the examples I
> used for tests.
>
> Regards,
> Adrian
>
> On Sunday, March 15, 2020 at 2:10:55 PM UTC, Matt Jadud wrote:
>>
>> Hi Adrian,
>>
>> The article seems to be missing a type definition for Ann.
>>
>> Perhaps some of this you already know...
>>
>> (match expr ...)
>>
>> is a pattern matcher, working to find a pattern that 'expr' fits.
>>
>> [(Lam _ _) ...]
>>
>> is attempting to match a pattern where a 'expr' is a struct called Lam,
>> and that structure has two fields. In this case, the value of those fields
>> is ignored, so the variable '_' is used to (by convention, not by syntax)
>> tell the programmer that these values do not matter. (At least, I'm
>> reasonably confident this is by convention and not by syntax.)
>>
>> The form
>>
>> [(Ann e t) ...] is matching the structure 'Ann', and binding the value in
>> the first field to the identifier 'e', and the second value to 't'. Then,
>> the expression following is executed (assuming the pattern matched).
>>
>> In the article, there is no struct definition for 'Ann'. I suspect it is
>> a typo/oversight. This would work:
>>
>> (struct Ann (e t))
>>
>> would be a reasonable definition. It says "Ann" is a data structure with
>> two fields, called "e" and "t".
>>
>> I haven't read the article, so "better" names for those fields is not
>> something I am going to come up with right now. The name in the definition
>> matters (to you, the programmer), but the identifier used to bind in the
>> pattern is not critical. (Or, it is again something that should be
>> important to you, but it does not need to match the names of the fields in
>> the struct definition.)
>>
>> Hopefully that helps, and helps you move forward a bit. Ask more
>> questions if that didn't help. And, perhaps putting your code as-is in a
>> Github Gist or similar, so that others can look at exactly what you're
>> working with would be useful.
>>
>> (I have no idea how complete or incomplete the code in the article is,
>> which is why I suggest you put it in a pastebin/gist to share... there
>> might be other things that were glossed in the article? I don't know.)
>>
>> Cheers,
>> Matt
>>
>>
>> On Sun, Mar 15, 2020 at 10:01 AM Adrian Manea 
>> wrote:
>>
>>> Hi all,
>>>
>>> I'm a mathematician delving into type theory and proof assistants and
>>> with special interests in Racket.
>>>
>>> I'm now trying to understand and implement P. Ragde's Proust
>>> <https://arxiv.org/abs/1611.09473> "nano proof assistant" and work
>>> through the examples in his article. However, I'm pretty much a beginner in
>>> Racket and I'm getting some errors. Particularly in the type-infer
>>> function, that's also used in the type-check function.
>>>
>>> Here is the code in the article:
>>>
>>> (define (type-check ctx expr type)
>>>   (match expr
>>> [(Lam x t)   ; lambda expression
>>> (match type
>>>[(Arrow tt tw) (type-check (cons `(,x ,tt) ctx) t tw)] ;
>>> arrow type
>>>[else (cannot-check ctx expr type)])]
>>> [else (if (equal? (type-infer ctx expr) type) true (cannot-check ctx
>>> expr type))]))
>>>
>>> (define (type-infer ctx expr)
>>>   (match expr
>>> [(Lam _ _

Re: [racket-users] Understanding P. Ragde's Proust

2020-03-15 Thread Matt Jadud
Hi Adrian,

The article seems to be missing a type definition for Ann.

Perhaps some of this you already know...

(match expr ...)

is a pattern matcher, working to find a pattern that 'expr' fits.

[(Lam _ _) ...]

is attempting to match a pattern where a 'expr' is a struct called Lam, and
that structure has two fields. In this case, the value of those fields is
ignored, so the variable '_' is used to (by convention, not by syntax) tell
the programmer that these values do not matter. (At least, I'm reasonably
confident this is by convention and not by syntax.)

The form

[(Ann e t) ...] is matching the structure 'Ann', and binding the value in
the first field to the identifier 'e', and the second value to 't'. Then,
the expression following is executed (assuming the pattern matched).

In the article, there is no struct definition for 'Ann'. I suspect it is a
typo/oversight. This would work:

(struct Ann (e t))

would be a reasonable definition. It says "Ann" is a data structure with
two fields, called "e" and "t".

I haven't read the article, so "better" names for those fields is not
something I am going to come up with right now. The name in the definition
matters (to you, the programmer), but the identifier used to bind in the
pattern is not critical. (Or, it is again something that should be
important to you, but it does not need to match the names of the fields in
the struct definition.)

Hopefully that helps, and helps you move forward a bit. Ask more questions
if that didn't help. And, perhaps putting your code as-is in a Github Gist
or similar, so that others can look at exactly what you're working with
would be useful.

(I have no idea how complete or incomplete the code in the article is,
which is why I suggest you put it in a pastebin/gist to share... there
might be other things that were glossed in the article? I don't know.)

Cheers,
Matt


On Sun, Mar 15, 2020 at 10:01 AM Adrian Manea 
wrote:

> Hi all,
>
> I'm a mathematician delving into type theory and proof assistants and with
> special interests in Racket.
>
> I'm now trying to understand and implement P. Ragde's Proust
>  "nano proof assistant" and work
> through the examples in his article. However, I'm pretty much a beginner in
> Racket and I'm getting some errors. Particularly in the type-infer
> function, that's also used in the type-check function.
>
> Here is the code in the article:
>
> (define (type-check ctx expr type)
>   (match expr
> [(Lam x t)   ; lambda expression
> (match type
>[(Arrow tt tw) (type-check (cons `(,x ,tt) ctx) t tw)] ;
> arrow type
>[else (cannot-check ctx expr type)])]
> [else (if (equal? (type-infer ctx expr) type) true (cannot-check ctx
> expr type))]))
>
> (define (type-infer ctx expr)
>   (match expr
> [(Lam _ _) (cannot-infer ctx expr)]
> [(Ann e t)  (type-check ctx e t) t]
> [(App f a); function application
>   (define tf (type-infer ctx f))
>  (match tf
> [(Arrow tt tw) #:when (type-check ctx a tt) tw]
> [else (cannot-infer ctx expr)])]
> [(? symbol? x)
>  (cond
>  [(assoc x ctx) => second]
>  [else (cannot-infer ctx expr)])]))
>
> The first question I have is: what's the (Ann e t) supposed to mean,
> because I'm getting a syntax error? Is it a type annotation? If so,
> shouldn't everything be inside the #lang typed/racket module and type
> annotations everywhere?
>
> Secondly, the functions don't seem to work like this, as I'm getting
> failed matches for everything that's not a lambda expression. Can you
> please help me clarify the code there or maybe it's already available
> somewhere? Because just typing in the examples in the article simply
> doesn't work. I can understand what they are supposed to do, but I lack
> the skills to fix things myself.
>
> Thank 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/6bdfed6a-13c7-4e86-8dcf-5d61b18e15d7%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/CAAGM456YQqawEbaytizkn5X6NzJirLq5oj2RDWS620BkKaZZGg%40mail.gmail.com.


Re: [racket-users] Megaparsack and where errors happen

2020-02-22 Thread Matt Jadud
Hi Alexis,

That helps immensely. It was difficult to come up with a "minimal working
example" without dumping a large parser, so thank you for being willing to
read between the... productions? Lines? *cough*

I have found the library a a joy to work with, and as I got deeper into
working with it, I suspected I was not using it as well as I might have.
You are right that I did not realize what a "hammer" the backtracking was.

This definitely gets me unstuck, and I will see where it takes me.

Many thanks,
Matt


On Fri, Feb 21, 2020 at 11:54 PM Alexis King  wrote:

> Hi Matt,
>
> I think you probably want to read this section of the docs:
> https://docs.racket-lang.org/megaparsack/parsing-branching.html#%28part._.Backtracking_with_caution%29
>
> The core idea is that `try/p` is a heavy hammer. It causes any failure
> inside its scope to backtrack, so you might end up accidentally ruining
> your error messages. Usually, what you really want is to do a small amount
> of lookahead to determine which branch is the correct one to take, then
> commit to the branch so that future parse failures are reported immediately.
>
> Without seeing your `base-type/p`, `convert/p`, and `chain/p` parsers,
> it’s hard to suggest a concrete solution. But consider using `try/p` to do
> only whatever parsing you need to do in order to disambiguate the parsers,
> then exit the scope of `try/p`. Something like this:
>
> (or/p (do (try/p base-type-initial/p) base-type-remainder/p)
>   (do (try/p convert-initial/p) convert-remainder/p)
>   ...)
>
> There are other approaches as well, and if you provide more information I
> might be able to suggest something better.
>
> This complication is unfortunately fundamental to the Parsec parsing
> model. The syntax/parse model of tracking “progress” and reporting the
> error associated with the parse that made it the farthest is much nicer,
> but syntax/parse has the luxury of parsing a well-known tree structure. A
> more tractable improvement might be to add some kind of explicit committing
> construct.
>
> Hope this helps,
> Alexis
>
> > On Feb 21, 2020, at 20:19, Matt Jadud  wrote:
> >
> > Hi all,
> >
> > This might be a Lexi question, but perhaps someone else will have some
> insight as well.
> >
> > I'm wrestling with how to get errors to propagate down in megaparsack.
> For example:
> >
> > (define convert/p
> >   (do (string/p "convert")
> >  ...
> >   [assigns ← (many/p #:min 0
> >  assignment-statement/p
> >  )]
> >  ...
> >   (pure ...)))
> >
> > (Assume I have a bunch of other parsing bits around the call to
> `assignment-statement/p`.)
> >
> > Currently, if I have a malformed assignment statement, the error is at
> the top level of `convert`. `convert/p` is part of a backtracking
> conditional:
> >
> > (define conversion/p
> >   (do
> > [result ← (many/p (or/p (try/p base-type/p)
> > (try/p convert/p)
> > (try/p chain/p)
> > )
> >   #:sep space0+/p
> >   )]
> > eof/p
> > (pure result)))
> >
> > What should I do to get the error to report/fail down the parse tree, as
> opposed to the top? I would rather know that there's something wrong down
> in my assignment statement, as opposed to getting an error that "c" was
> unexpected (because the entire conversion/p failed on account of an error
> somewhere down inside).
> >
> > I need to give the docs a more careful read, but I thought I'd ask, as
> it seems both simple and, given the nature of the parsing tools, possibly
> subtle.
> >
> > Many thanks,
> > Matt
> >
> >
> > --
> > 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/CAAGM45761tRo%2Bj0Rh078ngriYiMDum%3DyDyRgwQ1LLiuPZDFj6A%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/CAAGM456wdPp_Jg9O2xubf98SQ4rA-b5QpLU2%2BBqD5cvSdZyPQg%40mail.gmail.com.


[racket-users] Megaparsack and where errors happen

2020-02-21 Thread Matt Jadud
Hi all,

This might be a Lexi question, but perhaps someone else will have some
insight as well.

I'm wrestling with how to get errors to propagate down in megaparsack. For
example:

(define convert/p
  (do (string/p "convert")
 ...
  [assigns ← (many/p #:min 0
 assignment-statement/p
 )]
 ...
  (pure ...)))

(Assume I have a bunch of other parsing bits around the call to
`assignment-statement/p`.)

Currently, if I have a malformed assignment statement, the error is at the
top level of `convert`. `convert/p` is part of a backtracking conditional:

(define conversion/p
  (do
[result ← (many/p (or/p (try/p base-type/p)
(try/p convert/p)
(try/p chain/p)
)
  #:sep space0+/p
  )]
eof/p
(pure result)))

What should I do to get the error to report/fail down the parse tree, as
opposed to the top? I would rather know that there's something wrong down
in my assignment statement, as opposed to getting an error that "c" was
unexpected (because the entire conversion/p failed on account of an error
somewhere down inside).

I need to give the docs a more careful read, but I thought I'd ask, as it
seems both simple and, given the nature of the parsing tools, possibly
subtle.

Many thanks,
Matt

-- 
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/CAAGM45761tRo%2Bj0Rh078ngriYiMDum%3DyDyRgwQ1LLiuPZDFj6A%40mail.gmail.com.


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

2019-12-21 Thread Matt Jadud
My off-list thought (which was largely because I wasn't sure it would even
work) was to run a second web server on another port that was bound to
localhost. Then, SSH onto the localhost when needed, and squirt values into
the locally bound webserver as needed. Depending on the server config
(e.g., you're the only one on it) would make this reasonably secure. (If
someone got onto your host, you probably aren't worrying about the hash
table of parameters...)

Cheers,
Matt

#lang racket
(require web-server/dispatch
 web-server/servlet
 web-server/servlet-env)

(define posts (make-hash))

(define (list-posts req)
  (response/xexpr
   `(html
 (body
  ,@(for/list ([(k v) posts])
  `(p ,(format "[~a] ~a" k v)))
   

(define (review-post req key)
  (hash-ref posts key))

(define-values (blog-dispatch blog-url)
(dispatch-rules
 [("") list-posts]
 [("posts" (string-arg)) review-post]
 [else list-posts]))

(define (add-key req k v)
  (hash-set! posts k v)
  (response/xexpr `(html (body ,(format "Added '~a' -> '~a'" k v
  )

(define (get-key req k)
  (response/xexpr `(html (body ,(format "Found '~a'"   (hash-ref posts k
false)
  )

(define-values (tweaker url)
  (dispatch-rules
   [("set" (string-arg) (string-arg)) add-key]
   [("get" (string-arg)) get-key]))

(thread (λ ()
  (serve/servlet blog-dispatch
 #:servlet-path ""
 #:servlet-regexp #rx""
 #:port 8080
 #:listen-ip "0.0.0.0")))
(thread (λ ()
  (serve/servlet tweaker
 #:servlet-path ""
 #:servlet-regexp #rx""
 #:port 9090
 #:listen-ip "127.0.0.1")))


On Sat, Dec 21, 2019 at 4:13 PM George Neuner  wrote:

>
> On 12/21/2019 4:44 AM, Marc Kaufmann wrote:
>
> one useful feature of the Django web framework is that it is easy to
> access the database and change it on the fly. I am not using a DB, but a
> hash inside of Racket for various reasons. I understand that it would be
> easy to connect to a database in any language, and getting the hash is a
> different beast - but I am wondering if there is an easy way such that I
> could tell the racket web server via a command line or REPL interaction
> "(update-user uid key-name new-value)" or some such.
>
> Is that easily possible? (And very secondarily: Is this a stupid idea? But
> even if it is, it's what I am under time pressure to get working, as a
> proper solution ain't gonna happen in time.)
>
>
> Running a REPL inside your program is fairly easy but not terribly safe.
> E.g., you can dedicate a thread to reading a network port and executing
> whatever code fragments you send.  But you need to take precautions,
> limiting what it is allowed to do, and who can access it, so unauthorized
> users can't screw up your program.
>
> In my apps I make hot tweak settings available through a secured web
> interface.  The "variables" are functions exported from my configuration
> module (similar to the way parameters work).
>
> (define-syntax getter/setter!
>   (syntax-rules ()
> ((getter/setter!)
>  ; -- start template
>
>  (let [(var null)]
>(lambda x
>  (cond
>([null? x] var)
>([pair? x] (set! var (car x)))
>(else (error))
>))
>)
>
>  ; -- end template
>  )))
>
> (define some-config-var (getter/setter!))
>
>
> Then  *(some-config-var )*  changes the value, and
> *(some-config-var)*  gets the current value.
>
> It's simplistic, but it works well.  I haven't run into the need for more
> explicit synchronization, but if needed it would be simple to add a
> semaphore / mutex to the macro.
>
> During program execution I can tweak these "variables" using a special
> HTML page that lets me review and set many variables all at once.  But it
> could be done using a bunch of simple handlers - one per variable - that
> could be command line driven using curl.
>
>
> In your case, you could create an "update-user" URL handler that updates
> your hash from its arguments.  If you give it an hard to guess name and
> don't document it, then it may be reasonably safe.
>
> YMMV,
> 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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/b3a4de57-9b40-faa3-651b-b5efa08329a4%40comcast.net
> 
> .
>

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

Re: [racket-users] Re: GUI (get-directory)

2019-12-05 Thread Matt Jadud
It feels like much of the information needed to make some of the sign posts
for easy contribution are available either 1) automatically available at
time of documentation build, or 2) could be added to the info file.

Would someone in the Racket team be able to recommend or suggest some
concrete ways the community might approach work that begins addressing the
task of making it easier to contribute to docs?

Or, really, anyone with some insight into the tools. Some pointers would
help make it easier to contribute productively.

Cheers,
Matt

On Thu, Dec 5, 2019, 18:29 wanderley.guimar...@gmail.com <
wanderley.guimar...@gmail.com> wrote:

> I think your point is totally valid, and I feel that I already saw such
> discussion in the mail list.
>
> You can simplify the process by searching a piece of the documentation in
> github.  For example, I search for a piece of the docs from rackjure (1)
> which is the second result in my search.
>
>
> (1)
> https://github.com/search?l==macro+automatically+adds+the+parentheses+language%3ARacket=Code
>
>
> On Thu, Dec 5, 2019 at 12:27 PM David Storrs 
> wrote:
>
>> For the record, my big concern with the documentation is that it's
>> extremely hard to contribute to.  I would be delighted to contribute
>> documentation if the process was easy, but it's just not.  For a language
>> as amazing as Racket and a documentation set as high-quality as Racket's,
>> the difficulty of helping with it is surprising.
>>
>> tl;dr :  Using literate programming techniques(*) for documentation is a
>> bad idea.  So is having random tiny files scattered around instead of one
>> single .scrbl file in a location that maps to the URL of the page.
>>
>> (*) (i.e., having random tiny files with documentation on one particular
>> thing and then automating the process of assembling them)
>>
>>
>> My understanding is that the sequence goes like this:
>>
>> 1) Notice a thing you would like to change (a typo fix, add an example,
>> etc)
>> 1a) Ask on the mailing list how to contribute changes since the Guide /
>> Reference / package does not have clear directions built in
>> 2) Go to Github
>> 3) Find which racket-related repository is the one that matters for this
>> documentation.  The Racket project itself has half a dozen repositories and
>> it's not obvious (to me, at least) which one is which.  Things on the
>> package server will have a direct link, which helps a lot.
>> 4) git fork the appropriate repository, git clone it to your local machine
>> 5) grep -r through the clone to find the document that you want to
>> modify.  It will not be in a location apparent from the URL of the page you
>> were looking at, nor will it be named what that page was named, nor will it
>> contain all of the content from that page.  Also, it will be in Scribble,
>> which is a DSL that requires non-trivial effort to learn and is non-trivial
>> to read.  Still, it produces amazing output so that's probably worth it.
>> It's intimidating when you're just getting started, though.
>> 6a) make your change
>> 6b) google for how to rebuild scribble documentation
>> 6c) rebuild (by default this will rebuild all documentation), verify you
>> made the change correctly
>> 7) git commit, git push
>> 8) go back to github and submit a pull request
>> 9) (when (eq? (sync pr-msg-ch) 'Accepted) (exit))
>> 10) make requested changes
>> 11) git commit, git push, goto 9
>>
>> Compare that to what it looks like in, e.g., Perl
>>
>> 1) Notice a thing you would like to change (a typo fix, add an example,
>> etc)
>> 2) got to CPAN and search for the package / tutorial / etc.  clicking on
>> the name of the package gets you a listing of all files in the package (cf
>> https://metacpan.org/release/ETHER/Moose-2.2012)
>> 3) click on the 'Package::Name::Contributing' file and do what it says.
>> This will probably be similar to the Racket workflow except that:
>>
>> a) The complete details are spelled out.
>> b) There is a link directly to the repository
>> c) The location of the file you need to edit is obvious from the URL of
>> the documentation page that you're changing
>> d) The file contains the complete text of the page so it's easier to find
>> and easier to verify that your edits were correct
>> e) The file is in POD, which is so simple that you can generally learn
>> what you need just from glancing at the file, and it's easier to read than
>> Scribble.  It's simple enough that you generally don't need to rebuild it
>> to HTML, but if you choose to then you can easily rebuild just that page.
>>
>> Example of a Contributing file:
>> https://metacpan.org/pod/release/ETHER/Moose-2.2012/lib/Moose/Manual/Contributing.pod
>>
>>   (NB:  All major Perl packages have a Contributing file and the 'create
>> a package' tool for generating Perl modules creates a stub version for you
>> so it's hard to forget.  If the author somehow *does* forget and the
>> package doesn't have its own Contributing file then CPAN will show you a
>> default 

Re: [racket-users] Structured Concurrency in Racket

2019-10-07 Thread Matt Jadud
Hi Josh,

Racket has a number of powerful concurrency libraries/extensions that
handle both concurrent execution of code in a single process as well as
parallel execution across multiple processes/hosts. There is the "futures"
library, which might be the most similar to Trio.

https://docs.racket-lang.org/reference/futures.html

However, there are libraries that provide a larger lift, and are
grounded in language traditions that tie back to algebras for reasoning
about parallel systems. The channel library, and the code that builds on it
("places"), are examples.

https://docs.racket-lang.org/reference/channel.html

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

The history of formal reasoning, and implementation of, mechanisms for
concurrency and parallelism go back to at least the... 70's?

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

"Structured concurrency" does not, from the link(s) provided, seem to be
anything that stands out from this long tradition. (Or, if you prefer,
computer scientists have been reasoning about, building systems around, and
integrating into languages notions of parallelism and concurrency for
roughly 40+ years.)

So, personally, I would say that Racket has multiple libraries (which,
because of the nature of Racket, are in some cases extensions to the base
language) that implement structured concurrency.

Unless I'm completely misunderstanding your post.

Cheers,
Matt


On Mon, Oct 7, 2019 at 1:46 PM jab  wrote:

> Coming across
> https://trio.discourse.group/t/structured-concurrency-and-delimited-continuations/
> just provoked me to search for discussion of structured concurrency in
> Racket. I didn’t immediately find much.* I hope that doesn’t mean that the
> interesting work that’s being discussed over in
> https://trio.discourse.group/c/structured-concurrency etc. has been
> largely unknown by the Racket community. Trio is having a profound impact
> on the future of concurrency, not just in Python but in many other
> languages. There’s even a post on Wikipedia now:
> https://en.wikipedia.org/wiki/Structured_concurrency
>
> (For anyone new to the term,
> https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
> might be the best starting point. One persuasive example shows Nathaniel
> live coding a correct implementation of RFC 655 “Happy Eyeballs” in 40
> lines of Python:
> https://github.com/python-trio/trio-talks/tree/master/njsmith-async-concurrency-for-mere-mortals
> (For comparison, Twisted’s implementation took hundreds of lines and still
> had a logic bug after years of work.) There is also some related reading in
> https://github.com/python-trio/trio/wiki/Reading-list.)
>
> I hope this post provokes discussion of structured concurrency in Racket.
> It’d be fascinating to read more of your thoughts!
>
> Thanks,
> Josh
>
> * For example, Googling “structured concurrency racket” turned up mostly
> just a brief mention of Racket’s custodians in the bottom-most comment on
> this post: http://250bpm.com/blog:71
>
> --
> 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/bb36e50a-a77b-4c5b-b144-71ce647069b7%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/CAAGM455HSfVgBcu%2B1FZc-mubYaeYEFZb1XxZo_z_sQNqRDO4XQ%40mail.gmail.com.


Re: [racket-users] Haskell

2019-05-14 Thread Matt Jadud
The last time I saw a colleague sit down to write a compiler in Haskell,
they first had to do a bunch of heavy lifting to get the type system to
play along sensibly.

http://offog.org/publications/fita200811-generics.pdf

Your mileage may vary. I'd just use Racket. (See John's note.)

Cheers,
Matt

On Tue, May 14, 2019 at 11:23 AM Josh Rubin  wrote:

> It just occurred to me that Haskell could be a powerful way to manipulate
> programs in other languages (like Scheme or Racket). Unfortunately, I don't
> know Haskell. Has anybody been down this path?
>
> --
> Josh rubinjlru...@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/d2961559-f8af-c6d0-15e1-9c20b3dab959%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAAGM4551VVwp-QLVpMWw2nHd16SHOin-UoJi6w6JyG%2BnnQMDGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] recursive function with multiple arguments

2019-04-11 Thread Matt Jadud
Hi Travis,

Others will probably have better insights.

The only part that would be able to be replaced with a recursive call in
logmodr seems to be the loop itself. It is walking the list/vector y from
the second element to t (which... does numeric on a vector coerce it to a
length? I have no idea what numeric(t) does in this context. I sometimes
lose my mind trying to think about everything in R as a vector, and
where/when different functions do different things depending on what you
pass as a value...).

My termination condition is when i is equal to t, and otherwise, I do the
calculation, attaching the current calculation to the result of calculating
the rest of the values in the range. (In the for loop in the original
logmodr, this comes out looking like assignment to a vector, but we'll cons
up a list instead.) I have no idea if my pseudocode below puts the list in
the correct order... that could be fixed in a number of ways.

If I were translating this code, I would personally consider allocating the
vector and just doing the direct transliteration with a for loop. I don't
know that I would try and convert the code to a recursive call... but, as a
learning exercise, it makes sense why you're thinking about it.

The HtDP design recipe helps in thinking about how to break these kinds of
questions down. In this case, I had to think about whether there was a
recursion over a list/vector (there doesn't seem to be), but instead it
seemed like I'm building up my results in a list/vector. Therefore, I
needed to think about the recursion on the range of numbers and choose my
termination condition accordingly. From there, I also needed to figure out
what information was initialization, and what information needed to be
passed through the loop. Ultimately, I might pass a fair number of
parameters, but that's because I have to maintain the correct local scope
for each recursive call. I could also use an internal function definition
for some of these things, so that values that don't change are defined
once, and the function that is implementing the loop closes over those
values just once. This would cut... theta from the list of parameters, and
possibly also k and r, because they don't change. (Ha! K don't change.
That's a C pun!)

Bad humor aside, my point was that I could probably define a calc function
that had an internal calc* function (using either an internal define or a
letrec), and it would only take i and y as parameters. calc* would then
implement the "loop".

Someone will, no doubt, post a cleaner example that is three lines long and
only uses letrec and lambda, but here was my take on your question. But,
this was more fun then getting started on grading.

Cheers,
Matt

(define (rnorm t thetasd)
  (list 1 2 1))

(define (calc i y t r k theta)
  (cond
[(= i t) '()]
[else
 (cons (* (list-ref y (sub1 i))
  (- r (* (/ (* r (list-ref y (sub1 i))) k)
  (exp (list-ref theta i)
   (calc (add1 i) y t r k theta))]))

(define (logmodr yinit t r k thetasd)
  (let ([y (list yinit)]
[theta (rnorm t 0 thetasd)])
(calc 0 y t r k theta)))

On Thu, Apr 11, 2019 at 1:50 AM  wrote:

> Hi All,
>
> I'm trying to better understand recursion. I decided to rewrite the
> logmodr function from this blog post
>  as
> a recursive function. I was easily able to write the recursive functions if
> all but one of the arguments were set to default values. But I was
> completely stumped by how to handle the situation without using default
> argument values. After a considerable amount of flailing about, I finally
> realized that I could accomplish this task by passing the arguments as a
> struct (see code below). I find the struct approach relatively intuitive
> but it strikes me as quite verbose. Are there other (better?) ways to
> handle this task?
>
> Thanks,
>
> Travis
>
>
> #lang racket
>
> (require math)
>
> (struct args (y r k thetasd) #:transparent) ; only 'y' changes in
> project-pop function below
>
> (define (logmod args-struct)
>   (define theta (flvector-ref (flnormal-sample 0.0 (args-thetasd
> args-struct) 1) 0))
>   (args (* (args-y args-struct) (* (- (args-r args-struct) (* (args-r
> args-struct) (/ (args-y args-struct) (args-k args-struct (exp theta)))
> (args-r args-struct)
> (args-k args-struct)
> (args-thetasd args-struct)))
>
> (define (project-pop args-struct t [i 1])
>   (define y (args-y args-struct))
>   (if (= i t)
>   (list y)
>   (cons y (project-pop (logmod args-struct) t (+ i 1)
>
> (project-pop (args 1.0 1.8 20.0 0.1) 25)
>
>
> --
> 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: raco setup conflicting with slideshow

2019-04-10 Thread Matt Jadud
On Tue, Apr 9, 2019 at 3:55 PM Matthew Flatt  wrote:

>
> Are you running into problems where you really need GUI functionality
> to create the image? Or it is just a library is bundled with GUI
> functionality --- like `plot`, and maybe the `plot/no-gui` analog is
> missing? Or is it more a question of keeping track of which libraries
> imply a GUI and which do not?
>

In this case, there's probably a number of things going on.

1. Me not knowing when to use plot vs. pict.
2. Me having used plot in a library of my own, and then wanting to use
something from that library in my documentation. At that point, perhaps my
library should be organized so that I can separately include the parts that
require plot and the parts that don't.
3. I want to use the plot-generating parts of my library to write docs,
but  can't use them directly (on OSX, but it would work elsewhere?)...
which, is some combination of #1 and #2.

The summation of 1, 2, and 3 might sum to a result that says I haven't
taken the time to understand the connections between these libraries, and
that I have assembled my own code in sloppy ways. It was, however, a
surprise for me when I ran into it.

Cheers,
Matt

-- 
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: raco setup conflicting with slideshow

2019-04-09 Thread Matt Jadud
On Tue, Apr 9, 2019 at 2:44 PM Stephen Foster 
wrote:

>
> I've always assumed that any correct Racket code can be run during setup's
> documentation-building time.  If this isn't true, how can I know which
> Racket code can be used in this way and which can't?
>
>
I just wanted to +1 this thread; as I've been working on documentation
where I'd like to either 1) procedurally generate images as part of the
docs, or 2) have parts of the library that generate graphical output, I run
into import issues at setup time that cause the build to fail. These are
probably all variants of the OSX/non-main place problem.

I've been considering moving to a two-phase documentation build process,
where I have a Makefile to run Racket code to generate static images, and
then drive Scribble to generate the documentation. This way, the
documentation build process will succeed. In the end, that might be more
portable/easier for distribution anyway...

Cheers,
M

-- 
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] Does Racket have a sexp-syntax regular expressions?

2019-03-27 Thread Matt Jadud
I found this:

https://github.com/cordarei/racket-trx

Cheers,
M


On Wed, Mar 27, 2019 at 8:18 AM zeRusski  wrote:

> I swear someone told me there was a Racket lib equivalent of Emacs Lisp rx
> or Shivers's trx regular expressions, yet I failed to find one. Any
> pointers?
>
> Thanks
>
> --
> 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] color-maps for the plot package

2019-03-20 Thread Matt Jadud
>
>
> If others think that (1) and (2) are worthwhile doing, I will submit a PR,
> so
> we can discuss the API an implementation over something more concrete.  I
> am
> open discussion for points (3) and (4).
>
> For the more broader color map changes, if the improvements are split up in
> small incremental tasks, I will be happy to help out, as time allows.
>
>
1-4 sound like a solid foundation. If it was possible to have an API point
where a user can add (and then select) their own colormap, that would be
lovely. This would allow the described machinery to "just work" if I want
to explore the generation and use of colormaps other than those in the
library.

I've got an "all-puce" map in mind...

Thank you for the work and effort.

Cheers,
Matt

-- 
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] color-maps for the plot package

2019-03-19 Thread Matt Jadud
+1 in general, and making them accessible from outside plot makes sense to
me.

On Tue, Mar 19, 2019 at 9:53 AM Jens Axel Søgaard 
wrote:

> This is a great idea.
>
> It would be really nice to be able to use the colors also from non-plot
> programs.
>
> /Jens Axel
>
>
>
>
>
>
> Den tir. 19. mar. 2019 kl. 08.09 skrev Alex Harsanyi <
> alexharsa...@gmail.com>:
>
>>
>> The Python matplotlib package supports the concept of a colormap for
>> selecting
>> colors for each data set that is displayed -- the user uses an index, like
>> color 0, 1, 2, etc and this is mapped to a RGB value in the color map.
>> The
>> visual aspect of a plot can be changed just by switching the color map.
>>
>> The color maps that are available to the matplotlib user have a nice set
>> of
>> colors chosen by experts (presumably) and this makes it easy to create
>> nice
>> looking plots, you can see the colors here:
>>
>> https://matplotlib.org/examples/color/colormaps_reference.html
>>
>> The `plot` library from Racket allows specifying colors by using the RGB
>> triplet, or by using the `->pen-color` function which converts an index
>> into a
>> hardcoded set of colors -- this is similar to the color map concept,
>> except
>> that the available colors are not as nice and they are hardcoded:
>>
>>
>> https://docs.racket-lang.org/plot/utils.html?q=-%3Epen-color#%28def._%28%28lib._plot%2Futils..rkt%29._-~3epen-color%29%29
>>
>> I would like to add support for color maps to the plot package, if others
>> consider it worthwile.  The way I think it would work is that a new plot
>> parameter (say `plot-pen-color-map`) would be defined and `->pen-color`
>> would
>> be changed to use the user specified color map instead of the default set
>> of
>> colors (the default set would still be used if no color map is specified).
>>
>> I put together some prototype code (including a screenshot of what it
>> would
>> look like) here:
>>
>> https://gist.github.com/alex-hhh/8ca14a0890dc2cfa8fc89e0c816d86da
>>
>> Technically this could be implemented outside the `plot` package, but I
>> think
>> it is much nicer to be readily available when Racket is installed and it
>> will
>> result in much nicer looking plots for a lot less effort.
>>
>> Do others think this would be useful?
>>
>> Alex.
>>
>> --
>> 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.
>>
>
>
> --
> --
> Jens Axel Søgaard
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [racket-users] Re: Racket News - Issue 4

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

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

Cheers,
Matt

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

> Thank you so much for this!
>
> If I can suggest a project for next month's spotlight:
>
> - Christopher Lemmer Webber, co-editor of the ActivityPub specs, is
> working on a distributed social network library based on Racket:
> https://gitlab.com/spritely
>   It's still in early development, but I think it's an important project
> to give visibility to ;)
>
> Maybe we could also have a spotlight section for #lang languages too?
>
> - The brag parser generator is obviously a good project.
> - The video lang by Leif is also pretty awesome.
> - The slideshow lang might be a great pick too.
> - Obviously scribble.
>
> On Friday, March 15, 2019 at 12:03:47 PM UTC+1, Paulo Matos wrote:
>>
>> I have just published Issue 4 at
>>
>> http://racket-news.com/2019/03/racket-news-issue-4.html
>>
>> Grab a coffee and enjoy!
>> --
>> Paulo Matos
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [racket-users] Pretty display of tabular data?

2019-03-14 Thread Matt Jadud
On Thu, Mar 14, 2019 at 11:51 AM  wrote:

>
> 3. Which brings me to to the biggest obstacle.
>
> — beginners make mistakes
> — languages must explain mistakes
> — beginners better understand these explanations
>
>
Yes to all three of your points. I was thinking about your last point in my
first exploration, and error handling/reporting is something that is at the
front of my mind as I look at things like Pyret's sanitizers, as well as
the many/manifest ways that I see students struggle/fail with R. I don't
think I'll be able to "solve" this in the first instance, but keeping
centered the lived experience of the novice when learning to work with data
(which often comes in "from the wild," and is not
consistent/reliable/etc.), how to manage that messiness, and how to report
back in a learning-centric way when they encounter difficulty is going to
be 1) hard and 2) critical.

Which is perhaps a reflection/restatement/variation of what your last point.

I'm generally familiar with the broad space in which Guillaume's work is
situated, and have seen in presented/read it. So, yes.

And, thank you for the pointer to the rewriter library. The Racket stack is
rich enough at this point that I forget the wealth of tools that are
available.

Cheers,
M

-- 
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-14 Thread Matt Jadud
>
> There are now several projects announced on this list, all of them deal
> with
> data analysis on one way or the other.  Would it be possible to join forces
> and merge these projects so that we end up with one library that servers
> multiple purposes equally well?  Something where the final product is
> greater
> than the sum of its parts...
>
> Or perhaps these libraries have aims that are so different from each other
> that the only thing they share is a very abstract concept of "table"?
>

Yes?

It makes complete sense, from a practical perspective, to not duplicate
work.

Without bikeshedding ("where should the conversation happen?", "what color
should the logo be?"), there are easier and harder design constraints. For
example, I realized that any sufficiently interesting table interface
would, ultimately, embed a copy of LISP... wait... would be a half-assed
reimplementation of SQL. So, in my rethink, I just set things on top of the
sql library, thus providing the "base language" from which I would work. If
SQL can't do it, it's possible I don't need to do it, and it is 100%
certain that a first-year, who has been programming for 6 weeks, will not
have introductory data questions that cannot be handled by my "target
language."

Keeping a non-leaky abstraction (or, as non-leaky as possible) that lets a
student who is early in HtDP do work with data (in a principled way...
another loaded perspective...) is very important to me. I'll trade all the
fancy databases in the world (as well as the full expressivity of SQL, and
performance for datasets beyond 100K rows, and and and...) for an interface
that does a small number of things very well for novices. If we can do our
design work so that there are demarked shells of increasing complexity,
then yes, I'm confident that we could find ways to combine forces.

If nothing else, I'm already eyeing other libraries that I want to "wrap,"
so that they operate on the substrate I'm laying. I want simplified
plotting (with possibly reduced levels of customization from full 'plot',
either enforced through interfaces or simply enforced by reducing the
documentation for the interface), basic tools for summarizing and analyzing
data (I'm thinking of wrapping the "data-science" library that is floating
around, but not packaged)... so, yes. I don't want to reimplement
everything, but I do need a common substrate. At the moment, I've decided
that anywhere Racket runs (and that my students will use it) is powerful
enough to also have SQLite, and for my time, energy, and task, there are
worse choices than just using SQL.

But, back to bike-shedding... at the least, it might be interesting to kick
around a set of requirements/wants/needs/desires, and from there think
about next steps in design. However, blank-whiteboard design phase work is
challenging in distributed/asynchronous modes, so I'm also concerned that a
mailing list amongst people who do not know each-other is a hard way to do
good design on something nuanced... but, that could just be a failing of
mine. Suggestions for "next steps" on collaboration are something I'm
absolutely open to.

At the end of the day, I need tools for next Fall (ideally, sooner, so I
can begin developing course materials); that's a hard, non-optional
design/implementation deadline, no matter how much interest and goodwill
there is to collaborate.

Cheers,
Matt

-- 
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-13 Thread Matt Jadud
First, thank you for all the great pointers in this thread. It is clear
that different renderings will be useful in different contexts, and there's
good libraries to leverage in the community. That's what I was hoping.

https://bitbucket.org/jadudm/tbl/

(I'll add Github as a second push destination shortly.)

There's a story about how I'm at the point of writing this library. The
short version is that I would like to be able to do simple exploratory data
analysis with relatively small data in simple ways. The word "simple" is
grossly loaded in this context, so I'll just say that I want a library that
supports introductory exploratory data analysis in an HtDP context, and I
want it to have a pedagogic growth path, so that if students go off to use
Python/NumPy/SciPy, or R/Tidyverse (or, horrors, plain R), then they've had
the conceptual base to know what they want to do, even if the syntax,
semantics, and learning materials are against them.

This was a first dive into starting to think seriously about syntax-case
and syntax-parse, and that probably led me down roads that were not
entirely productive. I did a lot of implementation work as I explored.

In the last few days, I threw out 3000 lines of exploration, and rewrote it
in 300, much more of which is tests. In particular, I decided that
everything I wanted to do could be handled by an in-memory SQLite database,
I could leverage Ryan's excellent 'sql' library, and in doing, effectively
design a small "language" (API? interface? perhaps someday a #lang?) that
wraps operations on that data. However, the design of that is subject to
discussion and debate, and it might be that the library ultimately
encapsulates more than one interface, so that different kinds of data
questions can be asked differently.

So, the abstractive lift of using db/sql was huge, and I also like
rackunit/chk. I'm also wrapping some parts of plot, so that I can have
really, really short pathways to investigating data. It's early days on the
pieces (which, in the rewrite, I sprinted based depth to instead stitch a
complete pipeline in the name of proof-of-concepting the choice to backend
to SQLite). Wrapping everything under a single require, etc., hasn't
happened yet, testing is reasonably underway, and documentation on the
rewrite is currently lagging.

#lang racket
(require tbl/reading/gsheet
 tbl/plot)

;; The source Google Sheet: http://bit.ly/cities-gsheet
;; read-gsheet takes a version published/shared as a CSV
(define T (read-gsheet "http://bit.ly/cities-csv;))
(show (scatter T "LonD" "LatD"))

These two lines let me read in a CSV published via Google Sheets, and get
a  scatterplot in DrRacket.

So, that's a long story. However, I'd welcome dialogue. I may come back
with some specific questions. For the moment, I'm exploring. I had (and
will have again) the ability to slurp in SQL databases (SQLite, MySQL,
etc.), I currently do CSV files, and would like to output a number of these
formats as well. In terms of plotting, I'd like to support basics (think
early chapters of Tukey) with some customization, but ultimately know that
I can always drop down to full 'plot' if I need to.

The output of the table question is so that students can have a richer view
into the tables they're working with. A lot of good pointers were in this
thread.

That's long, but there you go. That's the story. A short version may be
"I'm standing on the shoulders of giants," because the rewrite feels like a
wrapper around sql and db... which, frankly, is lovely. (And, I'm almost
starting to understand how to use the various quasiquoting syntactic forms
in the sql language to build my own frankensteined queries...)

Cheers,
M




On Wed, Mar 13, 2019 at 4:59 PM  wrote:

> I've wanted this too, and got the sense that working with `snip%` instead
> of `gen:custom-write` was 1) the way to go and 2) very difficult. Are you
> planning on using this in some open source code you have right now in a
> github repo or something similar? I'd like to bookmark it.
>
> On Wednesday, March 13, 2019 at 11:19:07 AM UTC-7, Matt Jadud wrote:
>>
>> Hi all,
>>
>> I have a tabular data type that I'd like (I think) to be able to render
>> it either in ASCII or in a prettier way in the Interactions pane. I've
>> explored gen:write and friends, and can get the struct to display the way I
>> want---with ASCII. Essentially easy-peasy.
>>
>> What I wonder is: am I able to do something prettier? Can I encapsulate
>> some kind of styled rendering as a snip%, or... something... so that I can
>> render the first 5 and last 5 rows of a table with bolding of headers,
>> etc.?
>>
>> I don't know where to start, essentially, if I wanted to try and do this.
>> Or, perhaps it is not particularly doable.
>>
>> Pointers to examples in codebases are 

Re: [racket-users] Writing scribble?

2019-03-13 Thread Matt Jadud
I was going to say... is ESC-B some kind of shortcut from one of those
"text editors" I hear people talk about? ;) (I should have remembered that
DrR has bindings for many Emacs shortcuts...)

Also, thanks for the reminder about the prefs/bindings; this is essentially
the first time I've spent significant time poking at Scribble, and the
shortcuts that are useful are different, so they're in my unlearned-space.
I appreciate the pointers.

Cheers,
M


On Wed, Mar 13, 2019 at 8:16 PM Robby Findler 
wrote:

> It is control-left and control-right to go by words in DrRacket. If
> you go to Edit|Keybindings|Show Active Keybindings and type "word"
> you'll see those and the ones Matthias mentioned and some other
> word-related keystrokes.
>
> Robby
>
> On Wed, Mar 13, 2019 at 1:24 PM Matt Jadud  wrote:
> >
> > Hi all,
> >
> > I assume people use DrRacket to write Scribblings.
> >
> > I'll be writing text, and want to move back one word. On the Mac, most
> of the time I can hit Option-LeftArrow, and I go back one word.
> >
> > I DrRacket, this takes me back an expression, which in Scribble is a
> whole paragraph.
> >
> > Are there shortcuts for moving around Scribble documents that I don't
> know? Do people use other tools to write Scribblings?
> >
> > Cheers,
> > Matt
> >
> > --
> > 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] Writing scribble?

2019-03-13 Thread Matt Jadud
Hi all,

I assume people use DrRacket to write Scribblings.

I'll be writing text, and want to move back one word. On the Mac, most of
the time I can hit Option-LeftArrow, and I go back one word.

I DrRacket, this takes me back an expression, which in Scribble is a whole
paragraph.

Are there shortcuts for moving around Scribble documents that I don't know?
Do people use other tools to write Scribblings?

Cheers,
Matt

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

2019-03-13 Thread Matt Jadud
Hi all,

I have a tabular data type that I'd like (I think) to be able to render it
either in ASCII or in a prettier way in the Interactions pane. I've
explored gen:write and friends, and can get the struct to display the way I
want---with ASCII. Essentially easy-peasy.

What I wonder is: am I able to do something prettier? Can I encapsulate
some kind of styled rendering as a snip%, or... something... so that I can
render the first 5 and last 5 rows of a table with bolding of headers,
etc.?

I don't know where to start, essentially, if I wanted to try and do this.
Or, perhaps it is not particularly doable.

Pointers to examples in codebases are welcome (if such examples exist), and
I can work from there. Or, indications that this might be really difficult
are also welcome.

Cheers,
Matt

(Apologies if this somehow comes through twice... I sent it to plt-scheme
first...)

-- 
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] Help with evaluation of examples in Scribble

2019-03-10 Thread Matt Jadud
Oh! Thank you, Matthew.

I see. So, I'm running into the sandbox... as in, the sandbox is doing what
it should, and as a result, it is preventing the networked accesses that
I've added to my documentation. That's awfully obvious (now that it is put
that way), but it wasn't obvious from the error message.

I'll think about faking it for doc build. I'll add it to the issue tracker
for the package. I'm still learning basic things about scribbling docs, but
will likely stub something in to simplify the doc build at some point.
Thanks, Robby.

Cheers,
M



On Sun, Mar 10, 2019 at 10:57 AM Robby Findler 
wrote:

> For the purposes of documentation building however, does it perhaps make
> sense to fake then actual network connection?
>
> Robby
>
> On Sun, Mar 10, 2019 at 9:48 AM Matthew Flatt  wrote:
>
>> Use `call-with-trusted-sandbox-configuration` around the creation of
>> the evaluator. It's painful and unlikely to be worthwhile to give a
>> documentation sandbox limited (but workable) access to the filesystem.
>>
>> At Sun, 10 Mar 2019 10:29:15 -0400, Matt Jadud wrote:
>> > Hi all,
>> >
>> > I am trying to get sandboxed evaluation of code working in my scribble
>> > docs, and am having trouble.
>> >
>> > At the top of a scribble file, I have
>> >
>> > --- PASTE ---
>> > #lang scribble/manual
>> > @(require scribble/example
>> >   racket/sandbox
>> >   )
>> > --- ENDPASTE ---
>> >
>> > This file is a section that is being included into the top-level
>> > manual.scrbl.
>> >
>> > And, in the body of the included file, I have
>> >
>> > --- PASTE ---
>> > @(define my-evaluator
>> >(parameterize ([sandbox-output 'string]
>> >   [sandbox-error-output 'string]
>> >   [sandbox-memory-limit 50])
>> >  (make-evaluator 'racket
>> >  #:requires '(data-table
>> >
>> > @examples[#:eval my-evaluator
>> >   ; A remote Google Spreadsheet that we want to manipulate
>> >   (define test-url "http://bit.ly/2E2qZoI;)
>> >
>> >   ; Fetch the URL, and turn it into a table named "Testing"
>> >   (define fetched (read-gsheet "Testing" test-url))
>> >
>> >   ; Select all of the rows where the "age" column is greater
>> than 6.
>> >   (sieve fetched (> age 6))
>> >   ]
>> > --- ENDPASTE ---
>> >
>> > However, when I include this code, I get the following:
>> >
>> > --- PASTE ---
>> >
>> > raco setup: 3 running: /data-table/scribblings/manual.scrbl
>> >
>> > with-input-from-file: `read' access denied for
>> > /Users/mjadud/Library/Racket/7.2/share/info-cache.rktd
>> >
>> >   context...:
>> >
>> >/Applications/racket720/collects/setup/getinfo.rkt:231:4: for-loop
>> >
>> >/Applications/racket720/collects/setup/getinfo.rkt:221:0:
>> populate-table!
>> >
>> >/Applications/racket720/collects/setup/getinfo.rkt:289:0:
>> > find-relevant-directory-records23
>> >
>> >/Applications/racket720/collects/setup/getinfo.rkt:286:0:
>> > find-relevant-directories
>> >
>> >"/Users/mjadud/Library/Racket/7.2/pkgs/tzinfo/tzinfo/zoneinfo.rkt":
>> > [running body]
>> >
>> > --- ENDPASTE ---
>> >
>> >
>> > I can get things to build if I leave this file out.
>> >
>> > I can get things to build if I leave out the evaluator and sandboxed
>> > evaluation.
>> >
>> > Therefore, I think I have something wrong with how I'm setting up this
>> > evaluator, but I'm not sure how yet to fix the error I've encountered.
>> >
>> > Any insights would be appreciated.
>> >
>> > Cheers,
>> > Matt
>> >
>> > --
>> > 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.
>

-- 
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] Help with evaluation of examples in Scribble

2019-03-10 Thread Matt Jadud
Hi all,

I am trying to get sandboxed evaluation of code working in my scribble
docs, and am having trouble.

At the top of a scribble file, I have

--- PASTE ---
#lang scribble/manual
@(require scribble/example
  racket/sandbox
  )
--- ENDPASTE ---

This file is a section that is being included into the top-level
manual.scrbl.

And, in the body of the included file, I have

--- PASTE ---
@(define my-evaluator
   (parameterize ([sandbox-output 'string]
  [sandbox-error-output 'string]
  [sandbox-memory-limit 50])
 (make-evaluator 'racket
 #:requires '(data-table

@examples[#:eval my-evaluator
  ; A remote Google Spreadsheet that we want to manipulate
  (define test-url "http://bit.ly/2E2qZoI;)

  ; Fetch the URL, and turn it into a table named "Testing"
  (define fetched (read-gsheet "Testing" test-url))

  ; Select all of the rows where the "age" column is greater than 6.
  (sieve fetched (> age 6))
  ]
--- ENDPASTE ---

However, when I include this code, I get the following:

--- PASTE ---

raco setup: 3 running: /data-table/scribblings/manual.scrbl

with-input-from-file: `read' access denied for
/Users/mjadud/Library/Racket/7.2/share/info-cache.rktd

  context...:

   /Applications/racket720/collects/setup/getinfo.rkt:231:4: for-loop

   /Applications/racket720/collects/setup/getinfo.rkt:221:0: populate-table!

   /Applications/racket720/collects/setup/getinfo.rkt:289:0:
find-relevant-directory-records23

   /Applications/racket720/collects/setup/getinfo.rkt:286:0:
find-relevant-directories

   "/Users/mjadud/Library/Racket/7.2/pkgs/tzinfo/tzinfo/zoneinfo.rkt":
[running body]

--- ENDPASTE ---


I can get things to build if I leave this file out.

I can get things to build if I leave out the evaluator and sandboxed
evaluation.

Therefore, I think I have something wrong with how I'm setting up this
evaluator, but I'm not sure how yet to fix the error I've encountered.

Any insights would be appreciated.

Cheers,
Matt

-- 
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 Matt Jadud
On Thu, Feb 21, 2019 at 2:59 PM  wrote:

>
> - 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:
>
>
Everyone must be thinking the same things these past few months...

https://bitbucket.org/jadudm/data-table

I have been looking at Pyret's interface to tables, as well as the
data-frame package in the Racket pkg collection, and R's interface to
dataframes. My goal is something that is syntactically/conceptually simple
for students to use for EDA, and potentially scales well to more
interesting questions involving data. In the fall, I'll be doing work with
students around environmental sensing as part of their coursework, and I
want something for working with data that fits into the HtDP approach to
introducing students to thinking about designing programs.

Right now, I'm still exploring, and haven't made significant progress on
documentation, largely because I've just lifted the library to a point that
I can start using it myself for some experimentation with data in a project
of my own. This has illustrated some things that are missing, are not as
clean as they could be, etc., so I'm going to circle around again on the
library as I explore. My thinking is that if I can simplify the interfaces
and operations on a project with a heavy data lift, I might be heading in
the right direction for small data projects as well.

At the moment, I can import public spreadsheets from Google, slurp in MySQL
tables, SQLite tables, and CSV files. Although proprietary, I'll probably
add support for Airtable as an input as well, and will eventually look at
some of the MQTT dashboards for IoT (eg. io.adafruit.com). I have not
tested the living daylights out of the library, but nascent tests are
proceeding with development to watch for regressions as I explore. I can
insert, select, and sieve (filter) from tables, as I like the nomenclature
that Pyret uses for tables; I'm borrowing their ideas for the interface to
table operations for now.

I like the interface you've proposed for quickly specifying columns
(although the rationale for keywords is unclear to me), but I'd personally
have to think about the role of types on those columns. I like Pyret's
sanitizers, which provide cleanliness guarantees that the user can specify,
thus protecting the programmer from ill-formatted data in the table.

I suppose data-table is a usable library at this point, but it's highly
fragile while I'm working on it. 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.

Cheers,
Matt

-- 
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 Matt Jadud
On Tue, Feb 5, 2019 at 8:01 AM 'Paulo Matos' via Racket Users <
racket-users@googlegroups.com> wrote:

>
> Matthew mentions the move to Chez will help maintainability and I am
> sure he's right because he has been working with Racket for a long time
> but my experience comes from looking at backend files. When you look at
> them you end up being forced to look elsewhere, specifically the
> cpnanopass.ss file [3]. Well, this file is the stuff of nightmares...
> It's over 16000 (sixteen thousand!!!) lines of dense scheme code, whose
> comments are not necessarily Chez-Beginner friendly (maybe Alexis wants
> to rewrite it? [4]).


Interestingly, having been in the classroom* around '98-2000  when some of
these nanopass ideas were being developed (or, really, when I think they
were really hitting stride in the classroom---I'm sure they were being
developed well before), I find [3] to be exceedingly readable. Well, not
"exceedingly": I think it would benefit from some breaking apart into
separate modules. However, it uses the nanopass framework for specifying a
series of well-defined languages, each of which can be checked/tested
between pipeline stages.

Some of the more gnarly code is in the register allocation... which is
unsurprising. I do like that I can flip to the end, see the driver for all
the passes, and each pass is a separate, match-like specification of a
transformation from one language (datatype) to another. Ignoring the fact
that there's support code in the file, 16KLOC suggests around 500 lines per
pass (at roughly 30 passes, it looks like); 500 lines seems to me to be a
manageable unit of code for a single pass of a compiler that should, if
written true-to-form, does just one thing per pass. (This is, I suspect, a
classic "YMMV" kind of comment.)

I can't say that I'm about to step in and join the compiler team (save us
all from the thought!). I do think that it's nice to see the idea a
nanopass compiler 1) in production and 2) having the maturity to become
part of the production back-end of Racket. If [1] is where some/much of
Racket's backend currently lives, I am ecstatic that the backend will be
more Scheme (Chez? Racket?) than C/C++.

Cheers,
Matt

[1]
https://github.com/racket/racket/blob/master/racket/src/racket/src/compile.c

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

-- 
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: Tensorflow bindings?

2019-02-04 Thread Matt Jadud
Hi Doug,

If you think they're a good starting point, I'm happy to contribute. I
would rather reinvent fewer things.

My impression from off-list conversation is that if the library is on
GitHub, and licensed appropriately (Apache 2, MIT, BSD, LGPL*, GPL*, MPL,
EPL, ISC, CC-BY, CC-BY-SA, OFL, MS-PL, Boost Software License, or Artistic
licenses), then Google engineers would have permission (from a
legal/license perspective) to ultimately contribute as well. If they were
so moved.

Up to you.

Cheers,
M


On Mon, Feb 4, 2019 at 12:54 PM Doug Williams 
wrote:

> I have a start on them already, but they need work. I don't need them on
> my project until the summer and they have been a low priority. I would be
> happy to share them with anyone that wants to go at a faster pace.
>
> On Mon, Feb 4, 2019, 9:49 AM Greg Trzeciak 
>> Wasn't it a rhetorical question? :)
>>
>> Although I don't have use for TensorFlow at the moment - I would love to
>> have the FFI bindings ready for when I will finally need it.
>> The AI story in Racket at the moment is not as good is it could be:
>> https://github.com/racket/racket/wiki/AI
>>
>>
>> On Monday, February 4, 2019 at 5:07:58 PM UTC+1, Matt Jadud wrote:
>>>
>>> Hi all,
>>>
>>> https://www.tensorflow.org/install/lang_c
>>>
>>> Would there be interest/value in having FFI bindings for TensorFlow? If
>>> I poke it with a stick, are there others who would be willing to contribute
>>> to the development of a package that provided those bindings?
>>>
>>> I'm getting to the point with a project where I'm going to have to bail
>>> out of Racket in order to do some machine learn-y stats work, and I'd
>>> rather not have to switch languages just to do the analysis.
>>>
>>> Cheers,
>>> M
>>>
>> --
>> 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.


[racket-users] Tensorflow bindings?

2019-02-04 Thread Matt Jadud
Hi all,

https://www.tensorflow.org/install/lang_c

Would there be interest/value in having FFI bindings for TensorFlow? If I
poke it with a stick, are there others who would be willing to contribute
to the development of a package that provided those bindings?

I'm getting to the point with a project where I'm going to have to bail out
of Racket in order to do some machine learn-y stats work, and I'd rather
not have to switch languages just to do the analysis.

Cheers,
M

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

2019-01-22 Thread Matt Jadud
> No kidding?
>

*cough*

My initial wild guess is that the problem is in the queen.  Going by the
> description it's way overly complicated, with plenty of opportunities
> for something to get lost.
>

Perhaps. It's not a long driver, as code goes.


>
> Your whole architecture seems overly complicated for what it does. Why
> is the coordinator (queen) so intimately involved?  Why not have the
> workers process an ID end to end [read the source table, calculate,
> update the result table]?  All the coordinator should do is load balance
> and ensure that all the IDs actually get processed.
>

FWIW, to make sure that workers don't pull IDs on a duplicate basis, I have
one process farming them out. Hence, the worker requests an ID, does the
work, and submits the work back to the manager. The manager doles out IDs,
and then stores results.

But, yes, I can look to simplify.

Is the *source* table ever being updated outside of your program?
> And what is the DBMS?
>

No.

They're two SQLite tables. The readers should never block readers, to the
best of my understanding, and there is only a single writer (to a
completely separate DB/table).

I'm not aware that DP channels can drop messages - they are built on top
> of TCP for reliability.  The whole idea is that places may be widely
> separated and communicating by Internet.
>

Yep.

respond.  Instrumenting both sides would be best, but it should be
> simple enough for the queen to check that there is 1:1 correspondence
>

Yep.

There are myriad ways a distributed program can screw up.  I can't claim
> that the Racket place infrastructure is bullet-proof, but it certainly
> is well tested.  Any bugs are far more likely to be in your code. :-)
>

I agree. Appreciate having a sounding board. Thank you.

Back into the fray. More simplification, more contracts, more logging, and
simplify! simplify! simplify!

Cheers,
Matt

-- 
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] Distributed places question

2019-01-21 Thread Matt Jadud
Hi all,

I have too much code for a "minimal working example."

Every time I run a distributed places program, I get different results.
Sadly, it's complex, and I'm confident there are multiple places I could be
missing something. This is all running on a 256-core machine, and my
distributed places are all ssh connections to localhost. Each worker
spawned gets a unique port. I get non-deterministic results regardless of
whether I am running 2 or 64 or 128 places.

1. I have a queen bee process that reads in IDs from a database table.
2. Workers request, via distributed place channel, an ID.
3. The queen (which has a separate router for each worker running in
separate threads) sends an ID. This is dequeued from a semaphore-protected
queue.
4. The workers do queries based on that ID, some arithmetic calculations,
and then send a serializable struct back to the queen (received by the
router assigned to that worker). All comms, actually, use serializable
structs, and I match on those structs at both ends.
5. The queen uses a channel (local/internal) to send that struct to a
thread managing a queue.
6. Because there are multiple writers to that internal channel, a semaphore
is used within the processing thread to protect the queue.
7. A final thread picks elements off the queue (protected by the same
semaphore), and those structs are written into a database. There is a
separate DB for storing the results. There are no contention issues between
the table from which data is read during runtime and the DB where data is
stored at the end.

It's... not the simplest structure. That said, the comms between
queen/worker are deterministic; from ID fetch to final result, there is no
non-determinism. It is a bit of back-and-forth, but unrolled, it is a
pipeline pattern. So, between queen and worker, there should be no
impediments to communication, and no non-deterministic/branching
communications.

If I understand channels in Racket correctly, I can have multiple writers
to a single channel end, so although there is non-determinism in the
routers writing to the queuing thread, they should all be serviced. The
queue itself is, therefore, doubly-protected, once by the comms structure,
and once by the semaphore: it should not be possible for two threads to
ever be in the queue, either to insert or dequeue. The database tables are
either for reading or writing: never the two shall meet.

 1. If a worker chokes on something, will I ever know? I don't believe I
have a logging/error interface set up for the workers. (Besides... if they
die, how do they communicate that back over a channel before dying?) If
they threw an exception, would I hear about it while I'm watching the queen
run?

2. Is it possible for a distributed channel to drop data silently? Should I
add logging that lets me trace all of my comms from Q->W and back again?

3. Should I have a set of logs (for queen and all workers) that let me
reconstruct all comms/computations? I can do this, but I was hoping someone
would say "X possibly fails in Y way...", and that would provide insight
before I do all of that instrumentation work.

Ultimately, I think the heart of my questions have to do with the way
workers might silently die (if they can), and whether it is possible that
distributed channels can silently drop data without my queen process
knowing. (The latter would seem like an awfully big thing, and so I
sincerely doubt that's the issue.) Those are two big holes in my mental map
of how distributed places work, and I've spent enough time cleaning
up/refactoring/simplifying things that I thought I would ask the community
at this point.

I'm bothered because the DB work and calculations are all so deterministic.
I've only parallelized this because of the volume of data that ultimately
needs to be processed...

Cheers,
Matt

-- 
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] OpenGL in build w/ package server

2019-01-19 Thread Matt Jadud
Many thanks, Jay. I can work with that.

On Sat, Jan 19, 2019 at 10:13 AM Jay McCarthy 
wrote:

> This page talks about foreign library on the package build:
>
> https://pkg-build.racket-lang.org/about.html#foreign
>
> It's plausible the GLU is something common enough, we should install
> it by default.
>
> On Sat, Jan 19, 2019 at 3:10 PM Matt Jadud  wrote:
> >
> > Hi all,
> >
> > Is there a way to convince the package server to build packages that
> rely on the OpenGL bindings? Perhaps something in the deps of info.rkt that
> I don't understand?
> >
> > raco setup:   ffi-lib: couldn't open "libGLU.so.1" (libGLU.so.1: cannot
> open shared object file: No such file or directory)
> >
> > Cheers,
> > Matt
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
> -=[ Moses 1:33: And worlds without number have I created; ]=-
>

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


[racket-users] OpenGL in build w/ package server

2019-01-19 Thread Matt Jadud
Hi all,

Is there a way to convince the package server to build packages that rely
on the OpenGL bindings? Perhaps something in the deps of info.rkt that I
don't understand?

raco setup:   ffi-lib: couldn't open "libGLU.so.1" (libGLU.so.1:
cannot open shared object file: No such file or directory)

Cheers,
Matt

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

2019-01-01 Thread Matt Jadud
Hi all,

While avoiding other work this holiday season, I decided to explore this
further.

I very intentionally have modeled the work so far on NetLogo, given its
long history in this space. And, in exploring this project, I'm also
learning a number of things myself. For example, the project involved some
new learning in terms of macros as well as optimization, and I'm still
wrestling with the way the microworld is designed/implemented in the face
of that ongoing learning. (Similarly, I'm also still learning about
packaging, how the package server does or possibly does not work with
various git hosting solutions, and am learning Scribble.)

At this point, I have done no testing on Windows, am confident there's a
more performant (and maintainable/safe/etc.) way to represent the
underlying grid/world, and know there's a lot of testing and safety/error
handling to be be implemented.

So, release early, release often and all that. I thought I'd mention it
here in case anyone else wanted to explore along. I also recorded a few of
the microworlds in action, just because.

https://youtu.be/FpMy9QxWnhE

This seems to be available via a package install of "paddle." I have code
in my "examples" directory that fails to build, and I have to figure out
how to 1) leave it in the repository but 2) ask the package server to
ignore it at build time...

Happy new year,
Matt


On Thu, Dec 6, 2018 at 12:45 PM John Clements 
wrote:

> Sounds fascinating. As an instructor for first-quarter CS+X, I’ve been
> looking at alternatives to sound as a setting. I’m interested in the
> Fisler/Krishnamurthi/Politz/Lerner Big Data curriculum, but yours also
> sounds good!
>
> John
>
>

-- 
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] Macro introducing definitions from list of ids

2018-12-12 Thread Matt Jadud
Hi all,

I have improved my question. In asking it, I'm trying to make sure I
understand things so that I can ultimately ask fewer questions (about
this). Apologies for the verbosity; it exposes more surface for confusion
to be corrected.

I read Matthew's "Macros as scopes" last night before going to bed; I
cannot claim it was my best reading. That said, it gave me enough to sleep
on, strip out some mess this morning, and ask a better question.

https://gist.github.com/jadudm/2a1960867223773f09aef41ec551bd3f

Now, I get errors that look like what I saw in the scopes paper. This
strikes me as good.

In the example code (in "scopes-use"), 'current-agent' is defined at Phase
0.

"current-agent" in the first use, in "scopes-use"

Scopes at phase 0:
#(339342 module)
#(339349 module scopes-use)

"current-agent" as it appears in the macro expansion:

Scopes at phase 0:
#(-337432 module scopes-base)
#(-337431 module scopes-base)
#(-337422 module)
#(-337421 module)
#(339349 module scopes-use)
#(339369 macro)
#(339634 macro)

The full error (which is probably obvious from what I've now presented) is

current-agent: unbound identifier
  context...:
   #(-337432 module scopes-base) #(-337431 module scopes-base)
   #(-337422 module) #(-337421 module) #(339753 macro) #(340018 macro)
   #(340044 local) #(340045 intdef) #(340046 local) #(340047 intdef)
   #(340049 local) #(340051 local) #(340052 intdef) #(340054 local)
   #(340061 intdef) #(340066 local) #(340067 intdef) #(340070 local)
   #(340071 intdef) #(340073 local) #(340074 intdef) [common scopes]
  other binding...:
   #(current-agent # 0)
   #(339726 module) [common scopes]
  common scopes...:
   #(339733 module scopes-use)

What I'm uncertain of is how to reconcile the scopes for the macro
expansion. I've reached my current understanding of how friends like
syntax/loc, and perhaps more specifically, a macro-expanding-to-a-macro,
play with the scope expansions.

It may be that I can't do what I want to do.

Cheers,
Matt









On Tue, Dec 11, 2018 at 9:13 PM Matt Jadud  wrote:

> Ha! A new question!
>
>>
>>>>

-- 
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] Macro introducing definitions from list of ids

2018-12-11 Thread Matt Jadud
Ha! A new question!

1. My macro expands. I use the macro expander (which is wonderful), and
everything looks good.
2. In my code, Racket helpfully claims the identifier that I believe should
be bound, is not bound.
3. I copy the expanded macro from the expander.
4. I comment out the macro use site.
 5. I paste in the expanded macro.
6. Everything works.

This suggests to me I have the expansion I want.

Does each step of the macro expander change color for friendliness, or are
those expansion phases, and therefore only my first round of expansion is
being recognized as being in the environment (as opposed to a macro that
expands to a macro that expands to identifiers)?

I'm enjoying rereading "Fortifying Macros," and think I'll rewrite things
I've written in my explorations now, but I don't know if that will address
this question.

Many thanks,
Matt





On Tue, Dec 11, 2018 at 5:21 PM Matt Jadud  wrote:

> I'm wondering if...
>
>
> https://stackoverflow.com/questions/41102630/transforming-a-list-of-symbols-to-a-list-of-identifiers-to-be-used-in-a-macro
>
> is what I'm looking for (he says, answering himself)...
>
> (define-syntax (introduce stx)
>   (syntax-case stx ()
> [(_ tag ids ...)
>  (with-syntax ([(getter ...) (datum->syntax #'tag
> (map (λ (id)
>(string->symbol
> (format "~a-get-~a"
>
>  (syntax->datum #'tag)
>
>  id)))
>  (syntax->datum #'(ids
> ...])
>#`(begin
>(define (getter)
>  ;; Generating a do-nothing body for demonstration...
>  (format "get ~a ~a" (quote tag) (quote getter))) ...
>   ))]))
>
> Here's one answer. And I just crossed with Jens...
>
> Many thanks, Jens. That's much nicer. It illustrates how to decompose the
> problem into a few clean helpers to make the resulting macro much clearer.
>
> Thank you,
> Matt
>
> On Tue, Dec 11, 2018 at 5:07 PM Matt Jadud  wrote:
>
>> Many thanks, John.
>>
>> I've made it that far. I'll be more specific...
>>
>> Conceptually, I want...
>>
>> (define-syntax (introduce stx)
>>   (syntax-case stx ()
>> [(_ tag ids ...)
>>  (with-syntax ([(getters ...)
>> (map (λ (id) (format-id #'tag "~a-get-~a" tag id))
>> ids ...)])
>>#`(begin
>>(define (getters) 'get-something) ...)
>>)]))
>>
>> so that
>>
>> (introduce tag a b c)
>>
>> produces
>>
>> (define (tag-get-a) ...)
>> (define (tag-get-b) ...)
>> (define (tag-get-c) ...)
>>
>> I am aware that I can't use 'map' in the context above. I... know, but do
>> not understand, that the LHS of with-syntax is a syntax pattern. However,
>> how I would generate a syntactic form that I would match against that
>> pattern where I generate the identifiers for the defines (and then how I
>> would appropriately use ... to indicate repetition of the defines form, if
>> the structure above is even close) is what I'm wrestling with.
>>
>> Cheers,
>> M
>>
>>
>>
>> On Tue, Dec 11, 2018 at 4:16 PM John Clements 
>> wrote:
>>
>>> In answer to at least one of your questions, top-level “begin”s are
>>> “spliced” into their context to produce top-level bindings. So, for
>>> instance,
>>>
>>> #lang racket
>>>
>>> (begin
>>>   (define a 3)
>>>   (define b 4))
>>>
>>> (+ b a)
>>>
>>> … evaluates to 7
>>>
>>> I think this is not the only issue you’re going to run into, but it’s at
>>> least one of them.
>>>
>>> Apologies if I misunderstood your question!
>>>
>>> John
>>>
>>> > On Dec 11, 2018, at 1:12 PM, Matt Jadud  wrote:
>>> >
>>> > Hi all,
>>> >
>>> > I'm exploring macros today.
>>> >
>>> > I'd like to introduce a set of bindings. For example, I would like
>>> >
>>> > (introduce tag a b c)
>>> >
>>> > to become
>>> >
>>> > (define (tag-get-a) ...)
>>> > (define (tag-set-a! v) ...)
>>> >
>>> > or somesuch set of defines. I've discovered with-syntax and format-id,
>>> and have had good success with introducing singular defines, but how to
>>> expand the list of ids into a list of defines is something I'm no

Re: [racket-users] Macro introducing definitions from list of ids

2018-12-11 Thread Matt Jadud
I'm wondering if...

https://stackoverflow.com/questions/41102630/transforming-a-list-of-symbols-to-a-list-of-identifiers-to-be-used-in-a-macro

is what I'm looking for (he says, answering himself)...

(define-syntax (introduce stx)
  (syntax-case stx ()
[(_ tag ids ...)
 (with-syntax ([(getter ...) (datum->syntax #'tag
(map (λ (id)
   (string->symbol
(format "~a-get-~a"

   (syntax->datum #'tag)

   id)))
 (syntax->datum #'(ids
...])
   #`(begin
   (define (getter)
 ;; Generating a do-nothing body for demonstration...
 (format "get ~a ~a" (quote tag) (quote getter))) ...
  ))]))

Here's one answer. And I just crossed with Jens...

Many thanks, Jens. That's much nicer. It illustrates how to decompose the
problem into a few clean helpers to make the resulting macro much clearer.

Thank you,
Matt

On Tue, Dec 11, 2018 at 5:07 PM Matt Jadud  wrote:

> Many thanks, John.
>
> I've made it that far. I'll be more specific...
>
> Conceptually, I want...
>
> (define-syntax (introduce stx)
>   (syntax-case stx ()
> [(_ tag ids ...)
>  (with-syntax ([(getters ...)
> (map (λ (id) (format-id #'tag "~a-get-~a" tag id)) ids
> ...)])
>#`(begin
>(define (getters) 'get-something) ...)
>)]))
>
> so that
>
> (introduce tag a b c)
>
> produces
>
> (define (tag-get-a) ...)
> (define (tag-get-b) ...)
> (define (tag-get-c) ...)
>
> I am aware that I can't use 'map' in the context above. I... know, but do
> not understand, that the LHS of with-syntax is a syntax pattern. However,
> how I would generate a syntactic form that I would match against that
> pattern where I generate the identifiers for the defines (and then how I
> would appropriately use ... to indicate repetition of the defines form, if
> the structure above is even close) is what I'm wrestling with.
>
> Cheers,
> M
>
>
>
> On Tue, Dec 11, 2018 at 4:16 PM John Clements 
> wrote:
>
>> In answer to at least one of your questions, top-level “begin”s are
>> “spliced” into their context to produce top-level bindings. So, for
>> instance,
>>
>> #lang racket
>>
>> (begin
>>   (define a 3)
>>   (define b 4))
>>
>> (+ b a)
>>
>> … evaluates to 7
>>
>> I think this is not the only issue you’re going to run into, but it’s at
>> least one of them.
>>
>> Apologies if I misunderstood your question!
>>
>> John
>>
>> > On Dec 11, 2018, at 1:12 PM, Matt Jadud  wrote:
>> >
>> > Hi all,
>> >
>> > I'm exploring macros today.
>> >
>> > I'd like to introduce a set of bindings. For example, I would like
>> >
>> > (introduce tag a b c)
>> >
>> > to become
>> >
>> > (define (tag-get-a) ...)
>> > (define (tag-set-a! v) ...)
>> >
>> > or somesuch set of defines. I've discovered with-syntax and format-id,
>> and have had good success with introducing singular defines, but how to
>> expand the list of ids into a list of defines is something I'm not seeing
>> yet. Somehow, I feel like a macro that simply follows the natural recursion
>> on the syntax objects is probably the answer, but... that's like saying the
>> answer to a question in quantum mechanics is either 0, 1, or h-bar/2...
>> >
>> > I'm looking at the define-cbr example in the documentation, and
>> suspicious that I'm reaching a point with my macro authoring where the ...
>> and (... ...) are leaving me confused as to which layer of expansion I'm
>> dealing with as I look at my code. Hence, I'm asking for a nudge in the
>> right direction.
>> >
>> > Cheers,
>> > Matt
>> >
>> >
>> >
>> > --
>> > 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] Macro introducing definitions from list of ids

2018-12-11 Thread Matt Jadud
Many thanks, John.

I've made it that far. I'll be more specific...

Conceptually, I want...

(define-syntax (introduce stx)
  (syntax-case stx ()
[(_ tag ids ...)
 (with-syntax ([(getters ...)
(map (λ (id) (format-id #'tag "~a-get-~a" tag id)) ids
...)])
   #`(begin
   (define (getters) 'get-something) ...)
   )]))

so that

(introduce tag a b c)

produces

(define (tag-get-a) ...)
(define (tag-get-b) ...)
(define (tag-get-c) ...)

I am aware that I can't use 'map' in the context above. I... know, but do
not understand, that the LHS of with-syntax is a syntax pattern. However,
how I would generate a syntactic form that I would match against that
pattern where I generate the identifiers for the defines (and then how I
would appropriately use ... to indicate repetition of the defines form, if
the structure above is even close) is what I'm wrestling with.

Cheers,
M



On Tue, Dec 11, 2018 at 4:16 PM John Clements 
wrote:

> In answer to at least one of your questions, top-level “begin”s are
> “spliced” into their context to produce top-level bindings. So, for
> instance,
>
> #lang racket
>
> (begin
>   (define a 3)
>   (define b 4))
>
> (+ b a)
>
> … evaluates to 7
>
> I think this is not the only issue you’re going to run into, but it’s at
> least one of them.
>
> Apologies if I misunderstood your question!
>
> John
>
> > On Dec 11, 2018, at 1:12 PM, Matt Jadud  wrote:
> >
> > Hi all,
> >
> > I'm exploring macros today.
> >
> > I'd like to introduce a set of bindings. For example, I would like
> >
> > (introduce tag a b c)
> >
> > to become
> >
> > (define (tag-get-a) ...)
> > (define (tag-set-a! v) ...)
> >
> > or somesuch set of defines. I've discovered with-syntax and format-id,
> and have had good success with introducing singular defines, but how to
> expand the list of ids into a list of defines is something I'm not seeing
> yet. Somehow, I feel like a macro that simply follows the natural recursion
> on the syntax objects is probably the answer, but... that's like saying the
> answer to a question in quantum mechanics is either 0, 1, or h-bar/2...
> >
> > I'm looking at the define-cbr example in the documentation, and
> suspicious that I'm reaching a point with my macro authoring where the ...
> and (... ...) are leaving me confused as to which layer of expansion I'm
> dealing with as I look at my code. Hence, I'm asking for a nudge in the
> right direction.
> >
> > Cheers,
> > Matt
> >
> >
> >
> > --
> > 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] Macro introducing definitions from list of ids

2018-12-11 Thread Matt Jadud
Hi all,

I'm exploring macros today.

I'd like to introduce a set of bindings. For example, I would like

(introduce tag a b c)

to become

(define (tag-get-a) ...)
(define (tag-set-a! v) ...)

or somesuch set of defines. I've discovered with-syntax and format-id, and
have had good success with introducing singular defines, but how to expand
the list of ids into a list of defines is something I'm not seeing yet.
Somehow, I feel like a macro that simply follows the natural recursion on
the syntax objects is probably the answer, but... that's like saying the
answer to a question in quantum mechanics is either 0, 1, or h-bar/2...

I'm looking at the define-cbr example in the documentation, and suspicious
that I'm reaching a point with my macro authoring where the ... and (...
...) are leaving me confused as to which layer of expansion I'm dealing
with as I look at my code. Hence, I'm asking for a nudge in the right
direction.

Cheers,
Matt

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

2018-12-06 Thread Matt Jadud
Hi all,

The context for my recent messages to the list is that I'm thinking about
courses for next year, and I'm thinking about the intersections of data
analysis/visualization, modeling, and HtDP-ish introductions to programming.

I like NetLogo (https://ccl.northwestern.edu/netlogo/). I don't want to
introduce students to programming in NetLogo. While it is easy to attach
(say) a slider to a variable in a simulation, and it is easy to plot (say)
the population of an agent in the microworld, it is hard to then analyze
that data.

There's an R extension that embeds a headless NetLogo in R. I have even
less desire to introduce students to R, let alone the complex amalgamation
of the two.

Racket has all the tools I need. The Universe/Big Bang model seems like
there's already an infrastructure in place for supporting a functional
miroworld-style animation. (Or, I could go down the Processing path and
hide things behind a setup/draw, or I could go down the Greenfoot path, and
have student objects inherit from a base class that is microworld/animation
ready.). There's ample support for data representation, analysis, and
visualization. Every language abstraction I could want is somewhere in the
box.

I know it is a classic mistake to reinvent things that exist, but I feel
like the tools I want for an environment for introducing programming in a
principled way, and allowing students to engage in microworld simulations
and their analysis, are all here and within reach. I thought I'd float it
to this list, however, so that if there's any "we tried that," or "you
might look at" type suggestions, I could get those before I start sinking
time into this exploration.

Cheers,
Matt

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

2018-12-05 Thread Matt Jadud
Hi Doug,

I suspect (in this case), I'd like to build on/leverage plot, because I'd
like things to place nice in DrRacket's REPL (for example), and be able to
play with the plot ecosystem. To save you any work, I'll circle around
later if future me thinks current me was wrong.

This is crossing with Alex's message; based on his message/example, I think
I've read down too far, and need to spend more time looking at the tools
provided. For example, I somehow missed that (x-axis ...) could have its
origin moved. Instead, I was down into the points, line, and other
renderers, and therefore trying to implement my own renderer... when, in
truth, it is likely that everything I need at the moment is exposed "in
userland," if you will.

Thank you both,
M

On Wed, Dec 5, 2018 at 6:45 PM Doug Williams 
wrote:

> I have done many extensions to plots for a variety of reasons. Most of my
> extensions are a third option: Build on dc%. I typically make a new widget,
> say based on a horizontal or vertical panel with one or more embedded
> canvases. Then I use plot/dc to render directly on those canvases. I can
> easily aligned multiple plots, add additional elements outside the plots
> (in other embedded canvases), or overwrite the plot as I want. This works
> great for plots that are embedded in graphical programs - I do a lot of
> analysis work that way. I assume you could use plot/pict in a similar
> manner, but I never have.
>
>>
>>

-- 
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] Questions about plot

2018-12-05 Thread Matt Jadud
Hi all,

If I want to develop a new plot type, would I do best to:

1. Build on plot, or
2. Build on pict?

I suspect #1.

If I want to (say) have a number line, I would like to have an x-axis,
centered in my plot area (vertically), and no y-axis. I've been reading the
plot code for scatter plots, and I'm not clear where/how, if I were to
implement in a similar way, where I would override/parameterize for
changing the axes. (There's near and far axes (bottom and top) in 2D
renderers, but I don't seem to get to decide where they go vertically in
the plot space.)

Then, would I be drawing to it using the utilities built into plot, or do I
convert to a dc% in some way, and leverage pict, or... ?

In short, I feel like I should be building on plot/extending plot, I don't
want to reinvent wheels that are already invented, but I'm not yet sure
where the best starting point is. Do I develop a new plot type, dig deeper
into how axes are drawn, or do I do everything with overlays, or ...?

Many thanks,
Matt

-- 
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: plot legends

2018-12-01 Thread Matt Jadud
Thanks for the pointer; I should have searched the group history before
asking. And, perhaps, the ticket queue.

For what I'm exploring right now, that would be just fine, and makes
perfect sense, and will let me proceed with explorations without (yet)
making pull requests.

However, I personally feel like the enhancement that Ben pointed to is a
good one. Being able to say

'outer-upper-right
'outer-upper-left
...

(for example, and so on) as additional legend positions (so as to not
change the current language around legend placement) would be nice. While I
might, sometimes, want the legend inside the range of my axes, I personally
can imagine often wanting it outside of the "plot area."

Cheers,
M

On Sat, Dec 1, 2018 at 5:31 PM Alex Harsanyi  wrote:

>
> There was a similar question asked on this group a while ago.  tThe plot
> library does not support legends outside the plot area, but you can use the
> pict package to construct your own legend and place it anywhere.  This
> requires some coding, but provides more flexibility (for example,  you can
> also change the way the legend is drawn.)
>
> See https://groups.google.com/forum/#!topic/racket-users/QLfNmsluVHM
>
> Alex.
>
> On Sunday, December 2, 2018 at 4:47:22 AM UTC+8, Matt Jadud wrote:
>>
>> Hi all,
>>
>> I'm starting to think about courses for next year, and I'd really like to
>> move to Racket for working with data with my students. For me, this is
>> going to involve thinking about a package or packages that move some
>> plotting and data work down into the HtDP space.
>>
>> For now, I'm just playing. One of the first things that I've run into
>> with plotting is that I'd like to put the legends outside of the area in
>> which data is plotted. (Put another way, I'd like my legend to appear to
>> the right of #:x-max.)
>>
>> Is this possible using the existing library, or would this require
>> discussion/modifications and a pull request against the plot package?
>>
>> Many thanks,
>> Matt
>>
> --
> 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] plot legends

2018-12-01 Thread Matt Jadud
So, is the discussion "are you going to do it, or me?"

:D

Humor aside, I'll take a look, and report back thoughts here. Or,
visa-versa. (Or, if there is a better space for this conversation,
somewhere else.)

Thanks for the pointer to the ticket.

Cheers,
M

On Sat, Dec 1, 2018 at 4:14 PM Ben Greenman 
wrote:

> I think this requires discussion & modification.
>
> E.g.: https://github.com/racket/plot/issues/49
>

-- 
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] plot legends

2018-12-01 Thread Matt Jadud
Hi all,

I'm starting to think about courses for next year, and I'd really like to
move to Racket for working with data with my students. For me, this is
going to involve thinking about a package or packages that move some
plotting and data work down into the HtDP space.

For now, I'm just playing. One of the first things that I've run into with
plotting is that I'd like to put the legends outside of the area in which
data is plotted. (Put another way, I'd like my legend to appear to the
right of #:x-max.)

Is this possible using the existing library, or would this require
discussion/modifications and a pull request against the plot package?

Many thanks,
Matt

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-05 Thread Matt Jadud
On Mon, Nov 5, 2018 at 11:49 AM George Neuner  wrote:

>
> Don't throw it away too quickly.
>
> With a nod to process/thread scheduling: unless you muck with
> process/thread groups, by default Linux tries to gang schedule all the
> (ready) threads of a process to run simultaneously.
>
> Rather than creating large numbers of processes each having 1 place, you
> might want to consider creating fewer processes that have several places
> each  [essentially a gang of thread pools].  If the places typically do
> significant amounts of work, leveraging the gang behavior of the scheduler
> *might* increase overall performance of the application as a whole.
> [Particularly if the machine is not dedicated to your computing, and if the
> admins are not actively preventing you from exploiting this.  YMMV.]
>

Fortunately, at the moment, the machine is mine to play with, so I'm not
about to run into contention with other users.

I had structured the whole application in a CSP-ish way, largely using
channels to manage my synchronization. Therefore, the new abstraction isn't
too large a step.

I'm going to think about how to structure this a bit more at this point. As
you suggest, there's more than one way to do it, and as long as I'm doing
some cleanup/restructuring, I might as well be sensible about it.

Many thanks,
Matt

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-05 Thread Matt Jadud
Hi all,

First, thank you for the conversation around this.

On Sun, Nov 4, 2018 at 5:30 PM George Neuner  wrote:

>
> One .zo per distributed place is just one descriptor per process.  Again
> insignificant because you have 4K per process.
>
> It's apparent that the code is leaking descriptors somewhere.  Forcing GC
> may mitigate the problem, but it would be better if you found the leak.
>
>
I've lied. I am *not* using distributed places. I'm using *dynamic-place*,
which clearly is why I'm running into limits.

Unless anyone has alternative ideas, I'm going to restructure my code to
use distributed places on the single machine, which will, I think, give me
multicore parallelism and eliminate the file descriptor limit I'm running
up against.

Many thanks, again. I locked in my head I was using distributed places, and
was blind to my own code. I've kept the test case I wrote, below, that let
me see clearly what I was doing, as opposed to getting caught up in all the
other things my code was engaged in. I'll leave it below for posterity's
sake, but it doesn't serve a particular role at this point.

Cheers,
Matt

---

NOT QUITE RELEVANT ANYMORE...

I've written a small test case, and with Stefan's suggestion, dropped the
soft limit on descriptors to 100.

I can run my test case with 100 distributed places  when the soft limit is
1024 (and I end up with 708 descriptors in use when all of the distributed
places are idling), and it crashes immediately/very quickly when I drop
down to 100 descriptors.

[mjadud@phi subsetting]$ ulimit -n 100

[mjadud@phi subsetting]$ racket -um stress-queen.rkt

open-input-file: cannot open input file

  path:
/usr/netapp/faculty/mjadud/racket-src/racket/collects/racket/private/compiled/reading-param_rkt.zo

  system error: Too many open files; errno=24

The files I used for testing are in this Gist:

https://gist.github.com/jadudm/b165190677bf3c3eab2c07c278d61808

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Matt Jadud
On Sun, Nov 4, 2018 at 5:30 PM George Neuner  wrote:

>
> I'm not sure what you mean by "*my* descriptors".
>

I know what I mean, and I was incorrect. I was thinking my limit was
per-user, not per-process. Why I thought that, I don't know.

This thread gives me enough to work with in terms of next steps. Many
thanks.

Cheers,
Matt

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Matt Jadud
On Sun, Nov 4, 2018 at 4:58 PM Stefan Schmiedl  wrote:

> You  could  also  try  to  _reduce_  one of the limits of the current
> session  at  at  time  and see if that makes a difference. No need to
> bother the sysadmins for that.
>

Oooh. That saves me the risk of BOFH-style losses of my home directory...

Humor aside, good call.

Cheers,
M

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Matt Jadud
On Sun, Nov 4, 2018 at 4:30 PM 'Paulo Matos' via Racket Users <
racket-users@googlegroups.com> wrote:

> Curious about what your places are doing.
> How come you started so many places without seeing this:
> https://groups.google.com/d/msg/racket-users/oE72JfIKDO4/zbFI6knhAQAJ
>
> Could you share what each of the places do?
>

Each process is:

0. Requesting an identifier (integer) from the queen process over a
(distributed) place channel,
1. Extracting multiple subsets of data from a database based on that id,
2. Performing a series of calculations on each subset of data, and
3. Communicating the results of those calculations back to the queen
process over the place channel.

The workers each hold one reference to the query-db. The results that come
back to the queen are thrown on a queue, which is processed and written to
a separate database.

All communications between distributed processes are happening as
serializable structures over the place channels.

I don't believe I'm seeing the behavior you're describing, but I would have
to investigate more closely. I believe, given the scale of data that I'm
processing, that I'm seeing a roughly linear speedup... but perhaps that
reaches a plateau.  I'll have to revisit the thread you referenced and
investigate more closely; I only gained access to the machine Thursday.

Cheers,
Matt

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Matt Jadud
On Sun, Nov 4, 2018 at 2:17 PM George Neuner  wrote:

Are you using in-process places or distributed places?   In-process places
> are just OS threads in the same process.  Distributed places can be
> launched in/as separate processes, but then each process would have its own
> set of file descriptors.
>

Distributed places. However, even if they have their own descriptors, they
would be *my* descriptors. I think I'm limited to 1024 based on the current
machine configuration.


What DBMS(es)?  In-process DBMS like SQLite use file descriptors, but
> client/server DBMS use network connections (which don't count as open
> files).
>

I had that in a draft of this message; sorry for leaving it out. I have a
connection to the SQLite DB per distributed place. I *could* convert all of
this to use MySQL/Postgres, but I'm using SQLite because the dataset I'm
working with is across the ocean, and I'm caching things in a way that lets
me move between machines/clusters easily without having to set up new
services. I could possibly reduce this to a pool of DB connections, and use
a place channel to do all the queries against the DB. This would cut my
number of descriptors down.


IIRC, bytecode files are memory mapped, and that requires the file be kept
open.  But even if every file is mapped into every place, you'd need a lot
of code files to exhaust 4K descriptors ... if it is being done smartly
[???], there would only be 1 descriptor needed per file.


Unless it is 1024 descriptors, and if I have one .zo per distributed place,
and a DB, and... the question of whether library files count against that
.zo file descriptor count (I don't know)... that could quickly exhaust
things at the 128-distributed-place level. I have multiple libraries
included (sql, gregor, beautiful-racket-lib) and several files are required
in that I've written.

Without a whole lot more information the only thought that occurs is to
have each place force a major GC after it finishes a work unit.  If
something is not being closed properly by the code, then it might be
cleaned up by the GC.


Which, given that the distributed places are doing time-intensive work,
this doesn't hurt me drastically.

I won't be able to investigate more until tomorrow or Tuesday, given my
schedule. I might start by asking for a bump in the file descriptor from
the sysadmins.

Many thanks,
Matt

-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Matt Jadud
Hi all,

I have some code that is unhappy.  I suspect I'm running into an OS-level
resource limit.

I'm working with an Intel Phi machine running CentOS that reports 256
cores. It is built using the Intel Xeon Phi 7210, which suggests that it
has four, 64-core processors. I compiled Racket from source, but I don't
think that makes a difference here.

I've parallelized some code using places, and seem to be OK when (<
num-places 96). I've used channels (synchronous and asynchronous in places,
as well as two, semaphore-protected queues) internally for the queen bee
process. I have around N:M places-to-threads in the queen, and my code is
not *intentionally* non-deterministic.

The worker bees process messages in-and-out on their place-channels. Each
worker holds 2 connections to two databases. (I'm wondering if compiled
.zos of libraries are counting towards the number of open files each place
holds on to...)

When I run with 64 places, things are OK. When I run with 96 places, things
seem OK (code runs to completion). When I run with 128 places, things are
not OK.

My current best guess is that I'm running into a max number of allowed open
file descriptors. I don't have root on the system, so I can't easily change
this, but I thought I'd throw this to the list, and see if anyone has any
further thoughts as to what I might look for. Given that it takes a while
to spin up all 128 of the places, I suspect things look like they're
running fine... until enough of the places spin up, I run out of
descriptors (I suspect), and then all kinds of badness begins.

[mjadud@phi data]$ ulimit -Ha

core file size  (blocks, -c) unlimited

data seg size   (kbytes, -d) unlimited

scheduling priority (-e) 0

file size   (blocks, -f) unlimited

pending signals (-i) 385394

max locked memory   (kbytes, -l) 64

max memory size (kbytes, -m) unlimited

open files  (-n) 4096

pipe size(512 bytes, -p) 8

POSIX message queues (bytes, -q) 819200

real-time priority  (-r) 0

stack size  (kbytes, -s) unlimited

cpu time   (seconds, -t) unlimited

max user processes  (-u) 385394

virtual memory  (kbytes, -v) unlimited

file locks  (-x) unlimited

[mjadud@phi data]$ ulimit -Sn

1024

When running with 96 places:
...

[mjadud@phi data]$ ls -l /proc/$(pidof racket)/fd | wc -l

873

# This is a steady state.


Keeping an eye on things when running with 128 places:
...

[mjadud@phi data]$ ls -l /proc/$(pidof racket)/fd | wc -l

983

[mjadud@phi data]$ ls -l /proc/$(pidof racket)/fd | wc -l

999


# 

Re: [racket-users] Student code metrics

2018-05-13 Thread Matt Jadud
Hi Stephen,

I'd look at work by Andy Ko and his students, the PLT group has some work
in the broad sphere of this space (not quite gamification, I don't think,
but definitely work around how novices approach programming), the ACM ICER
conference, and a smattering of things that appear in ACM SIGCSE. (Both
ICER and SIGCSE assume ACM digital library access, although you can often
find copies of papers floating around.) There's also the ACM journal TOCE,
and some things in CSE, off the top of my head. All of those spaces should
have publications you can look at around the analysis of student code,
gamification, and a number of related spaces.

Stephen Edwards did a pretty comprehensive analysis of student work in Java
submitted via Web-CAT back in... '09? As Matthias said, it shows (amongst
other things) that students start their homework at the last minute.
There's current work to look at ways to shape behavior, both in terms of
providing positive reinforcement as well as attempting to game students to
begin sooner, but it's early days on that work (as far as I know).

If you continue to not find things, give a shout, and I can try and help
you find starting points for chasing literature.

Cheers,
Matt


On Sun, May 13, 2018 at 4:36 PM, Stephen Foster 
wrote:

> Hi!
>
> I was about to start building a tool for statically analyzing student
> code.  But I first want to ask if there's related work out there.
>
> I'm interested in relatively simple stuff -- e.g. How many functions did
> the student write?  How many expressions?  What's the average nesting depth
> of expressions?  Etc.  Basically, I want to start quantifying things about
> students' coding styles -- both to identify potential problems and also to
> help students set goals (e.g. "Today, you wrote 2 functions.  Tomorrow, I
> want you to try to write 3!").
>
> Before I start writing this myself, is there anything that I should know
> about?  Has someone already done exactly this?  Or is there some library
> for static analysis or code metrics that I should be building upon?  I
> searched a bit and couldn't find a lot.  Maybe I'm using the wrong keywords.
>
> --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.
> 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] Is it possible to cross-compile Racket?

2018-01-26 Thread Matt Jadud
I've wondered this many times, and never investigated it.

Thank you both for the question and answer.

On Fri, Jan 26, 2018 at 8:19 AM, Matthew Flatt  wrote:

> At Fri, 26 Jan 2018 04:40:44 -0800 (PST), Leff Ivanov wrote:
> > Is it possible for example running DrRacket on Windows to generate
> > standalone native executables for Mac OSX and some generic Linux
> > distribution?
>

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


[racket-users] Re: raco pkg install under Docker...

2018-01-14 Thread Matt Jadud
Hi all,

I'm starting to think I don't need to install "json" because it's already
there.

There are days...

Cheers,
Matt


On Sun, Jan 14, 2018 at 5:50 PM, Matt Jadud <m...@jadud.com> wrote:

> Hi all,
>
> I thought it would be fun to take something straight forward and make it
> more complex.
>
> RUN yes | raco pkg install json
>
>
> yields the excitement below. I'm starting with Firth's Dockerfile/image,
> but I don't think that's the critical piece. This is against version 6.11,
> which might be. I get the same results whether I'm using a minimal download
> or the full racket download.
>
>
> This is, of course, the first thing I've really tried to do with Docker.
> Why start simple?
>
>
> If anyone has any thoughts, they'd be appreciated.
>
>
> Many thanks,
> Matt
>
>
> ---> Running in 6fe5fc394ca2
>
> Resolving "json" via https://download.racket-lang.
> org/releases/6.11/catalog/
>
> Resolving "json" via https://pkg-build.racket-lang.
> org/server/built/catalog/
>
> package-catalog-lookup: error from server
>
>   URL: https://pkg-build.racket-lang.org/server/built/catalog/pkg/
> json?version=6.11
>
>   status code: 403
>
>   context...:
>
>/usr/share/racket/collects/pkg/private/network.rkt:59:3
>
>/usr/share/racket/collects/pkg/private/catalog.rkt:218:0:
> read-from-server
>
>/usr/share/racket/collects/pkg/private/catalog.rkt:138:9: for-loop
>
>/usr/share/racket/collects/pkg/private/catalog.rkt:135:2:
> lookup-normally
>
>/usr/share/racket/collects/pkg/private/../../racket/
> private/more-scheme.rkt:261:28
>
>/usr/share/racket/collects/pkg/private/prefetch.rkt:128:2
>
>/usr/share/racket/collects/pkg/private/catalog.rkt:132:0:
> package-catalog-lookup9
>
>/usr/share/racket/collects/pkg/private/catalog.rkt:200:0:
> package-catalog-lookup-source19
>
>/usr/share/racket/collects/pkg/private/clone-path.rkt:370:0:
> desc->repo8
>
>/usr/share/racket/collects/pkg/private/clone-path.rkt:64:2:
> add-repo-desc35
>
>/usr/share/racket/collects/pkg/private/clone-path.rkt:45:0:
> adjust-to-normalize-repos
>
>/usr/share/racket/collects/pkg/private/install.rkt:911:3
>
>/usr/share/racket/collects/racket/contract/private/arrow-
> val-first.rkt:397:3
>
>/usr/share/racket/collects/racket/file.rkt:378:8
>
>/usr/share/racket/collects/racket/file.rkt:334:2: loop
>
>/usr/share/racket/collects/pkg/main.rkt:203:16
>
>
>
>

-- 
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] raco pkg install under Docker...

2018-01-14 Thread Matt Jadud
Hi all,

I thought it would be fun to take something straight forward and make it
more complex.

RUN yes | raco pkg install json


yields the excitement below. I'm starting with Firth's Dockerfile/image,
but I don't think that's the critical piece. This is against version 6.11,
which might be. I get the same results whether I'm using a minimal download
or the full racket download.


This is, of course, the first thing I've really tried to do with Docker.
Why start simple?


If anyone has any thoughts, they'd be appreciated.


Many thanks,
Matt


---> Running in 6fe5fc394ca2

Resolving "json" via https://download.racket-lang.org/releases/6.11/catalog/

Resolving "json" via https://pkg-build.racket-lang.org/server/built/catalog/

package-catalog-lookup: error from server

  URL:
https://pkg-build.racket-lang.org/server/built/catalog/pkg/json?version=6.11

  status code: 403

  context...:

   /usr/share/racket/collects/pkg/private/network.rkt:59:3

   /usr/share/racket/collects/pkg/private/catalog.rkt:218:0:
read-from-server

   /usr/share/racket/collects/pkg/private/catalog.rkt:138:9: for-loop

   /usr/share/racket/collects/pkg/private/catalog.rkt:135:2: lookup-normally


/usr/share/racket/collects/pkg/private/../../racket/private/more-scheme.rkt:261:28

   /usr/share/racket/collects/pkg/private/prefetch.rkt:128:2

   /usr/share/racket/collects/pkg/private/catalog.rkt:132:0:
package-catalog-lookup9

   /usr/share/racket/collects/pkg/private/catalog.rkt:200:0:
package-catalog-lookup-source19

   /usr/share/racket/collects/pkg/private/clone-path.rkt:370:0: desc->repo8

   /usr/share/racket/collects/pkg/private/clone-path.rkt:64:2:
add-repo-desc35

   /usr/share/racket/collects/pkg/private/clone-path.rkt:45:0:
adjust-to-normalize-repos

   /usr/share/racket/collects/pkg/private/install.rkt:911:3


/usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:397:3

   /usr/share/racket/collects/racket/file.rkt:378:8

   /usr/share/racket/collects/racket/file.rkt:334:2: loop

   /usr/share/racket/collects/pkg/main.rkt:203:16

-- 
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 right way to generate HTML from the web server?

2018-01-04 Thread Matt Jadud
Many thanks for all of the responses. I have no fear of the parentheses,
and will likely end up with a number of wrappers like you describe,
Phillip. I hadn't (yet) twigged to possibly wrapping things up in a CDATA
section, but that makes sense.

Now if we just had a Racket library that shoveled snow...

On Thu, Jan 4, 2018 at 2:07 PM, Philip McGrath 
wrote:

> FWIW, I use `response/xexpr` in production with a `#:preamble` of `#" html>\n"`, and I haven't run into problems.
>
> The biggest non-obvious thing, since I see you're generating a script
> element, is that `response/xexpr` (and the underlying `xexpr->string`/`
> write-xexpr`) properly escape < and & in body strings. This is a huge win
> in preventing injection/cross-site scripting, but HTML expects inline
> script and style elements not to be escaped. You can achieve this by
> replacing
> `(script ([type "text/javascript"]) ,(generate-some-javascript))
> with
> `(script ([type "text/javascript"]) ,(make-cdata #f #f
> (generate-some-javascript)))
>
> (If you want to go beyond that and respect the cdata-ness of the cdata,
> there are tricks for both CSS and JavaScript to put the 

[racket-users] What is the right way to generate HTML from the web server?

2018-01-04 Thread Matt Jadud
Hi all,

I read through this issue:

https://github.com/racket/racket/issues/577

and am in the "what is going on?" category of user when it comes to HTML
generation in Racket. What should I be using to generate responses from a
servlet? response/xexpr? Does that generate HTML I can use practically? Or,
doesn't it?

I've spent a lot of time in the last few days chasing the generation of
TOTP URIs for use with apps like Authy/FreeOTP/etc. I finally realized that
I'm passing strings like

otpauth://totp/
handin:astud...@foo.edu?secret=NODOFamp;issuer=handinamp;algorithm=SHA1amp;digits=6amp;period=30

to the Javascript layer for QR encoding. This looks bad to me.

What is the best way to generate HTML from the webserver? I don't care
about XML vs. HTML; I just want the fastest path to writing a small web
application that solves a problem that I have, and part of that means
easily generating HTML that does what I expect when I generate it. That is,

   (body
(div ((id "QRCODE")))
(script ((type "text/javascript"))
,(format "new
QRCode(document.getElementById('QRCODE'), '~a');"
 (generate-otp-uri email secret)

seems not to do what I expect, which in this case is causing some rather
subtle challenges to chase down. ("Why does my test for TOTP encoding pass
*here*, and generate numbers that match *this* app when I enter data by
hand, but fail in the same app when I read the QR code that I generated...")

Pointers to relevant documentation appreciated.

Cheers,
Matt

-- 
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: Product and Vendor ID?

2017-10-16 Thread Matt Jadud
Many thanks Alex, Neil.

I was looking at libusb, and was hoping-beyond-hope that there might be a
secret, Racket-native solution that I had never heard of or encountered.

I'll be back when I'm confused as to where to put the native libs for
building a stand-alone app for distribution on multiple platforms. But,
I'll give it a go before asking that question. 'raco' has lots of
options... one probably does what I want.

Cheers,
Matt

-- 
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] Product and Vendor ID?

2017-10-15 Thread Matt Jadud
Hi all,

Any ideas on how to portably get the product and vendor ID for USB devices
in a Racket app?

Long-and-short, I'd like to be able to find a micro:bit when plugged in, so
I can open a serial port and talk to the MicroPython REPL.

Many thanks,
Matt

-- 
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] RacketCon Code of Conduct

2017-06-18 Thread Matt Jadud
I'm with Claire 100%.

I think the code of conduct proposed as a starting point is completely
reasonable.

So, "+1."

Cheers,
Matt

On Sun, Jun 18, 2017 at 12:07 PM, claire alvis 
wrote:

> On Saturday, June 17, 2017 at 2:53:23 PM UTC-4, Matthias Felleisen wrote:
> > A code of conduct is a totally stupid idea for RacketCon. Racketeers
> were raised properly by their parents and are well behaved. I really hate
> attending conferences that need to impose a code.
>

-- 
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] Preventing browser frame from terminating evaluation thread?

2017-04-17 Thread Matt Jadud
Hi all,

I would like to spawn a browser frame, but I'd like it if the frame did not 
terminate the thread when I close it. I'm having a hard time figuring out what 
I should override/augment or catch so that I can spawn the frame from within a 
GUI application, let the user close the frame, and not have the whole 
application terminate.

Cheers,
Matt

#lang racket

(require browser)

(define really-hyper-frame%
  (class hyper-frame%

(super-new)

(define (on-close)
  (printf "Closing!")
  ;; But, how do I prevent the evaluation thread
  ;; from terminating? For example, if I want to launch
  ;; a browser frame from interactions in a GUI application?
  )
(augment on-close)
))

;; I'm aware the example is from the module level, but the same issue applies 
if 
;; I create the frame as a result of, say, a button% click.
(new really-hyper-frame%
 [label "The Frame"]
 [start-url "https://racket-lang.org/;])

-- 
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] Has anyone generated Open Office or Google Docs from scribble source?

2016-09-20 Thread Matt Jadud
Hi Kathi,

PrinceXML makes pretty PDFs of the output Scribble documentation.

I downloaded it, installed it, pointed it at a Scribbled page, and the PDF
was nice; links were preserved, mostly.

prince https://docs.racket-lang.org/scribble/ -o scribble.pdf
I don't know if PDFs will work for your user(s)? I know it's not what you
asked for...

Cheers,
Matt


On Tue, Sep 20, 2016 at 6:54 AM, Kathi Fisler  wrote:

> We have a bunch of exercise handouts (for Bootstrap) in scribble format,
> and users who want them as editable Google Docs (for distribution within
> their school's LMS).  Does anyone have a backend for scribble docs that
> produces a format that can upload as an editable Gdoc?  It looks like
> OpenOffice has an xml format, for example, which I suspect scribble could
> target (at least in theory).
>
> thanks,
> Kathi
>
> --
> 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] Routing syntax

2016-04-04 Thread Matt Jadud
Hi Brian,

This looks similar to what "dispatch" does?

https://docs.racket-lang.org/web-server/dispatch.html

I've never extended the bi-directional patterns that are available, but
there is an extension mechanism built in, so that your #:when notions might
be part of an extended/new url component matcher?

Cheers,
M



On Mon, Apr 4, 2016 at 2:08 PM, Brian Adkins  wrote:

> I've been looking into an appropriate syntax for routing web requests. For
> each route, I'll need the following information:
>
> * URL Pattern (required) e.g.
>   "/"
>   "/:org_shortname/product_image/:style/:filename"
>   "/:org_shortname/products/(*id).json"
>
> * Function to handle request (required)
>
> * Accepted HTTP verbs (optional, defaults ot all)
>
> * Name (optional) - used to do "reverse routing" i.e. produce a URL from
> parameters
>
> * Contraints (optional) - further refine the pattern matching e.g.
> type/format of params
>
> Here's an example from Rails:
>
> Foo::Application.routes.draw do
>   match "/:org_shortname/product_image/:style/:filename" =>
> 'product_images#product_image',
> :as => :product_image, :via => :get, :constraints => { :filename =>
> /.jpg$/ }
>
>   # URL pattern: "/:org_shortname/product_image/:style/:filename"
>   # Function: ProductImagesController.product_image
>   # Name: :product_image
>   # Verbs: GET
>   # Contraints: filename param must end in .jpg
>
>   match '/products/(*id).json'  => 'products#show', :via => :get
>
>   # URL pattern: '/products/(*id).json'
>   #(*id) globs everything between /products/ and .json including /
> chars
>   # Function: ProductsController.show
>   # Verbs: GET
> end
>
> There are many other aspects (much of which is just syntax sugar) of
> routing in Rails that I'm ignoring initially.
>
> I'm thinking of something like the following:
>
> (routes
>   ("/" home-page)
>   ("/:org_shortname/product_image/:style/:filename" product-image #:verbs
> (get)
>#:name prod-image #:when (regexp-match #rx".jpg$" filename))
>   ("/products/(*id).json" product-show #:verbs (get)))
>
> The first two arguments (url-pattern function) are required, so they're
> positional. The optional arguments are specified with keywords.
>
> Instead of:  #:verbs (get)would it be better to have  #:verbs get  and
> dynamically check for an atom vs. list ?
>
> My initial goal is just for the "base" syntax. Sugar can be added later
> for some cases.
>
>  Any feedback is appreciated.
>
> 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] preserve objects created in REPL after adding/changing proc definitions?

2016-02-16 Thread Matt Jadud
On Mon, Feb 15, 2016 at 1:39 PM, Neil Van Dyke  wrote:

> Fred Martin wrote on 02/15/2016 12:21 PM:
>
>> https://docs.racket-lang.org/reference/serialization.html, which allowed
>> me to save my object in my definitions buffer along Neil's suggestion. :)
>>
>
> Be aware that the serialize format is Racket-version-specific, so
> implications for serialized values pasted into files.
>

Just to clarify/get clarification:

Serialized data does carry a version tag, but it does not seem to be pegged
to the Racket version that created the structure. The FASL  format IS very
much tied to the Racket version. Serialize seems, essentially, a very
verbose, readable format.

At least, that has been my experience with serialize/FASL, and what I seem
to get from the documentation. But, I want to make sure I'm not confused.

Cheers,
Matt

-- 
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] Anybody done some "Internet of Things" stuff with Racket?

2015-11-10 Thread Matt Jadud
Hi Daniel,

I have the start of an MQTT client laying around, but it's pretty
ugly. It was basically me poking around and exploring the protocol.

https://github.com/concurrency/plumb2/blob/master/mqtt.rkt
https://github.com/concurrency/plumb2/blob/master/mqttest.rkt

It's lying in the middle of a pile of other mess, which can be safely
disregarded.

Although the file isn't marked, you can take the LICENSE file in that
repo to be authoritative, making it MIT. Ask me questions as you see
fit, but again, I was exploring multiple ideas as I worked my way
through the protocol implementation. (Mostly, I was having fun with
Tony's bitsyntax library.

Cheers,
Matt


On Tue, Nov 10, 2015 at 6:13 AM, Daniel Brunner  wrote:
> Hi,
>
> has anybody done some "Internet of Things" stuff with Racket? I am
> looking for some applications which use e.g. MQTT[*] either as a broker
> or client and I couldn't find anything on the internet or in the group.
> Any help or suggestions would be nice.
>
> Best wishes,
> Daniel
>
> [*] https://en.wikipedia.org/wiki/MQTT
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


[racket-users] Re: Loading a 1.2GB serialized file

2015-04-13 Thread Matt Jadud
And, I've answered my own question.

I really wouldn't want the ensuing thrashing, even if I could load the data
on a machine with insufficient RAM; I dropped $1 and picked up a VM for
long enough to load Racket, load the data, and do what needed to be done. I
needed around 20GB all told.

I'm sure there's something in HtDP about thinking about your data in
advance and whatnot... :D

Cheers,
Matt

On Sat, Apr 11, 2015 at 2:53 PM, Matt Jadud m...@jadud.com wrote:


 2a. Fire up an Amazon VM with 60+GB of RAM, and see if that lets me run my
 analysis.



-- 
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] Loading a 1.2GB serialized file

2015-04-13 Thread Matt Jadud
Hi all,

I have a slight problem. While running some data analysis, I decided to
cache some hash tables to disk. I started by using FASL, but found that it
was fragile between versions of Racket. For example, I have v6 in one place
and v6.1.1 in another... and, I can't afford to have these cached versions
not have *some* persistent value, in as much as I am working across desktop
Macs and server Linux machines with the same scripts, which are slightly
out-of-sync in Racket versions.

So, I just used straight serialize. This was OK for reasonable amounts of
data, but I forgot that I might be dealing with unreasonable amounts of
data. I am now dealing with a file that is 1.2GB in size, and contains a
hash with many keys, each of which contains a fair bit of data in the form
of additional hashes, lists, and strings. My goal, ultimately, would be to
read this file in and run my analysis.

As I attempt to run an analysis now (which involves loading the serialized
data as-is), I get the following:

Couldn't allocate memory: (os/kern) no space available
Abort trap: 6

As far as I know (which isn't very far), this is coming from the OS, not
Racket. I'm running a 10.9 machine with 16GB of RAM that is, generally,
doing a bunch of desktop-machine kinds of things (as opposed to a
stripped-down Linux server).

My thoughts at this point:

1. Hope Matthew Flatt has a magic incantation up his sleeve.

2a. Fire up an Amazon VM with 60+GB of RAM, and see if that lets me run my
analysis.

2b. Generally find access to a machine with a lot more RAM than I have in
any of my machines at the moment.

3. Wish I had stored my data differently.

I can, if need be, modify the storage format and do something that is more
RAM-friendly (allowing for sequential, element-by-element load-and-analyze
from cached local data). The database I'm working against is large enough
that my initial query can sometimes take a while to run  (days), and I'm
not excited about going back to that stage for this particular query. I
will, as necessary. And, of course, my SQL-fu may be weak, but I'm dealing
with tables that are larger than my typical experience
(tens-to-hundreds-of-millions of elements), and I have to do one join and a
bit of filtering, which slows things down, even when indexed.

Racket seemed to be happy to build the hash table in the first place (see
#3), but loading it back is currently my stumbling block.

Ah, adventures with somewhat large data.

Cheers,
Matt

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