[racket-users] Re: Pict and pict types

2020-11-24 Thread Alex Harsanyi
This is a known issue:  plot-pict does not return a typed/pict type · Issue 
#15 · racket/plot (github.com)   

Alex.
On Tuesday, November 24, 2020 at 7:24:17 PM UTC+8 tim wrote:

> Hi everyone,
>
> In typed racket, vc-append expects arguments of type pict, while plot-pict 
> produces results of type Pict. Therefore, to have vc-append accept a 
> plot-pict argument, I’m currently casting the result of plot-pict to be 
> of type pict.
>
> From my understanding of the underlying racket code, Pict just invokes a 
> pict? predicate through an #opaque definition, and cast inserts a runtime 
> test of its argument. Therefore, my cast seems wasteful. Have I missed 
> something? Is there a better way to structure a solution that type-checks?
>
> Here’s some code that type-checks for me:
>
> #lang typed/racket
>
> (require plot
>  pict)
>
> (vc-append (cast (plot-pict (function sin 0 1))
>  pict))
>
>
> and the output is a graph, as expected.
>
> Here’s some that fails a type-check:
>
> #lang typed/racket
>
> (require plot
>  pict)
>
> (vc-append (plot-pict (function sin 0 1)))
>
>
> Error output:
>
> ;  plot-pict-test.rkt:6:11: Type Checker: type mismatch
> ;   expected: pict
> ;   given: Pict
> ;   in: (plot-pict (function sin 0 1))
> ; Context (plain; to see better errortrace context, re-run with C-u 
> prefix):
> ;   
> /Applications/Racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:376:0
>  
> type-check
> ;   
> /Applications/Racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:619:0
>  
> tc-module
> ;   
> /Applications/Racket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:96:12
> ;   
> /Applications/Racket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:23:4
>
> I get the same results whether I require pict or typed/pict.
>
> I hope this question is of general interest. I have some familiarity with 
> regular racket, but I’m only just starting out on typed racket. 
>
> Best,
>
>
>
> Tim
>
>

-- 
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/91d1094d-fe0a-46a9-9fc7-21355dea7163n%40googlegroups.com.


[racket-users] Re: EDIT: Building a rectangle builder: trailing rectangle bug.

2020-11-23 Thread Alex Harsanyi
The snip selection and resize is handled by the pasteboard 
on-default-event, and it looks like your code also handles events, 
resulting in duplicate handling.   There is no clear solution to this, as 
the system does not know if you want to select snips or draw rectangles.  
 However, you could use Ctrl + drag to draw the rectangles.  To do that, 
move your own code into a new method, say "my-on-default-event" and call 
that method for mouse events which have the control key set.

 (define/override (on-default-event event)
   (if (send event get-control-down)
   (on-default-event-1 event)
   (super on-default-event event)))

The disadvantage now, is that there is no visual feedback when you use Ctrl 
+ drag (previously, the selection rectangle was drawn).  To draw an 
intermediate selection rectangle, you can track mouse motion events in your 
"my-on-default-event" and keep the intermediate rectangle, same as you do 
for "start-pos", than override the "on-paint" method of the pasteboard to 
draw the intermediate rectangle.  Note that you cannot call on-paint 
directly from on-default-event, and the pasteboard does not know it needs 
to redraw itself unless you call "refresh".

Alex.

On Monday, November 23, 2020 at 7:49:00 PM UTC+8 kokou.a...@gmail.com wrote:

>
>
>
>
> *please, disregard the previous email, there was a little bug. this is the 
> correct code. the issue still exists. *
>
> I can click to drag in order to draw a rectangle, but when i drag the 
> created rectangle (for position adjustment), a new rectangle is created 
> from the said position. How do i constrain/fix the issue? i have been 
> trying to use key-combination to draw a new rectangle on demand. How do i 
> fix it ? 
>
> ```
> #lang racket/gui
>
> (define (maybe-set-box! b v)
>   (when b
> (set-box! b v)))
>
>
>
> (define rect-snip-class%
>   (class snip-class%
> (inherit set-classname)
> (super-new)
>
> (set-classname "rect-snip-class%")
> ))
>
>
> (define rect-snip-class (new rect-snip-class%))
>
> (define rect-snip%
>   (class snip%
> (inherit set-snipclass
>  set-flags get-flags
>  get-admin)
> (init w h)
> (super-new)
> (set-snipclass rect-snip-class)
> (define height h)
> (define width w)
>
> (define/override (get-extent dc x y [w #f] [h #f] . _)
>   (maybe-set-box! w width)
>   (maybe-set-box! h height))
>
> (define/override (draw dc x y left top right bottom . _)
>   (send dc draw-rectangle x y width height))
> ))
>
>
>
> (define pb
>   (new
>(class pasteboard%
>  (super-new)
>  (inherit insert)
>
>  (define start-pos #f)
>
>  (define/override (on-default-event event)
>(super on-default-event event)
>(define x (send event get-x))
>(define y (send event get-y))
>(cond
>  [(and (equal? (send event get-event-type) 'left-down)
>(send event button-down? 'left)
>(not (send event dragging?)))
>   (set! start-pos (cons x y))]
>  [(and (equal? (send event get-event-type) 'left-up)
>start-pos)
>   (let ([dx (- (car start-pos) x)]
> [dy (- (cdr start-pos) y)])
> (define-values (nx nw)
>   (if (> dx 0)
>   (values x dx)
>   (values (+ x dx) (abs dx
> (define-values (ny nh)
>   (if (> dy 0)
>   (values y dy)
>   (values (+ y dy) (abs dy
> (define sn (new rect-snip%
> [w nw]
> [h nh]))
> (insert sn nx ny)
> (set! start-pos #f))]))
>
>
>  )))
>
> (define f-main (new frame% [label "wireframe"]))
> (define cnv-main (new editor-canvas%
>   [editor pb]
>   [parent f-main]))
>
>
> (send f-main show #t)
> ```
>
>

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


Re: [racket-users] Re: when do we use snip%, snip-class% and editor-snip%

2020-11-20 Thread Alex Harsanyi


On Friday, November 20, 2020 at 11:09:13 PM UTC+8 kokou.a...@gmail.com 
wrote:

> Thanks, I'm opening another subject meanwhile, Can you please advise? 
>
> This is my current code which displays a rectangle on a pasteboard. 
>
> I'm trying to build a wireframe designer where. I can click on a button or 
> a node on a rectangle to create either an inner rectangle/circle or another 
> standalone shape which will also contains their properties. At the end, 
> those created object will serve to generate code samples. 
>
> Can you please advise what functions or classes needed to improve on that? 
>

To respond to mouse clicks, the snip instance will need to handle mouse 
events, which means you need to (1) set the flag 'handles-events and, 
depending on your use case, 'handles-all-mouse-events and (2) override the 
`on-event` method.

Alex.
 

>
> Below is the current implementation done so far. 
>
>
> #lang racket
> (require racket/gui racket/draw pict)
>
> (define board (new pasteboard%))
> (define toplevel (new frame%
>   [label "My board"]
>   [width 500]
>   [height 500]))
> (define canvas (new editor-canvas%
> [parent toplevel]
> [editor board]))
> (send toplevel show #t)
> (define my-snip-class
>   (new (class snip-class%
>  (super-new)
>  (send this set-classname "my-snip"
> (send (get-the-snip-class-list) add my-snip-class)
> (define rectangle-snip%
>   (class snip%
> (init-field w h)
> (super-new)
> (send this set-snipclass my-snip-class)
> (define/override (get-extent dc x y width height . other)
>   (when width (set-box! width w))
>   (when height (set-box! height h)))
> (define/override (draw dc x y . other)
>   (draw-pict (rectangle w h) dc x y
>
> (send board insert (new rectangle-snip% [w 30] [h 80]) 100 300)
>
>
>
> On Fri, Nov 20, 2020 at 10:40 AM Alex Harsanyi  
> wrote:
>
>>
>>
>> On Friday, November 20, 2020 at 4:56:03 PM UTC+8 kokou.a...@gmail.com 
>> wrote:
>>
>>> please, can you provide some tutorial about this video? 
>>>https://www.youtube.com/watch?v=UKMgURA5Wg8
>>>
>>
>> This explains how the program works: 
>> https://alex-hhh.github.io/2020/06/ishido.html, there are other snip% 
>> related tutorials on that web site.
>>  
>>
>>>
>>>
>>> On Fri, Nov 20, 2020 at 5:26 AM Alex Harsanyi  
>>> wrote:
>>>
>>>> You use snips to build small interactive widgets which can be combined 
>>>> and embedded into other GUI applications.   the snip-class% is a helper 
>>>> class for building snips and editor-snip% is a type of snip which allows 
>>>> building nested editors (an editor within an editor).
>>>>
>>>> DrRacket uses snips for its editor and REPL, and supports user defined 
>>>> snips as well.  For example, in the video below, the plot is a snip% and 
>>>> so 
>>>> is the map.   Once you implement a snip, DrRacket knows how to use it when 
>>>> you show it in the REPL:
>>>>
>>>> https://www.youtube.com/watch?v=R2KU0ZvIJws
>>>>
>>>> snips can also be embedded into GUI applications, for example you can 
>>>> build a GUI window which contains a map and several plots:
>>>>
>>>> https://www.youtube.com/watch?v=OElNG3ZGgd0
>>>>
>>>> and you can also build interactive applications.  In the video below, 
>>>> each game tile is a snip% and they are managed by a pasteboard% object:
>>>>
>>>> https://www.youtube.com/watch?v=UKMgURA5Wg8
>>>>
>>>> Alex.
>>>>
>>>> On Friday, November 20, 2020 at 11:47:19 AM UTC+8 kokou.a...@gmail.com 
>>>> wrote:
>>>>
>>>>> I have been reading about those classes but i can't properly figure 
>>>>> out. 
>>>>>
>>>>> what are the main use-case of snip, snip-class and editor-snip? 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>> 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...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/racket-users/1

Re: [racket-users] Re: when do we use snip%, snip-class% and editor-snip%

2020-11-20 Thread Alex Harsanyi


On Friday, November 20, 2020 at 4:56:03 PM UTC+8 kokou.a...@gmail.com wrote:

> please, can you provide some tutorial about this video? 
>https://www.youtube.com/watch?v=UKMgURA5Wg8
>

This explains how the program 
works: https://alex-hhh.github.io/2020/06/ishido.html, there are other 
snip% related tutorials on that web site.
 

>
>
> On Fri, Nov 20, 2020 at 5:26 AM Alex Harsanyi  wrote:
>
>> You use snips to build small interactive widgets which can be combined 
>> and embedded into other GUI applications.   the snip-class% is a helper 
>> class for building snips and editor-snip% is a type of snip which allows 
>> building nested editors (an editor within an editor).
>>
>> DrRacket uses snips for its editor and REPL, and supports user defined 
>> snips as well.  For example, in the video below, the plot is a snip% and so 
>> is the map.   Once you implement a snip, DrRacket knows how to use it when 
>> you show it in the REPL:
>>
>> https://www.youtube.com/watch?v=R2KU0ZvIJws
>>
>> snips can also be embedded into GUI applications, for example you can 
>> build a GUI window which contains a map and several plots:
>>
>> https://www.youtube.com/watch?v=OElNG3ZGgd0
>>
>> and you can also build interactive applications.  In the video below, 
>> each game tile is a snip% and they are managed by a pasteboard% object:
>>
>> https://www.youtube.com/watch?v=UKMgURA5Wg8
>>
>> Alex.
>>
>> On Friday, November 20, 2020 at 11:47:19 AM UTC+8 kokou.a...@gmail.com 
>> wrote:
>>
>>> I have been reading about those classes but i can't properly figure out. 
>>>
>>> what are the main use-case of snip, snip-class and editor-snip? 
>>>
>>>
>>>
>>>
>>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/156fcba7-86b4-483b-a936-8121a0f9f397n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/156fcba7-86b4-483b-a936-8121a0f9f397n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

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


[racket-users] Re: when do we use snip%, snip-class% and editor-snip%

2020-11-19 Thread Alex Harsanyi
You use snips to build small interactive widgets which can be combined and 
embedded into other GUI applications.   the snip-class% is a helper class 
for building snips and editor-snip% is a type of snip which allows building 
nested editors (an editor within an editor).

DrRacket uses snips for its editor and REPL, and supports user defined 
snips as well.  For example, in the video below, the plot is a snip% and so 
is the map.   Once you implement a snip, DrRacket knows how to use it when 
you show it in the REPL:

https://www.youtube.com/watch?v=R2KU0ZvIJws

snips can also be embedded into GUI applications, for example you can build 
a GUI window which contains a map and several plots:

https://www.youtube.com/watch?v=OElNG3ZGgd0

and you can also build interactive applications.  In the video below, each 
game tile is a snip% and they are managed by a pasteboard% object:

https://www.youtube.com/watch?v=UKMgURA5Wg8

Alex.

On Friday, November 20, 2020 at 11:47:19 AM UTC+8 kokou.a...@gmail.com 
wrote:

> I have been reading about those classes but i can't properly figure out. 
>
> what are the main use-case of snip, snip-class and editor-snip? 
>
>
>
>
>

-- 
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/156fcba7-86b4-483b-a936-8121a0f9f397n%40googlegroups.com.


[racket-users] Re: Help implementing an early return macro

2020-10-28 Thread Alex Harsanyi
Are you looking for `let/ec`?

(let/ec return
  (define x (random 10))
  (unless (even? x)
(log-info "x wasn't even, x = ~a" x)
(return -1))
  (define y (random 10))
  (unless (even? y)
(log-info "y wasn't even, y = ~a" y)
(return -1))
  (+ x y))

Alex.

On Wednesday, October 28, 2020 at 6:54:44 PM UTC+8 jackh...@gmail.com wrote:

> So I'm a little tired of writing code like this:
>
> (define x ...)
> (cond
>   [(take-shortcut? x) (shortcut x)]
>   [else
>(define y (compute-y x))
>(cond
> [(take-other-shortcut? x y) (other-shortcut x y)]
> [else
>  (define z ...)
>  (cond ...)])])
>
> That is, I have some logic and that logic occasionally checks for 
> conditions that make the rest of the logic irrelevant, such as an empty or 
> false input or something else that should trigger an early exit. Each check 
> like this requires me to write a cond whose else clause wraps the 
> remainder of the body, leading to an awkward nesting of cond forms. I 
> don't have this issue when the early exits involve raising exceptions: in 
> those cases I can just use when and unless like so:
>
> (define x ...)
> (unless (passes-check? x) (raise ...))
> (define y ...)
> (unless (passes-other-check? x y) (raise ...))
> (define z ...)
> ...
>
> I'm aware of a few macros in the racket ecosystem that try to solve this 
> problem. For example, Jay wrote a blog post 
>  that creates a 
> condd form that's like cond but allows embedded definitions using a #:do 
> keyword. I've also seen various approaches that use escape continuations to 
> implement the early exit. There's drawbacks I'm not happy about however:
>
>- 
>
>For cond-like macros that allow embedded definitions, it looks too 
>different from regular straight-line Racket code. I like my function 
> bodies 
>to be a sequence of definitions and expressions, with minimal nesting, 
> just 
>like the when and unless version above. I don't have to use a keyword 
>or extra parentheses to signal whether a form is a definition or a when 
>/ unless check in error-raising code, why should I have to do that in 
>code that uses early returns?
>- 
>
>Continuation-based solutions impose a nontrivial performance penalty 
>and have complex semantics. I don't like that the generated code behaves 
>differently from the cond tree I would normally write. What happens if 
>I stick an early exit inside a lambda? Or a thread? What if I set up a 
>continuation barrier? Does that matter? I don't know and I don't want to 
>think about that just to write what would be a simple if (condition) { 
>return ... } block in other languages.
>
> So I wrote a basic macro for this and I have some questions about how to 
> make it more robust. The macro is called guarded-block and it looks like 
> this:
>
> (guarded-block
>   (define x (random 10))
>   (guard (even? x) else
> (log-info "x wasn't even, x = ~a" x)
> -1)
>   (define y (random 10))
>   (guard (even? y) else
> (log-info "y wasn't even, y = ~a" y)
> -1)
>   (+ x y))
>
> Each guard clause contains a condition that must be true for evaluation 
> to proceed, and if it isn't true the block takes the else branch and 
> finishes. So the above would expand into this:
>
> (block
>   (define x (random 10))
>   (cond
> [(not (even? x))
>  (log-info "x wasn't even, x = ~a" x)
>  -1]
> [else
>  (define y (random 10))
>  (cond
>[(not (even? y))
> (log-info "y wasn't even, y = ~a" y)
> -1]
>[else (+ x y)])]))
>
> This part I got working pretty easily. Where I hit problems, and where I'd 
> like some help, is trying to extend this to support two important features:
>
>- 
>
>I should be able to define macros that *expand* into guard clauses. 
>This is important because I want to implement a (guard-match  
> else  ...) form that's like match-define 
>but with an early exit if the pattern match fails. I'd also really like to 
>add a simple (guard-define   else 
> ...) form that expects option-expression to produce an 
>option 
>
> 
>  
>(a value that is either (present v) or absent) and tries to unwrap it, 
>like the guard let construct in Swift 
>.
>- 
>
>Begin splicing. The begin form should splice guard statements into the 
>surrounding body. This is really an offshoot of the first requirement, 
>since implementing macros that expand to guard can involve expanding 
>into code like (begin (define some-temp-value ...) (guard ...) (define 
>some-result ...)).
>
> Having been around the Racket macro block before, I know I need to do some 
> kind of partial expansion here. But honestly I can't 

Re: [racket-users] Why is get-impure-port* slower than a system call to curl?

2020-09-16 Thread Alex Harsanyi


On Thursday, September 17, 2020 at 7:54:23 AM UTC+8 gneuner2 wrote:

>
> That's true - Windows tries IPv6 first 


Windows does not try IPv6 first.

Client applications that call `getaddrinfo` with `AF_UNSPEC` , ask for both 
IPv4 and IPv6 addresses when resolving names.  When that happens, the 
resolver library (maybe on Windows only?) returns a list of IP addresses 
for that name, but puts IPv6 addresses first.  The code than tries to 
connect to addresses in the order they are returned, meaning they try IPv6 
first.  If client applications would specify AF_INET instead for their 
`getaddrinfo` call, they would only get IPv4 addresses, but my 
understanding is that AF_UNSPEC is the recommended flag for new 
applications, and I think Racket is using it.

I am not sure how things work on Linux with respect to address resolution, 
but on my windows machine, "ping localhost" receives responses from "::1" 
while on my RaspberryPi it receives responses from "127.0.0.1", even though 
I have the "::1" address for localhost as well.   Strangely, it even 
responds from 127.0.0.1 when I ping "ip6-localhost" which is only listed as 
"::1" in my /etc/hosts file.

Alex.
 

> - but it isn't the whole story 
> here.  If IPv6 were the only cause, then disabling IPv6 should fix the 
> problem ... but it doesn't always fix the problem.  On some Windows 
> machines, name resolution by the local DNS client is just painfully slow 
> [and no one knows exactly why]. 
>
> Certainly Stephen should try either binding the server to ::1 or 
> disabling IPv6 altogether ... but it's possible that neither of these 
> options may solve his problem. 
>
> 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/5c5e6d88-cbf0-4c15-b73a-9f9c4958b42an%40googlegroups.com.


Re: [racket-users] Why is get-impure-port* slower than a system call to curl?

2020-09-16 Thread Alex Harsanyi
On Windows at least, "localhost" resolves to two IP addresses (in this 
order): "::1" (IPv6) and "127.0.0.1".  The Racket `tcp-connect` function 
will try the fist one first, and since you probably don't bind your web 
server to the IPv6 address, the connection times out, than `tcp-connect` 
tries the IPv4 one and succeeds.  This is  why using "localhost" is slower 
than using "127.0.0.1".   

I know this because I have been caught by it as well :-)  My solution was 
to learn IpV6 and start my server on IPv6 :-)

 Perhaps curl and Chrome go straight for the IPv4 address.

As a test, try starting your web server on an IPv6 address (::1) and see if 
things improve.

Alex.

On Wednesday, September 16, 2020 at 11:14:29 PM UTC+8 Stephen Foster wrote:

> Thanks everyone.  We resolved the issue over on the http-easy package: 
> https://github.com/Bogdanp/racket-http-easy/issues/6
>
> I'll summarize for the curious:
>
> Turns out it's largely a "my system thing": requests to "localhost" are 
> slow, but 127.0.0.1 are fast.  On Chrome and curl, both were fast, which is 
> why I assumed the slowdown was in some Racket package.  It's more likely a 
> DNS issue.  (I have to use an unfamiliar Windows machine for game 
> development; there's probably something misconfigured about the DNS.)
>
> In any event, my original problem is solved: I can use Racket's packages 
> and send requests to 127.0.0.1, and the spellcasting experience in 
> CodeSpells is super-snappy now.
>
> Thanks again, everyone!  And thanks Bogdan -- both for the help, and for 
> the http-easy package.  :)
>
> On Mon, Sep 14, 2020 at 3:42 PM Sam Phillips  wrote:
>
>> Hi Stephen,
>>
>> I ran this small benchmark against a remote web server, and was
>> definitely getting better response using the http-easy module.
>>
>> https://gist.github.com/samdphillips/32763ebd0d938678c2972b1dd8ee5778
>>
>> $ racket -e '(require (submod "http-perf.rkt" curl))'
>> cpu time: 768 real time: 35299 gc time: 0
>>
>> $ racket -e '(require (submod "http-perf.rkt" http-easy))'
>> cpu time: 1810 real time: 17316 gc time: 70
>>
>> On Mon, Sep 14, 2020 at 12:57 PM Stephen Foster  
>> wrote:
>> >
>> > Finally circling back to this issue.  I've disabled debugging in 
>> DrRacket and also done a test outside of DrRacket.  It's still slow. :(
>> >
>> > I also tried the newer HTTP client: 
>> https://docs.racket-lang.org/http-easy/index.html.  Like the others, it 
>> is also slow.
>> >
>> > I'll do some more digging.  I'm currently trying to figure out if this 
>> is a "just me" / "just my system" problem.  So... I'd be grateful if anyone 
>> who has written code that sends HTTP requests from Racket could chime in 
>> with: 1) I can confirm that sending HTTP requests from Racket has always 
>> been fast for me, or 2) I too have noticed Racket HTTP requests are slow.
>> >
>> > (Note that by "slow", I mean: takes noticeably longer than curl.)
>> >
>> >
>> >
>> > On Tue, Jul 7, 2020 at 12:21 PM Jon Zeppieri  wrote:
>> >>
>> >> Hi Stephen,
>> >>
>> >> Your video shows you running this code in DrRacket with debugging
>> >> enabled. That usually affects performance. Have you made measurements
>> >> when running this code outside of DrRacket?
>> >>
>> >> - Jon
>> >>
>> >>
>> >> On Tue, Jul 7, 2020 at 2:13 PM Stephen Foster  
>> wrote:
>> >> >
>> >> > I'm considering using Racket to remake my 3D game CodeSpells.  I'm 
>> using http requests to have Unreal Engine and Racket talk to each other.
>> >> >
>> >> > When I use the http/request library, Racket fires off its GET 
>> request much slower than if it were to do a system call to curl.  (Same is 
>> true if I use simple-http, which makes me think the problem might be a deep 
>> one.)
>> >> >
>> >> > Here's a video to demo the issue.  Notice how, with curl, the 
>> experience is playable, whereas with the Racket function, there's way too 
>> much time between the spell landing and the effect occurring:
>> >> >
>> >> > https://youtu.be/jTqUFVlfBFA
>> >> >
>> >> > Obviously, I'd like to do things in a Rackety way.  But I'm not 
>> above doing things the silly way.  I'd just be grumpy about it.
>> >> >
>> >> > Any ideas?
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > 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...@googlegroups.com.
>> >> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/997693d6-b94a-4f69-85cf-aa475c807b20n%40googlegroups.com
>> .
>> >
>> >
>> >
>> > --
>> >
>> >
>> > Stephen Foster
>> > ThoughtSTEM Co-Founder
>> > 318-792-2035 <(318)%20792-2035>
>> >
>> > --
>> > 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...@googlegroups.com.
>> > To view this discussion on the web 

Re: [racket-users] Re: Application Templates!

2020-08-20 Thread Alex Harsanyi


On Thursday, August 20, 2020 at 9:11:45 PM UTC+8 hen...@topoi.pooq.com 
wrote:

> On Wed, Aug 19, 2020 at 09:33:01PM -0700, Alex Harsanyi wrote: 
> ... 
> ... 
> > I think Racket would benefit by a suite of applications which are small 
> but 
> > not trivial and with a source code which is commented in more detail 
> than a 
> > regular application. 
>
> Every regular application would also benefit from being commented in 
> this much detail. 


Whenever you write a comment, you usually have an intended reader in mind 
(this happens even if you are not conscious about it).  For a comment in an 
application code base, the intended readers are the application developers, 
so you tend to assume that they already know (1) the language constructs 
and conventions, (2) the problem domain and (3) the application 
architecture.  Such a comment would be useless to someone who is trying to 
learn the programming language or learn the application architecture.

Than, there is the question of effort required to write these comments.  It 
took me significantly longer to write the programs that I linked to, 
because I wanted to structure them in ways that are easier to understand by 
a broader set of users,  Still, I did not explain what `define` or function 
application is, so I left out the absolute beginners.For small programs 
and blog posts, this is workable, for larger programs I don't think it is 
-- this is why introductory material at various expertise levels is still 
needed.

Alex.


> -- hendrik 
>

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


[racket-users] Re: Application Templates!

2020-08-19 Thread Alex Harsanyi
I am not sure that a template in the style of "dotnet new" is directly 
applicable for Racket --  the .Net framework is, well a framework. which is 
a library that expects the users to structure their own programs in certain 
ways.  The templates fill the need of setting up the boilerplate code for 
different kind of applications as required by the .Net framework.  Racket 
applications don't need large amounts of "setup code", most of the code is 
very specific to the application itself, so not sure what a template would 
contain apart from very basic things.

I think Racket would benefit by a suite of applications which are small but 
not trivial and with a source code which is commented in more detail than a 
regular application.  I attempted to do this with my blog posts, some of 
which describe more-or-less complete applications (most of them games). The 
entire source code is in a single file which can be run directly and is 
available as a GitHub Gist linked from the blog posts.

Here are some examples:

* ishido game (936 lines):  
https://gist.github.com/alex-hhh/2e204b3a9d9d7094f65a0b585d0b7480 
* tetris game (893 
lines): https://gist.github.com/alex-hhh/2233aee39852f4e0aead4af4cafb40d5
* chess board (893 lines): 
https://gist.github.com/alex-hhh/4817c4d0353e40b72108e7e753c3d0da
* password generator GUI (346 lines): 
https://gist.github.com/alex-hhh/6acbbb8ebca47c4cfaa2540499494af6
* password generator, command line (142 lines): 
https://gist.github.com/alex-hhh/27286f4609ea0c989675e5c946ca39de

These are of course not templates, but they could serve as the starting 
points for users who already have some experience with programming and want 
to try out some more complex programs.

Alex.

On Thursday, August 20, 2020 at 5:49:37 AM UTC+8 Stephen De Gabrielle wrote:

> I’ve started a small collection!
>
> https://github.com/racket-templates
>
> These are GitHub templates so you use them by clicking ‘use this template‘ 
> on the repo
>
> I’m looking for more ideas/contributions;
> From the top of my head;
> - ‘worker service’ (dotnet new has this)
> - DrRacket plugin
> - Keybinding package
> - Teachpack
> - raco command
> - scribble (multiple)
> - pollen (multiple)
> - slideshow
> - racket embedded in c app
>
> Can you suggest(or submit) any others?
>
> < the reasons is to give new users another way ins>>
>
> Are language specific templates a good idea?
> - typed racket
> - datalog
> - parenlog
> - rosette
>
>
>   Thoughts suggestions criticisms appreciated!
>
> Stephen
>
> On Wed, 19 Aug 2020 at 00:02, Stephen De Gabrielle  
> wrote:
>
>> I got jealous that dot net has dotnet new with lots of templates so I 
>> made a GitHub template for a cli command 
>> https://github.com/spdegabrielle/cli-command 
>>
>> If you have an idea for a template you should make one!
>>
>> If you have a cool package that can be demonstrated as an application 
>> maybe consider a template as a way to introduce new Racketeers to your 
>> package?
>>
>> Best
>>
>> Stephen
>>
>> -- 
>> 
>>
>>
>> -- 
> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/856e1c7a-5afc-42d8-89f0-6b6fb81158d5n%40googlegroups.com.


[racket-users] Re: GUI zoom and normal-control-font

2020-08-19 Thread Alex Harsanyi
At least on Windows, users can select the text size in the Windows System 
Settings,and Racket GUI applications will use that setting.   So I can make 
the text of the GUI controls bigger or smaller by adjusting this setting.  
The Racket GUI have to be restarted though for the settings to take effect 
-- they don't react dynamically to text size changes.

Of course this is a system level setting and all applications on the 
machine will use the chosen text size.

Alex.

On Wednesday, August 19, 2020 at 12:31:42 AM UTC+8 James Platt wrote:

> I'm looking at implementing a zoom contents (not zoom window) feature in a 
> GUI with lots of elements and I'm wondering about the best way to do this. 
> Most, if not all, standard GUI widgets in Racket can be resized by changing 
> the font size of their contents or label. Then redraw the widget and you 
> have the whole thing in a new size. So zoom could be done by creating a 
> function which handles each element individually but I would like a more 
> general solution, if possible. Most widgets use the value 
> normal-control-font for their default but it doesn't look like this can be 
> changed at present. If there were a setter for normal-control-font, it 
> looks like you could have a menu item change it, then recursively get the 
> children of the frame it is attached to and redraw them. Would this 
> actually work? Is there a better way to do it?

-- 
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/33fa4a60-6c4b-4948-9288-6ae45a2d75b6n%40googlegroups.com.


[racket-users] Re: Racket GUI: text aligned to the left of other text

2020-08-10 Thread Alex Harsanyi
The simplest thing is to just use tabs.   A line of text would be 
"\tYour Message here" and an overflowing line would be "\tOverflowing 
message".  Yes, this will work for variable width fonts.

The `text%` class  has a `set-tabs` method which allows setting the tab 
stops in drawing units on the canvas, so you can override `on-display-size` 
to set the tab width to be a percentage of the display, or you can leave it 
as a fixed width.

Alex.

On Tuesday, August 11, 2020 at 3:32:41 AM UTC+8 cwebber wrote:

> Hello, 
>
> I'm building a little chat application with Racket. Overall Racket's 
> GUI tools are quite comfortable, and I'm just using Rakcet's text editor 
> stuff to build the chat. But a fairly standard thing to do with chat 
> applications is to have text like: 
>
> (Beware, fixed width ascii art ahead) 
>
> .. 
> | FooChat Deluxe [X]| 
> || 
> | File Blah | 
> || 
> |  | It's snowing outside!! | alice | 
> |  | In August | bob | 
> |  | Nevermind, the snow is a representation of | carol | 
> | | collective anxiety about the world | | 
> |  | Oh okay it is snowing then | | 
> || 
> | [Better go get some snow shoes then___] [Send] | 
> '' 
>
> The core idea there being that usernames left-align to the text. 
>
> I'm not sure what's the nicest way to do this, though I've taken a guess 
> that maybe the "Show/Hide Line Numbers" in DrRacket is the best example. 
> I'd be happy to look at that but I can't really find it in the drracket 
> repository and am not sure where it would be? 
>
> (I guess one other complication is that if you copy-pasta text it would 
> be great to still be able to copy paste the names too, but I can think 
> of some kludgery that might make that possible.) 
>
> - Chris 
>

-- 
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/b8a0a5e2-aac0-42bf-a2a2-7d9b150bd709n%40googlegroups.com.


[racket-users] Overiding the default preferences directory in Racket applications

2020-07-25 Thread Alex Harsanyi

If a Racket package uses `get-preference` and `(find-system-path 'pref-dir)`
to store some data, is there a way for an application using that package to
override the default preferences file used and the preferences directory
returned by `(find-system-path 'pref-dir)`?

The reason I ask this question is that my map-widget package uses
"(find-system-path 'pref-dir)" to determine the location used to store the
cache for the downloaded map tiles and also uses `get-preference` to 
retrieve
some parameters regarding map rendering.

This approach works fine when a user installs the package and uses it 
directly
within Racket, however, when the package is used as part of an application
(and especially when building a standalone distribution of the 
application), I
would like to be able to override what `(find-system-path 'pref-dir)` 
returns,
as by default it points to a "racket" path (e.g. %APPDATA%/Racket on windows
and ~/.racket on Linux)

Thanks,
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0e310fcb-0628-4fd9-8787-3f7bec0a6e66n%40googlegroups.com.


Re: [racket-users] Re: note about parsing speed of xml vs sxml?

2020-06-29 Thread Alex Harsanyi


On Tuesday, June 30, 2020 at 7:48:14 AM UTC+8 Neil Van Dyke wrote:

> Is even 2x speedup helpful for your purpose? 


Yes it is, and for my purpose `read-xml` is fine even without any speed 
improvement.  In the sports field, XML (via the TCX format) is a legacy 
technology.  Typical TCX files are about 1Mb in size, the 14Mb one is a 
very large one.   Setting ` xml-count-bytes` to #t while calling `read-xml` 
gets me a speed improvement at a low effort, but it is not worth adding 
another package dependency just to support a legacy technology.

3 seconds is one old magic 
> number for user patience in HCI, so I suppose there's still a big 
> difference between 4 seconds and almost 10 seconds? 
>

I am not sure where you got the 3 seconds from, but even 3 seconds is too 
long to wait on a button callback.  For large files, both read-xml and sxml 
would need to have a progress dialog with a cancel button, or some other 
form of user feedback, if one wants to make a "well behaved" GUI.
 

> For large (and absolutely massive) XML... SSAX can shine even better 
> than in this comparison, since you can, say, populate a database *while 
> you're parsing, without first constructing the intermediate 
> representation* of xexpr or SXML.  GC-wise, with the database-populating 
> scenario, you'll probably end up with small, little-referencing, local, 
> short-lived allocations.  Besides GC costs, you'll also use less RAM 
> (possibly lower AWS bill), and be less likely to push into swap (which 
> would be bad for performance). 
>

... if you are willing to deal with the complexity of a SAX interface, that 
is.  I have written code for parsing documents (correctly!) using a SAX 
interface, and the resulting code was so complex that I had to use a code 
generator for it, but yes, the resulting code was very fast.   Would I do 
it again? No.

The complexity of SAX parsing is probably why most people use a DOM style 
interface...
 

> In addition to SSAX's current performance characteristics and 
> opportunities... There might also be opportunity to optimize SSAX 
> significantly for Racket. Oleg is a famously capable Scheme programmer, 
> but he was writing SSAX in fairly portable Scheme code, a couple decades 
> ago, when he wrote SSAX.  I did an initial packaging of SSAX for PLT 
> Scheme, Kirill Lisovsky later did many packagings of various SXML-ish 
> tools (including his own), and then John Clements did more work to 
> package Oleg's SXML-ish tools for Racket... But I don't know that anyone 
> has had motivation to try to optimize Racket's SSAX port, using current 
> Racket features, and tuning for current performance characteristics. 
>

> Side note regarding performance comparison... FWIW, SSAX might be doing 
> some things `read-xml` doesn't, such as namespace resolution, entity 
> reference resolution, and some validation. 
>

You used the phrase "might be doing...", does that mean that it might not 
do those things?

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/affcfe0e-a5a7-43a6-9019-8876dc40ed03n%40googlegroups.com.


[racket-users] Re: note about parsing speed of xml vs sxml?

2020-06-29 Thread Alex Harsanyi
I installed the sxml package out of curiosity, and while it is faster, it 
is not 4 times as fast, as your tests indicate. I used the following test 
program with a 14Mb XML file (a bike ride in TCX format):

(define file-name 
"../MyPackages/more-df-tests/tcx-data/2015-09-27-0755_Road_Cycling_WF.tcx")
;; Make sure the file is in the cache
(call-with-input-file file-name
  (lambda (in) (let loop ([c (read-char in)]) (unless (eof-object? c) 
(loop (read-char in))
(collect-garbage 'major)
(time (void (call-with-input-file file-name (lambda (in) 
(ssax:xml->sxml in null)
(collect-garbage 'major)
(time (void (call-with-input-file file-name read-xml)))

On my laptop the times are:

 ssax:xml->sxml : cpu time: 4031 real time: 4128 gc time: 157
 read-xml: cpu time: 9578 real time: 10031 gc time: 3270

The big difference I found so far is that `read-xml` will store the 
location (line number, column and file offset) for each element, and 
enabled `port-count-lines!` by default.  If I use:

(parameterize ([xml-count-bytes #t])
  (time (void (call-with-input-file file-name read-xml

The results are much closer together, although `read-xml` is still slower 
and spends more time in the garbage collector:

 ssax:xml->sxml :  cpu time: 4187 real time: 4233 gc time: 202
 read-xml: cpu time: 5797 real time: 5824 gc time: 1251

Perhaps a note could be added to the documentation indicating that users 
can speed up `read-xml` significantly if they set `xml-count-bytes` to #t.

Alex.

On Saturday, June 27, 2020 at 11:05:42 AM UTC+8 'John Clements' via 
users-redirect wrote:

> I’m parsing a large-ish apple plist file, (18 megabytes), and I find that 
> the built-in xml parsing (read-xml) takes about five times as long as the 
> sxml version (11 seconds vs 2.4 seconds on my machine), and that the plist 
> parser is way longer, at 18 seconds.
>
> Would anyone object if I added a margin note to this effect to the xml 
> docs?
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f99175fa-de2a-4434-9984-78446b3cf828n%40googlegroups.com.


Re: [racket-users] Re: note about parsing speed of xml vs sxml?

2020-06-28 Thread Alex Harsanyi
I tested the your string port version and I also wrote a "string-append" 
version of the xml reader and they are both slower by about 10-15% on my 
machine, when compared to the current read-xml implementation which uses 
`list->string`.  It looks like `list->string` is not the bottleneck here.

There are some small improvements that can be made from micro 
optimizations.  For example, I changed `name-char?` to not use 
`name-start?` but instead check for all chars, and I also changed 
`lex-name` to construct the list in reverse and use `(list->string (reverse 
chars))`, plus I reordered the cond condition to check the common case 
first (that the next character is a name-char? and not a 'special one).  
However, this resulted in only about 5-10% speed improvement, nowhere near 
where the 4 time speedup when using `sxml`, as reported by John.

In the end, it may well be that speeding up `read-xml` can only be done by 
these types of micro-optimizations.  Another thing I looked into was the 
"pattern" used for reading: all the `read-xml` code will use the pattern of 
"peeking" the next character, deciding if it is good, than reading it.  
This is much slower than just reading the characters directly.  These are 
the results from just reading in a 14Mb XML file:

read-char only:  cpu time: 312 real time: 307 gc time: 0
read-char-or-special only:  cpu time: 750 real time: 741 gc time: 0
peek-char than read-char:  cpu time: 1234 real time: 1210 gc time: 0
peek-char-or-special than read-char-or-special:  cpu time: 1688 real 
time: 1690 gc time: 0

Using this code:

(define file-name "your-test-file-here.xml")

(printf "read-char only~%")
(collect-garbage 'major)
(time
 (call-with-input-file file-name
   (lambda (in)
 (let loop ([c (read-char in)])
   (if (eof-object? c)
   (void)
   (loop (read-char in)))

(printf "read-char-or-special only~%")
(collect-garbage 'major)
(time
 (call-with-input-file file-name
   (lambda (in)
 (let loop ([c (read-char-or-special in)])
   (if (eof-object? c)
   (void)
   (loop (read-char-or-special in)))

(printf "peek-char than read-char~%")
(collect-garbage 'major)
(time
 (call-with-input-file file-name
  (lambda (in)
(let loop ([c (peek-char in)])
  (if (eof-object? c)
  (void)
  (begin
(void (read-char in))
(loop (peek-char in

(printf "peek-char-or-special than read-char-or-special~%")
(collect-garbage 'major)
(time
 (call-with-input-file file-name
  (lambda (in)
(let loop ([c (peek-char-or-special in)])
  (if (eof-object? c)
  (void)
  (begin
(void (read-char-or-special in))
(loop (peek-char-or-special in

Alex.

On Monday, June 29, 2020 at 5:30:43 AM UTC+8 rmculp...@gmail.com wrote:

> Thanks Alex for pointing out the use of list->string. I've created a PR (
> https://github.com/racket/racket/pull/3275) that changes that code to use 
> string ports instead (similar to Hendrik's suggestion, but the string port 
> handles resizing automatically). Could someone (John?) with some large XML 
> files lying around try the changes and see if they help?
>
> Ryan
>
>
> On Sun, Jun 28, 2020 at 9:56 PM Neil Van Dyke  
> wrote:
>
>> If anyone wants to optimize `read-xml` for particular classes of use, 
>> without changing the interface, it might be very helpful to run your 
>> representative tests using the statistical profiler.
>>
>> The profiler text report takes a little while of tracing through 
>> manually to get a feel for how to read and use it, but it can be 
>> tremendously useful, and is worth learning to do if you need performance.
>>
>> After a first pass with that, you might also want to look at how costly 
>> allocations/GC are, and maybe do some controlled experiments around 
>> that.  For example, force a few GC cycles, run your workload under 
>> profiler, check GC time during, and forced time after.  If you're 
>> dealing with very large graphs coming out of the parser, I don't know 
>> whether those are enough to matter with the current GC mechanism, but 
>> maybe also check GC time while you're holding onto large graphs, when 
>> you release them, and after they've been collected.  At some point, GC 
>> gets hard for at least me to reason about, but some things make sense, 
>> and other things you decide when to stop digging. :)  If you record all 
>> your measurements, you can compare empirically the how different changes 
>> to the code affect things, hopefully in representative situations.
>>
>> I went through a lot of these exercises to optimize a large system, and 
>> sped up dynamic Web page loads dramatically in the usual case (to the 
>> point we were then mainly limited by PostgreSQL query cost, not much by 
>> the application code in Scheme, nor our request network I/O), 
>> and also greatly reduced the pain of intermittent request latency spikes 
>> due to GC.
>>
>> One of 

Re: [racket-users] Re: note about parsing speed of xml vs sxml?

2020-06-28 Thread Alex Harsanyi
I suggested using `string-append` because in my own performance 
investigations with reading 100Mb+ CSV files: constructing short tokens 
using string-append is faster than using a string port -- perhaps there is 
a fixed overhead with using string ports which makes `string-append` faster 
for short strings, but I don't know at what string length the string ports 
become faster.

I think using string ports will be definitely faster than using 
`list->string`, but for the difference between `string-append` and string 
ports, some performance measurement might be needed.

Thanks for looking into this,
Alex.

On Monday, June 29, 2020 at 5:30:43 AM UTC+8 rmculp...@gmail.com wrote:

> Thanks Alex for pointing out the use of list->string. I've created a PR (
> https://github.com/racket/racket/pull/3275) that changes that code to use 
> string ports instead (similar to Hendrik's suggestion, but the string port 
> handles resizing automatically). Could someone (John?) with some large XML 
> files lying around try the changes and see if they help?
>
> Ryan
>
>
> On Sun, Jun 28, 2020 at 9:56 PM Neil Van Dyke  
> wrote:
>
>> If anyone wants to optimize `read-xml` for particular classes of use, 
>> without changing the interface, it might be very helpful to run your 
>> representative tests using the statistical profiler.
>>
>> The profiler text report takes a little while of tracing through 
>> manually to get a feel for how to read and use it, but it can be 
>> tremendously useful, and is worth learning to do if you need performance.
>>
>> After a first pass with that, you might also want to look at how costly 
>> allocations/GC are, and maybe do some controlled experiments around 
>> that.  For example, force a few GC cycles, run your workload under 
>> profiler, check GC time during, and forced time after.  If you're 
>> dealing with very large graphs coming out of the parser, I don't know 
>> whether those are enough to matter with the current GC mechanism, but 
>> maybe also check GC time while you're holding onto large graphs, when 
>> you release them, and after they've been collected.  At some point, GC 
>> gets hard for at least me to reason about, but some things make sense, 
>> and other things you decide when to stop digging. :)  If you record all 
>> your measurements, you can compare empirically the how different changes 
>> to the code affect things, hopefully in representative situations.
>>
>> I went through a lot of these exercises to optimize a large system, and 
>> sped up dynamic Web page loads dramatically in the usual case (to the 
>> point we were then mainly limited by PostgreSQL query cost, not much by 
>> the application code in Scheme, nor our request network I/O), 
>> and also greatly reduced the pain of intermittent request latency spikes 
>> due to GC.
>>
>> One of the hotspots, I did half a dozen very different implementations, 
>> including C extension, and found an old-school pure Scheme 
>> implementation was fastest.  I compared the performance of the 
>> implementation using something like `shootout`, but there might be 
>> better ways now in Racket. https://www.neilvandyke.org/racket/shootout/  
>> I also found we could be much faster if we made a change to what the 
>> algorithm guarantees, since it was more of a consistency check that 
>> turned out to be very expensive and very redundant, due to all the ways 
>> that utility code ended up being used.
>>
>> In addition to contrived experiments, I also rigged up a runtime option 
>> so that the server would save data from the statistical profiler for 
>> each request a Web server handled in production.  Which was tremendously 
>> useful, since it gave us real-world examples that were also difficult to 
>> synthesize (e.g., complex dynamic queries), and we could go from Web 
>> logs and user feedback, to exactly what happened.
>>
>> (In that system I optimized, we used Oleg's SXML tools very heavily 
>> throughout the system, plus some bespoke SXML tools for HTML and XML.  
>> There was one case in which someone had accidentally used the `xml` 
>> module, not knowing it was incompatible with the rest of the system, 
>> which caused some strange failures (no static checking) before it was 
>> discovered, and we changed that code to use SXML.)
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/68624c9a-df35-14a3-a912-df806799a7e0%40neilvandyke.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.
To view this discussion on the web visit 

[racket-users] Re: Pasting an Image from windows clipboard and annotating it

2020-06-27 Thread Alex Harsanyi
You can get the bitmap from the clipboard using "(send the-clipboard 
get-clipboard-bitmap)" and you can use the bitmap dimensions (see get-with 
and get-height methods of the bitmap% object) to make the canvas the same 
size as the bitmap by constructing it with stretchable-width and 
stretchable-height set to #f and setting the min-width and min-height to 
the bitmap dimensions.   To draw the bitmap onto the canvas, you can use 
the draw-bitmap method in the paint callback.

For the mouse clicks, you will need to override the `on-subwindow-event` on 
the canvas to look at the mouse events and record where the user clicked.  
You can draw the letters at the click positions in the paint-callback of 
the canvas using the draw-text method.

Hope this helps,
Alex.

On Saturday, June 27, 2020 at 10:44:44 AM UTC+8 frangonve wrote:

> Hello, A newbie here:
>
> I want to insert an image from windows clipboard to a rectangular widget 
> that will take the image size. Then when  repeatedly clicking the mouse on 
> different coordinates of the image I want to superimpose each time the next 
> letter in alphabetic order with transparent background:
>
> This is the type of images to insert:
>
> [image: Clever Mines 20200318.png]
>
> This is what I want to show after clicking several times on the image 
> high-left corner:
>
> [image: Clever Mines 20200318 id.png]
>
> Please can you help me?
>
> Cheers
>
> Francisco 
>

-- 
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/b5ad5b07-ae85-40e6-b072-8c71e5a68dd2n%40googlegroups.com.


[racket-users] Re: note about parsing speed of xml vs sxml?

2020-06-27 Thread Alex Harsanyi
Looking at the source for `read-xml`, it seems to be using `list->string` 
in several places.  That is, it reads characters one-by-one and constructs 
a list by appending a character to the end of it, than calls `list->string` 
to produce the string.  I suspect read-xml could be made faster by using 
`string-append` in these cases.

https://github.com/racket/racket/blob/master/racket/collects/xml/private/reader.rkt

Alex.

On Saturday, June 27, 2020 at 11:05:42 AM UTC+8 'John Clements' via 
users-redirect wrote:

> I’m parsing a large-ish apple plist file, (18 megabytes), and I find that 
> the built-in xml parsing (read-xml) takes about five times as long as the 
> sxml version (11 seconds vs 2.4 seconds on my machine), and that the plist 
> parser is way longer, at 18 seconds.
>
> Would anyone object if I added a margin note to this effect to the xml 
> docs?
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f079d5ff-27c0-43be-b0dd-f999e8ee561cn%40googlegroups.com.


[racket-users] Re: [racket-money] Fwd: [racket-dev] Racket Survey 2020

2020-06-24 Thread Alex Harsanyi


On Thursday, June 25, 2020 at 6:14:42 AM UTC+8, jos.koot wrote: 

Questions and problem reports of users always are responded to very 
> promptly.
>

It depends.  If the problem report starts with "racket crashes when I do 
X", it will be fixed within 24 hours.  For everything else, not so much.  A 
quick browse of the issues sections of the various packages in the Racket 
organization will show that there are many issues reported a long time ago 
which have no feedback. 

While Stephens question in another thread is how we can encourage users to 
submit fixes themselves, there is also a lack of response when it comes to 
submitted pull requests.  You can browse the pull request section of 
various projects and see for yourself, but here is an example: 
https://github.com/racket/plot/pull/5 -- created in 2015, looks perfectly 
good and reasonable change, yet there is no feedback from the Racket team 
about this.  Why should this person ever attempt contribute again if she is 
ignored?

For my part, I have some spare time which I could dedicate to helping out 
the Racket project.  Given that my time is limited, I cannot pick up big 
tasks, but I could help diagnose and fix bugs (and I have done so a few 
times in the past).  However, my own experience is that, even if I submit a 
pull request, I need to prompt the developers to look at it and provide 
feedback, and it is unclear to me when I would cross the line and become 
nagging.

I understand that the core Racket team is busy, but they are the only ones 
who can clarify the criteria for merging a pull request and also only they 
can review and merge them -- if they don't have time to do that, it is 
useless to talk about user contributions.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e8453de0-2aa9-482b-89ca-2596c09585a1o%40googlegroups.com.


[racket-users] Re: trying to use futures for some calculations

2020-06-18 Thread Alex Harsanyi
Perhaps my choice for the interval names is not ideal, so I will try to 
explain it:

I am trying to fit a function which uses 3 parameters, so I need three data 
points to solve for these parameters.  The three points are drawn from 
three intervals, and, rather than calling the intervals ivl1, ivl2, ivl3 I 
gave them names which seemed roughly appropriate.

As for the values I provided, they seem ok for getting a good fit, but in 
the final application, the user will be able to specify any range they want 
(as long as the ranges don't overlap).

Alex.

On Wednesday, June 17, 2020 at 10:08:06 PM UTC+8, Brian Adkins wrote:
>
> On Wednesday, June 17, 2020 at 4:50:44 AM UTC-4, Alex Harsanyi wrote:
>>
>>
>> I am trying to speed up an algorithm using futures, but I am getting some 
>> unexpected results (and no real speed improvements), and I was wondering if 
>> someone more experienced could have a look a the code and tell me what am I 
>> doing wrong.
>>
>> I put up the code in this repository: 
>> https://github.com/alex-hhh/cp3-exeriments, unfortunately it is the 
>> simplest meaningful example that I can come up with.  Most of the 
>> functions, however are just support functions and there are six 
>> implementation of the same algorithm.
>> [...]
>>
>
> This is entirely unrelated to your question, but I'm curious about your 
> ranges. Andy Coggan defines the following:
>
> Neuromuscular:  < 30 seconds
> Anaerobic:  30 seconds to 3 minutes
> VO2max:  3 minutes to 8 minutes
> Lactate Threshold: 8 to 30 minutes
> Tempo:  60 to 180 minutes
> Endurance:  60 to 300 minutes
>
> I'm curious about you using 2 to 5 minutes for anaerobic. In particular, 
> because I'm targeting 5 minutes as an important benchmark, and I've 
> considered that as high level aerobic w/ a strong anaerobic contribution.
>

-- 
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/24a40ced-ed69-4a8e-9921-baa5b932174fo%40googlegroups.com.


Re: [racket-users] trying to use futures for some calculations

2020-06-18 Thread Alex Harsanyi

Hi Dominic,

Thanks for taking the time to look into this.  For most of your suggestions 
I already suspected this to be the case, as I attempted to use futures 
several times in the past, but it is good to know that other people are of 
the same opinion.

I looked at some other suggestions in this thread and they do make small 
improvements to the speed, but nothing spectacular.  The biggest 
improvement (about 30%) comes from using Typed Racket -- this is attractive 
as the code looks nice and has type annotations too.  For realistic data 
sets, the best TR version still takes about 5 seconds.  While 5 seconds is 
not a lot, the code will be added to a GUI application, and this means that 
I will need to implement some kind of progress bar for the user to look at, 
while the results come in...

Given these experiments and discussion, and from my personal point of view, 
futures are not attractive, as they require a lot of effort to get any 
performance benefits out of them, and simple and "innocent" code changes 
can result in a complete performance loss.  Also the resulting code is not 
particularly elegant and maintainable, especially once I start using the 
unsafe operations.

Out of curiosity, I also implemented the straightforward CP3 search 
(cp3-baseline) in C++ and it runs in 0.7 seconds.

However, for now, I will go with the Typed Racket solution and just add a 
progress bar to the GUI.

Thanks everyone for looking at this code and providing suggestions.

Alex.

On Thursday, June 18, 2020 at 4:45:38 AM UTC+8, Dominik Pantůček wrote:
>
> Hi Alex, 
>
> I finally got to investigate the issue in depth. And there are two major 
> problems blocking your implementation from running the futures in 
> parallel. 
>
> 1) Allocations of boxed flonums. I tried to get rid of those by 
> allocating "scratchpad" flvectors and mapping everything onto them. The 
> future scheduling started to look different, however there are many 
> allocations because of your loops in functions cp3-futures and 
> evaluate-cost. 
>
> I didn't finish the work though, because I noticed another strange 
> thing. The Typed Racket code in the lambda function returned by spline 
> (your mmax-fn argument) blocks almost entirely the parallel execution on 
> ... type checks. 
>
> 2) All those =, < and friends just block it. 
>
> So how to fix this? Well, it is relatively easy albeit quite a lot of 
> manual work. 
>
> (I am looking only at the cp3-futures function when talking about 
> possible improvements). 
>
> * Change the all the for loops for let loop forms and use preallocated 
> flvectors to hold all the values. 
> * Switch to racket/unsafe/ops for everything inside futures (this is not 
> necessary, but takes away a few possible surprises) 
> * Restructuralize the way you split the work into 30 futures and just 
> use a binary tree of futures as suggested earlier. 
> * Use racket/unsafe/ops from regular racket to implement the spline 
> interpolation. I would also move the coefficients into one huge flvector 
> and forgot about lists at all. This is very specific workload. 
>
> And do not worry about GCs. Once you get rid of all allocations inside 
> futures, the GCs will disappear. 
>
> Also bear in mind that my suggestions are rather low level. By following 
> them you will get the algorithm to scale over multiple cores if you 
> really need it. Just remember it will be at a huge cost to readability. 
> You can slightly mitigate this by some refactoring and custom syntax, 
> but that is even more work and I would really consider whether you need 
> the parallelism for a computation that takes a few seconds anyway. 
>
> Of course, if you plan to use your algorithm for much bigger data set, 
> this is the way to go (including the custom syntax). 
>
>
> Cheers, 
> Dominik 
>
> On 17. 06. 20 10:50, Alex Harsanyi wrote: 
> > 
> > I am trying to speed up an algorithm using futures, but I am getting 
> > some unexpected results (and no real speed improvements), and I was 
> > wondering if someone more experienced could have a look a the code and 
> > tell me what am I doing wrong. 
> > 
> > I put up the code in this repository: 
> > https://github.com/alex-hhh/cp3-exeriments, unfortunately it is the 
> > simplest meaningful example that I can come up with.  Most of the 
> > functions, however are just support functions and there are six 
> > implementation of the same algorithm. 
> > 
> > Basically, the problem I am trying to solve is to fit a model to 
> > existing data and this is done by evaluating 2.5 million combinations of 
> > parameters.  My best, non-futures based, algorithm can do this in about 
> > 3 seconds (8 seconds in DrRacket). 
> > 

[racket-users] trying to use futures for some calculations

2020-06-17 Thread Alex Harsanyi

I am trying to speed up an algorithm using futures, but I am getting some 
unexpected results (and no real speed improvements), and I was wondering if 
someone more experienced could have a look a the code and tell me what am I 
doing wrong.

I put up the code in this repository: 
https://github.com/alex-hhh/cp3-exeriments, unfortunately it is the 
simplest meaningful example that I can come up with.  Most of the 
functions, however are just support functions and there are six 
implementation of the same algorithm.

Basically, the problem I am trying to solve is to fit a model to existing 
data and this is done by evaluating 2.5 million combinations of 
parameters.  My best, non-futures based, algorithm can do this in about 3 
seconds (8 seconds in DrRacket).

Given that each of this 2.5 million combination is completely independent 
from the others, they could all be done in parallel.  Given this, I 
"sliced" the combinations into 30 groups and tried to perform each "slice" 
in its own future and select the best among the 30 results produced by 
these futures.

Unfortunately, while the futures versions of the algorithm produce the 
correct result, the algorithm runs at the same speed as the non-futures 
version.  My `processor-count` returns 8, so I would expect at least some 
level of parallelism.

As a first step, I tried using `would-be-future`, to see if it reported any 
operations which might block, but nothing was printed out.

I also tried using the futures visualized, and I found the following:

* the code appears to be blocking on primitive operations, such as +, -, < 
etc.
* I suspect these operations are inside the code generated by the `for` 
loops, so I am not sure how to remove them without making the code even 
more difficult to read.
* there seems to be a lot more time spent in the garbage collector when 
running the futures visualizer than without it (DrRacket runs with 
unlimited memory)

So I am wondering if someone who is more familiar with futures can look at 
the code and provide some hints about what can be done to make this code 
run in parallel (or if it cannot, I would like to understand why).

This is already a long message, so I will not add further details here, but 
the repository at https://github.com/alex-hhh/cp3-exeriments has an 
explanation of what every function does, and I am happy to provide further 
clarifications if needed.

Thanks,
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8bf6f7c4-3b2f-4b86-9a8a-be68e82d09cfo%40googlegroups.com.


Re: [racket-users] Re: [racket] Web Framework Benchmarks

2020-06-08 Thread Alex Harsanyi


On Monday, June 8, 2020 at 6:11:37 PM UTC+8, Yury Bulka wrote:
>
> Wow, from 695 requests per second to 49,516 is a huge improvement! 
>
> Since we were comparing to django previously, it's now much closer with 
> django (which does 78,132 rps.) 
>

I know very little about web development, so these may be some stupid 
questions, but I am very curious.

I am looking at 
http://www.techempower.com/benchmarks/#section=data-r19=ph=composite, 
and even with 78k requests/second, Django is at the bottom of that list 
(position 98 out of 104).  In fact, most of the web frameworks that I can 
recognize are at the bottom of this list, and their score is also very 
modest, compared to the frameworks at the top.  The highest framework that 
I can recognize in that list is "flask" and its performance is a mere 4.8% 
of the top one.

Question 1: Based on this benchmark, is there any reason to chose anything 
else but "drogon"?  Even if one chooses the second best on that list, which 
is "actix", they already loose about 6% performance and things degrade 
quickly afterwards.  The framework at position 10 is already half the speed 
of the top one.

Question 2:  Based on Bogdans message in this thread, it seems that most of 
the performance improvement for the Racket benchmark comes from the nginx 
configuration (which has nothing to do with Racket) and the next 
improvement has to do with how the user program is written (by supplying a 
"Content-Length" header).  So, is this benchmark really testing the Racket 
web server performance, or is it testing a very specific deployment?

Alex.

 

>
> Django also does run multiple worker processes (3 per cpu): 
>
> https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Python/django/gunicorn_conf.py#L8
>  
>
> The other tests are also doing much better. 
>
> So do I undestand correctly that the factors that contribute to the 
> improvement are: 
>
> 1. running multiple worker processes behind nginx 
> 2. adding content-length to all responses 
> 3. using CS variant of Racket 
> 4. using Racket 7.7 
> 5. tuning nginx config (enabling http 1.1 especially) 
>
> I'm curious what was the individual contribution of these factors. In 
> the PR regarding #5 you already stated that it gives a 4-5x improvement. 
>
> #1 and #5 are the things one would normally do anyway in a production 
> setup I guess. As is #4 most likely. 
>
> #2 is something that seems to require manual work in the client code, 
> but maybe that can be made easier on web-server-lib side somehow. 
>
> Curious how much do #3 contribute. 
>
> Big thanks again for everyone investing time in investigating this. 
>
> -- 
> Yury Bulka 
> https://mamot.fr/@setthemfree 
> #NotOnFacebook  
>
>
> Bogdan Popa > writes: 
>
> > Small update on this: I've updated the benchmarks to run multiple Racket 
> > processes with an Nginx load balancer in front.  After some tuning[1], 
> here 
> > is what the results look like on my 12 core AMD Ryzen 9 3900 server: 
> > 
> > 
> https://www.techempower.com/benchmarks/#section=test=669bfab7-9242-4c26-8921-a4fe9ccd8530=ph=composite=2
>  
> > 
> > 50k/s is a respectable number for the plaintext benchmark IMO and we 
> > could get it to go higher if we could ditch Nginx or spend more time 
> > improving the server's internals, as Sam suggested. 
> > 
> > The `racket-perf' benchmark is for a branch[2] that I have where I've 
> made 
> > some small improvements to the server's internals. 
> > 
> > [0]: https://github.com/TechEmpower/FrameworkBenchmarks/pull/5727 
> > [1]: https://github.com/TechEmpower/FrameworkBenchmarks/pull/5737 
> > [2]: https://github.com/racket/web-server/pull/94 
>
>

-- 
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/6a31e2c4-c698-4841-93ba-274cb4f24581o%40googlegroups.com.


[racket-users] Re: foldts-test-suite

2020-06-02 Thread Alex Harsanyi

Are there alternatives to the `folds-test-suite` and `fold-test-results` 
functions, for people who want to write their own test running and 
reporting for Rackunit tests?

Alex.

On Wednesday, June 3, 2020 at 2:00:02 AM UTC+8, Jack Firth wrote:
>
> The test case folding stuff in RackUnit should mostly be ignored, instead 
> of extended.
>
> On Saturday, May 23, 2020 at 7:52:21 AM UTC-7, Shriram Krishnamurthi wrote:
>>
>> The documentation
>>
>>
>> https://docs.racket-lang.org/rackunit/internals.html?q=run-test-case#%28def._%28%28lib._rackunit%2Fmain..rkt%29._foldts-test-suite%29%29
>>
>> says that `folds-test-suite` can be implemented in terms of 
>> `fold-test-results` as follows:
>>
>> (define 
>> 
>>  (fold-test-results 
>> 
>>  suite-fn case-fn seed test)
>>   (foldts-test-suite 
>> 
>>(lambda 
>> 
>>  (suite name before 
>> 
>>  after 
>> 
>>  seed)
>>  (before 
>> 
>> )
>>  (suite-fn name seed))
>>(lambda 
>> 
>>  (suite name before 
>> 
>>  after 
>> 
>>  seed kid-seed)
>>  (after 
>> 
>> )
>>  kid-seed)
>>(lambda 
>> 
>>  (case 
>> 
>>  name action seed)
>>  (case-fn
>>(run-test-case 
>> 
>>  name action)
>>seed))
>>seed
>>test))
>>
>> I'm curious why the value of `seed` in the second argument (the fup 
>> position) — highlighted — is ignored. I was guessing that, since this is a 
>> tree-fold, there are values "from across" and "from down", and we don't 
>> want to throw either one away. Wouldn't we want to take a combinator that 
>> combines the two?
>>
>> Shriram
>>
>>

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


[racket-users] Re: Testing for Packages

2020-05-26 Thread Alex Harsanyi

I am personally confused about what you think the problem is, so I just 
want to make sure that you know that you can develop and test a new 
package, or you can modify an existing package and test the modifications, 
without publishing the package.

Basically in Racket you can:

* create a new package using "raco pkg new", or clone an existing one
* install the package from the local folder, using "raco pkg install 
./my-package"
* make changes and run the tests -- you can keep making changes on the 
installed package without having to re-install it
* once the tests pass, you can commit the changes and publish them

"Under raco pkg management" does not mean that the package is publicly 
available on the racket package server.  You can keep the package private, 
and still be able to install it and run the tests.

Alex.

On Wednesday, May 27, 2020 at 10:36:10 AM UTC+8, Robert Postill wrote:
>
> Hi, 
>
> Inspired by the reply to 
> https://stackoverflow.com/questions/62014612/how-to-test-a-racket-package-self-sufficiently,
>  I 
> decided to ask the question here.  So a little background to the 
> discussion.  I've been looking at a racket package, and the package has a 
> couple of collections.  It's been dormant for a few years, and so when I 
> ran the tests they didn't work (it's a driver, and the database it works 
> with had moved on in the intervening time).  So I started thinking about 
> the tests.  One thing that troubled me was that the tests seemed to be 
> dependant on the package already being installed. Ryan Culpepper's 
> comment on the stack overflow question (
> https://stackoverflow.com/a/62027185/11219) suggests that the tests 
> should be run once the package is under raco pkg's management. Up until 
> that point, I had been considering a PR rewiring the require statements to 
> be significantly more relative.
>
> In the generally excellent docs for racket, I haven't found advice 
> relating to the right way to structure the tests for a package. Nor an 
> idiomatic approach to dealing with package installation during package 
> development. Here are my sources for reference:
> https://blog.racket-lang.org/2017/10/tutorial-creating-a-package.html
> https://beautifulracket.com/jsonic-3/the-package-server.html
> https://greghendershott.com/2013/12/racket-package-management.html
> http://www.greghendershott.com/2017/04/racket-makefiles.html
>
> Now I think I should explain why I'm thinking that way.  FYI I've been a 
> part of the ruby community, and so my thinking has a ruby-ish colour.  
> Which makes me think I'm maybe off in my community norms for racket. I've 
> always considered the point at which a package gets transferred into the 
> domain of raco pkg's management to be a pivotal moment. It has this implied 
> social contract that if I'm mixing with code into a system area managed by 
> the language, the package needs to be trustworthy. Testing *after* 
> installing seems a bit like I'm putting the cart before the horse? It feels 
> like saying here's my code, put it in a system-wide place, I hope it works.
>
> So I'm interested in opinions and advice as to how to think correctly 
> about testing packages and also how other people approach creating a 
> well-behaved package.
>
> Regards
> Robert
>

-- 
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/aca8e24c-88db-4aae-8ab6-4dc455b4481f%40googlegroups.com.


[racket-users] Re: GUI executable creating an annoying command line window

2020-05-26 Thread Alex Harsanyi

I cannot reproduce this.  If I create the executable from the command line 
using "raco exe --gui work-timer.rkt", or from DrRacket specifying GRacket 
as the "base", the console window does not show up.  

If I create the executable using "raco exe work-timer.rkt" or by specifying 
"Racket" as the base in DrRacket, the console window shows up, but this is 
expected.

I am using Racket 7.7 (BC, not the Chez version).

Alex.

On Tuesday, May 26, 2020 at 5:00:01 PM UTC+8, Philip Benade wrote:
>
> Hi All
>
> I have been trying to create a simple GUI with the racket/gui library. For 
> the most part it works but alongside my GUI it also creates a command line 
> window. You can see a screenshot of this in the attached picture. I found 
> this discussion when I searched for a solution: 
> https://groups.google.com/forum/#!topic/racket-users/QmvqWtm1x28 In that 
> case it was happening because there were things that did not return void. 
> In my case however it is not printing anything, there isn't even any white 
> space.
>
> I am using the "Create Executable" option from the "Racket" heading in 
> Dr.Racket's menu. I set the Type to be "Distribution (to install on other 
> machines)" and the Base to "GRacket" and keep the "Embed DLLs in the 
> executable" check box checked. Is there some setting or something I can 
> change to make this window to go away?
>
> I have attached my program's .rtk file in case anyone needs it to see what 
> I'm doing wrong.
>
> Regards
> Philip
>

-- 
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/2bcb57b6-73c4-41cb-b737-64d0cb0cf31e%40googlegroups.com.


Re: [racket-users] Re: Should I stop sending packages to the catalog?

2020-05-25 Thread Alex Harsanyi


On Thursday, April 30, 2020 at 3:59:49 PM UTC+8, Laurent wrote:
>
> Alex, that looks like an interesting workflow. Maybe worth a blog post? ;)
>


Well, it took longer than I anticipated, but here it is: 
https://alex-hhh.github.io/2020/05/dependency-management-in-racket-applications.html

I understand that everyone has a different workflow and my workflow will 
not be directly applicable to them, but hopefully a few ideas can be 
re-used.  I also tried to explain what I would like from a "dependency 
management" solution.

Alex.
 

>
> On Thu, Apr 30, 2020 at 12:11 AM Alex Harsanyi  > wrote:
>
>>
>> You could both send packages to the package catalog and instruct your 
>> users to use a different package source if they wish to use old versions.  
>> I don't see these two options in conflict with each other.
>>
>> As an application writer, I am on the other side of this problem, by 
>> depending on other packages. Having limited time to work on my project I 
>> want to upgrade package dependencies at my own pace.   The solution I found 
>> is to use git submodules and add each package as a submodule to my 
>> application.  I  construct a catalog of these packages, at an exact git 
>> commit, and simply run a raco pkg install, knowing that the exact version 
>> that I want will be there.  From time to time, I update these submodules 
>> and allow some time for fixing any problems that might result from these 
>> updates.  This has worked reasonably well so far, and I can reliably 
>> reconstruct older versions of the application knowing that all dependencies 
>> will be correct for that old version.
>>
>> For my part, for any packages that my application depends on, their 
>> authors can make any breaking changes they want, as this will not 
>> immediately break my application.  At a later date I can review these 
>> changes, update my application and move to the new version.
>>
>> The only downside is that installed packages are at "user scope" rather 
>> than "application scope" so once installed from the git submodules, that 
>> package becomes available to all applications on my computer.   So far this 
>> has not been a real issue, although I had to uninstall, switch catalogs and 
>> re-install a few times.
>>
>> I personally regard pkgs.racket-lang.org as the source for the latest 
>> package versions, for users which just started using the package. Users who 
>> need precise versioning, can always setup their own package catalogs (i 
>> discovered that it is a really simple process)
>>
>> Alex.
>>
>>
>> On Thursday, April 30, 2020 at 12:47:25 AM UTC+8, Sage Gerard wrote:
>>>
>>> April 9th in the #general Slack channel taught me that there was no 
>>> clean way to
>>> release a breaking change in a package. I'm open to working on version 
>>> pinning
>>> support in raco pkg provided that a maintainer can walk me through some 
>>> code.
>>>
>>> In the meantime, as much as I appreciate the efforts made in the current 
>>> system,
>>> I'm considering stopping my contributions to the package catalog until 
>>> further notice.
>>> I'm open to submitting packages if I am confident in their longevity, 
>>> but I don't want
>>> to end up in the position I've been in for the last few weeks when 
>>> planning a release.
>>> That position being an inability to release an edition that is not in 
>>> some way "aware"
>>> of a prior edition. In my view, changing the package/collection name is 
>>> an
>>> example of that problem, not a solution to it.
>>>
>>> I'm considering asking my users to specify different package sources in 
>>> their info.rkt
>>> files when dealing with my work. Before I commit to that decision, I 
>>> wanted to tap into
>>> those of you who have already been here. How have you handled breaking 
>>> changes
>>> for your projects? How have you communicated with your users to make 
>>> sure they
>>> were adequately prepared? Am I being too black-and-white about this?
>>>
>>> *~slg*
>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/b3b54ccf-b4f1-425e-802a-110d5ac26591%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/b3b54ccf-b4f1-425e-802a-110d5ac26591%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

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


Re: [racket-users] Re: rackunit and logging

2020-05-23 Thread Alex Harsanyi

As I mentioned in my previous post, the "unit" that can succeed or fail is 
the "test case", and this will work:

#lang racket
(require rackunit)

(define-test-suite hw
  (test-case "one" (check-equal? 1 1))
  (test-case "two" (check-equal? 1 (/ 1 0)))
  (test-case "three" (check-equal? 1 2)))

(foldts-test-suite
 (λ (suite name before after seed) (before) seed)
 (λ (suite name before after seed kid-seed) (after) (append seed kid-seed))
 (λ (case name action seed)
   (let ([outcome (run-test-case name action)])
 (cons outcome seed)))
 empty
 hw)

;; Produces:
;; '(# # #)


You won't be able to catch errors from the test case in a handler -- this 
is handled by rackunit, so the `with-handlers` is useless there.

Alex.

On Saturday, May 23, 2020 at 10:47:53 PM UTC+8, sk wrote:
>
> Sorry to be thinking out loud here…
>
> I thought the reason Alex might be using `foldts-test-suite` instead of 
> `fold-test-results` is because the latter automatically runs each test but 
> the former leaves that in programmatic control. I thought this would enable 
> me to catch exceptions, thus (using Alex's really good names for the 
> pieces). E.g.:
>
> (define-test-suite hw
>   (check-equal? 1 1)
>   (check-equal? 1 (/ 1 0))
>   (check-equal? 1 2))
>
> (foldts-test-suite
>  (λ (suite name before after seed) (before) seed)
>  (λ (suite name before after seed kid-seed) (after) (append seed kid-seed))
>  (λ (case name action seed)
>(let ([outcome (with-handlers ([exn:fail?
>(λ (e)
>  (println "got here")
>  (cons 'test-failed seed))])
> (run-test-case name action))])
>  (cons outcome seed)))
>  empty
>  hw)
>
> Unfortunately, the `with-handers` does not seem to be taking effect at 
> all: the runner still halts with an error. Can anyone see what I'm missing?
>
> Shriram
>

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


Re: [racket-users] Re: rackunit and logging

2020-05-23 Thread Alex Harsanyi


On Saturday, May 23, 2020 at 10:25:07 PM UTC+8, sk wrote:
>
> Thank you, Alex, this seems to have just the right set of information. I'm 
> curious why you use `foldts-test-suite` instead of  `fold-test-results`, 
> whose documentation says "Hence it should be used in preference to 
> foldts-test-suite 
> ."
>  
>
>

I no longer remember why I choose `foldts-test-suite`, I remember 
experimenting with a few approaches before settling on the current one, but 
looking at the code now, I think `fold-test-results` would have worked 
equally well in my case.
 

> (And while David's points about the verbosity are well taken, my TAs are 
> likely to be used to the rackunit primitives, though I think I'll consider 
> borrowing some of his aliases for shorter testing primitive names.)
>
> In the success case, the result seems to be `void` (rather than, say, a 
> value corresponding to the type of test). Are there cases where it's not 
> void?
>

I am not sure I understand this question: whose result is "void" and what 
would "A value corresponding to the type of the test" be?
 

>
> In the failure case, is there a procedure to convert the `exn:test:check` 
> value into a human-readable string? I'm guessing you have some 
> serialization process for the XML test report.
>

Unfortunately, I had to import some functions from the "private" section of 
rackunit. in particular, the display-test-failure/error function.
 

>
> Sadly, errors during test execution aren't sandboxed, so if there's an 
> error in a test, the whole suite breaks down. I think this means I'm going 
> to have to write custom testing procedures anyway.
>

I am not sure what "errors during test execution" means for you, but a 
check failure in a test case will not prevent other test cases from 
running, and neither will any other failure that raises an exception.  I'm 
sure a creative programmer can write a test case which will prevent other 
test cases from running, but the issue does not seem important enough to 
prevent them.

The "unit" is however the test case, not the individual check, so if a 
check fails inside a test case, other checks in the same test case will not 
run.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/7a5b8cd8-d2d6-492c-9e17-b1c466099640%40googlegroups.com.


[racket-users] Re: rackunit and logging

2020-05-22 Thread Alex Harsanyi
You can use foldts-test-suite 

 
(part of the rackunit package) to write your own test runner which collects 
and reports on the tests according to your needs.  This will only work for 
the rackunit tests which are organized in test suites and test cases, not 
with simple `check-*` written inside test modules.

I used it myself to write a test runner which runs rackunit tests and 
outputs the results as JUnit XML test files.  This is a widely supported 
test result format that can be imported into test reporting applications.

Alex.

On Saturday, May 23, 2020 at 7:47:47 AM UTC+8, Shriram Krishnamurthi wrote:
>
> I'm trying to understand the design of the logging portion of rackunit:
>
>
> https://docs.racket-lang.org/rackunit/Testing_Utilities.html#%28part._.Logging_.Test_.Results%29
>
>1. The "log" seems to only be a *count*, not the actual rackunit 
>output (as the term "log" would suggest). Since I want to show a summary 
> of 
>tests — including output — on a different medium, after the test suite has 
>run, it looks like I need to essentially create my own logging support? 
>(Perhaps the "check-info stack" is useful here, but I don't think so.)
>2. Why do the check-… procedures not return any value? It would seem 
>natural for them to return, say, false in case of passing and a failure 
>information structure in case of failing (or a structure in both cases). 
>But they seem to only return void, so I'm not entirely sure how else to 
>extract the information for the log without rewriting the check's.
>3. As an aside, I'm not entirely sure what `test-log!` is there for. 
>Presumably it's to record in the log "tests" run by operations that are 
> not 
>part of rackunit? I'm curious how people have used it.
>
> TL;DR: If I want to record what happened on all the checks for 
> post-execution processing, do I need to (a) create my own log and, to do 
> so, (b) rewrite all the checking predicates to provide the information that 
> the detailed log needs?
>
> Thanks,
> Shriram
>

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


[racket-users] Re: Output out of order when using system procedure

2020-05-20 Thread Alex Harsanyi

Change the first line of your python script to:

#!/home/utils/Python-3.8.0/bin/python3 -u

Alex.

On Wednesday, May 20, 2020 at 5:00:12 PM UTC+8, Rock Nie wrote:
>
> Thx! sys.stdout.flush() works but in real use cases I cannot add 
> sys.stdout.flush() to every python print.
> Can I do anything in the racket side to solve the problem? Making the 
> interactive window behave like terminal perhaps?
>
> On Wednesday, May 20, 2020 at 4:49:30 PM UTC+8, Alex Harsanyi wrote:
>>
>> Short version: Try adding a "sys.stdout.flush()" after each of your print 
>> statements in your python script.
>>
>> Longer version: when you run that program in a terminal, the output is a 
>> TTY and the standard output is flushed after every line.  When you run it 
>> as a subprocess, the standard output is a pipe and it is buffered.
>>
>> This is not Racket specific, you would get the same problem if you ran 
>> "os.system("test.py")" in another python program.
>>
>> Alex.
>>
>> On Wednesday, May 20, 2020 at 4:15:02 PM UTC+8, Rock Nie wrote:
>>>
>>> This only happens in DrRacket.
>>>
>>> On Wednesday, May 20, 2020 at 1:16:44 PM UTC+8, Rock Nie wrote:
>>>>
>>>> I am running the system procedure in drracket's interactive window
>>>> (system "test.py")
>>>>
>>>> where test.py is
>>>> #!/home/utils/Python-3.8.0/bin/python3
>>>> import os
>>>>
>>>> print("Running cmd: date1")
>>>> print("Running cmd: date2")
>>>> os.system("date")
>>>> print("Running cmd: date3")
>>>> os.system("date")
>>>>
>>>> and the output is
>>>> Tue May 19 22:14:19 PDT 2020
>>>> Tue May 19 22:14:19 PDT 2020
>>>> Running cmd: date1
>>>> Running cmd: date2
>>>> Running cmd: date3
>>>> #t
>>>>
>>>> which is different from my expectation, can anyone help explain why?
>>>>
>>>>

-- 
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/52c084d4-8793-4e9e-a0d8-96d1ae64db7d%40googlegroups.com.


[racket-users] Re: Output out of order when using system procedure

2020-05-20 Thread Alex Harsanyi
Short version: Try adding a "sys.stdout.flush()" after each of your print 
statements in your python script.

Longer version: when you run that program in a terminal, the output is a 
TTY and the standard output is flushed after every line.  When you run it 
as a subprocess, the standard output is a pipe and it is buffered.

This is not Racket specific, you would get the same problem if you ran 
"os.system("test.py")" in another python program.

Alex.

On Wednesday, May 20, 2020 at 4:15:02 PM UTC+8, Rock Nie wrote:
>
> This only happens in DrRacket.
>
> On Wednesday, May 20, 2020 at 1:16:44 PM UTC+8, Rock Nie wrote:
>>
>> I am running the system procedure in drracket's interactive window
>> (system "test.py")
>>
>> where test.py is
>> #!/home/utils/Python-3.8.0/bin/python3
>> import os
>>
>> print("Running cmd: date1")
>> print("Running cmd: date2")
>> os.system("date")
>> print("Running cmd: date3")
>> os.system("date")
>>
>> and the output is
>> Tue May 19 22:14:19 PDT 2020
>> Tue May 19 22:14:19 PDT 2020
>> Running cmd: date1
>> Running cmd: date2
>> Running cmd: date3
>> #t
>>
>> which is different from my expectation, can anyone help explain why?
>>
>>

-- 
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/3244d6fe-493a-4cbf-8da7-8044152e0235%40googlegroups.com.


[racket-users] Re: Requesting feedback on CSS3 parser and tokenizer

2020-05-12 Thread Alex Harsanyi
I now very little about web technologies and web development, so this might 
be a stupid question:  could you explain what types of applications might 
need a to parse CSS files?  I can only think of one, and that is a web 
browser.  Are you working towards a web browser in Racket?

Alex.

On Wednesday, May 13, 2020 at 6:37:22 AM UTC+8, Sage Gerard wrote:
>
> I'm working to release a CSS3 tokenizer and parser to the catalog 
> tomorrow. 
>
> https://github.com/zyrolasting/css3-syntax
>
> The current state lacks tests, so any logic errors should keep me busy for 
> a little longer. I'm here to ask for bug reports and feedback in the issue 
> tracker since I had my head in the weeds long enough. 

-- 
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/268eace0-f69e-44d4-b59c-13ef767d1108%40googlegroups.com.


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

2020-05-06 Thread Alex Harsanyi
Every problem can be solved by adding another level of indirection (except 
perhaps having too many  levels of indirection :-) ).  You can put the code 
below in a separate file:

(define (make-info-menu-item parent target-table)
  (new menu-item%
  (label "info")
  (parent parent)
  (callback (lambda (menu-item event)
  (message-box "Info"
   (~a "You have selected " (length (send target-table get-
selected-row-indexes)) " rows")
   #f)

And use it like so:

(require "info-menu-item.rkt")
(define row-edit-menu (new popup-menu% ))
(define table3 ...)
(define info-menu (make-info-menu-item row-edit-menu table3)

You could also have just one "make-row-edit-menu" function which creates 
all menu items.

Alex.

On Thursday, May 7, 2020 at 7:50:01 AM UTC+8, James Platt wrote:
>
> I'm working on organizing and documenting some things and I have some 
> code, below, which works but I don't understand why.  Specifically, why 
> don't I get an error about table3 not being defined? 
>
> This is a very simplified version of what I'm working on.  What I actually 
> want to do is put all the code related to creating a standard table editing 
> menu in a file which I can then include wherever I want that menu.  The 
> full menu will be a lot of code.  Unfortunately I can't seem to get this to 
> work without either getting an error that row-edit-menu is not defined or 
> that table3 is not defined.  In other words, I want to be able to define 
> table3 in one file which requires the file where row-edit-menu is defined 
> but I can't seem to figure out how to get this to work.  It works just fine 
> when all the code is in one file, however. 
>
> James 
>
>
> #lang racket 
> (require racket/gui/base 
>  qresults-list 
>  ) 
>
> ;set up columns 
> (define (column1 data) (vector-ref data 0)) 
> (define (column2 data) (vector-ref data 1)) 
>
> (define my-columns 
>   (list 
>(qcolumn "Column1" column1 column1) 
>(qcolumn "Column2" 
> (lambda (row) 
>   ;(displayln row) 
>   ;(displayln (db-row-ref row "Column2" headers 1)) 
>   (if (number? (column2 row)) (number->string (column2 row)) 
> "");This allows a cell to be blank. 
>   ;(number->string (column2 row)) 
>   ) 
> column2) 
> 
>) 
>   ) 
>
> (define frame3 (new frame% 
>   [label "myTable 3"] 
>   [width 800] 
>   [height 600] 
>   )) 
>
>
> (define row-edit-menu (new popup-menu% )) 
>
> (define info-menu-item (new menu-item% 
>   (label "info") 
>   (parent row-edit-menu) 
>   (callback (lambda (menu-item event) 
>   (message-box "Info" 
>(~a "You have 
> selected " (length (send table3 get-selected-row-indexes)) " rows") 
>#f) 
>   )) 
>   )) 
>
> (define table3 
>(new (class qresults-list% (init) (super-new) 
>   [parent frame3] 
>   [pref-tag 'preferences-tag] 
>   [selection-type 'multiple] 
>   [right-click-menu row-edit-menu]) 
>   ) 
>
> (send table3 setup-column-defs my-columns) 
>
> (send frame3 show #t) 
>
> (send table3 add-row (vector "R1C1" 10)) 
> (send table3 add-row (vector "R2C1" 11)) 
> (send table3 add-row (vector "R3C1" 12)) 
> (send table3 add-row (vector "R4C1" 13)) 
>
>
>

-- 
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/01e04764-42b2-4619-8aff-32fbf4d68269%40googlegroups.com.


[racket-users] Re: plotting graphs with flipped y axes

2020-05-03 Thread Alex Harsanyi


On Monday, May 4, 2020 at 1:31:06 AM UTC+8, David Bremner wrote:
>
>
> Does anyone know how to achieve plots like the attached with racket's 
> plot module? I'm stuck trying to invert the y axis. I'd like the smaller 
> y values to be at the top of the plot. 
>
>
I am not aware of any plot parameter which would allow flipping the axis, 
but you can transform the data to be flipped and use an axis transform for 
the axis itself.  I wrote a blog post which is somewhat related: 
https://alex-hhh.github.io/2020/02/dual-axis-plots.html, the post covers 
plotting a second data series which has a different scale than the first. 
The same technique of making "guest" transforms can be used to flip an 
axis: you would call 
(make-guest-transform base-min base-max base-max base-min) to obtain the 
"flip" transform and only plot the "guest" which would be flipped.

Hope this helps,
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ace9b069-8454-4d50-8ed1-547ecad38cc0%40googlegroups.com.


[racket-users] Re: Strange find-files problem

2020-05-03 Thread Alex Harsanyi
The path is fine.  `ext` however is always void.  
get-current-platforms-icon-ext is incorrect, you don't need quotes around 
the platform names.

Also, the error message is incomplete, I am not sure if there was scroll 
bar, but the contract failure should have told you which argument was wrong.

Alex.
   

On Sunday, May 3, 2020 at 4:45:44 PM UTC+8, Dexter Lagan wrote:
>
> Hello Sunday coders,
>
>   So I made a QuickScript to compile to standalone executable in a 
> platform-independent manner - without zipping. It works great, and Laurent 
> gave me a hand with the file browsing part for Linux. However I'm 
> encountering a hard to track runtime error with find-files. I am listing 
> all files with a certain extension. In the past I have used string-suffix? 
> for this, but I found out about path-has-extension? and attempted to use it 
> instead. I'm getting an error with both. Here's the code :
>
> ;; find files of a given extension recursively from the current directory
> (define (find-files/ext path ext)
>   (define (ext-file? f)
> (and (not (void? f))
>  (or (path? f) (string? f))
>  (file-exists? f)
>  (path-has-extension? f ext)))
>   (find-files ext-file? path))
>
> The error I'm getting should not be possible. I have added all these 
> checks to try and catch it, to no avail:
>
> [image: Capture.PNG]
>
> ;; same as previous, but using string-suffix?
> (define (find-files/ext# path ext)
>   (define (ext-file? f)
> (and (not (void? f))
>  (or (path? f) (string? f))
>  (file-exists? f)
>  (string-suffix? (path->string f) ext)))
>   (find-files ext-file? path))
>
> When using string-suffix?, I'm getting a different error:
>
> [image: Capture2.PNG]
>   I have used find-files many times over the years and I have never seen 
> this. The start-path is issued from (path-only f), where f is the source 
> file path given by QuickScript for the current source file.
> If you're testing this code, note that when using path-has-extension?, the 
> icon file extension constants have to be prefixed with '#' to comply with 
> the function's param type.
> Here's the full source :
>
>
> https://github.com/DexterLagan/compile-to-standalone-quick/blob/master/compile-to-standalone.rkt
>   
>
>   Any help would be appreciated.
>
> Dex
>

-- 
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/109c94cb-7224-42ba-acca-79a9cb022600%40googlegroups.com.


Re: [racket-users] Should I stop sending packages to the catalog?

2020-05-01 Thread Alex Harsanyi


On Friday, May 1, 2020 at 9:12:55 PM UTC+8, Jesse Alama wrote:
>
> On Thursday, April 30, 2020 at 2:57:45 PM UTC+2, Jay McCarthy wrote:
>>
>>
>> This is simply a social standard though. There is nothing that 
>> technically prevents you from breaking compatibility, except that your 
>> users may be upset. You can post things on the package server that 
>> follows any rules you want, including conflicting with any other 
>> packages.
>>
>
> I'd like to second this point. There's nothing stopping you from pushing 
> whatever you want to your repo, and hence distributing whatever you want 
> via the package server. I've pushed breaking changes to my packages before, 
> and no one has complained, so I guess I didn't break any part of the 
> interface that they were using. (Or I have no users of my stuff at all, 
> which is certainly possible!)
>
> I don't know how many packages mention, in their description, that they're 
> experimental, explicitly warning me that the interface is unstable and 
> likely to change. I use 'em anyway because they offer useful functionality. 
> I don't recall being nailed by breaking changes, but perhaps I'm just 
> getting lucky.
>
> What exactly is the claim, anyway, about the package server not allowing 
> breaking changes? Is it that if you do a breaking change to your package, 
> then it's possible that other people's packages correspondingly break? If 
> so, then I think that's not a very interesting claim. Does the claim at 
> issue just amount to a restatement of the ethos that Jay mentioned about 
> trying to ensure backwards compatibility for a long time?
>

I think that there are two issues here: 

First there's backwards compatibility -- it is a good idea to keep your 
packages backwards compatible, although sometimes it can be difficult, 
especially with packages which were released too early, before their 
interface stabilized.

Than there are breaking changes.  This does include the backwards 
incompatible changes, but also includes defects.  Defects are 
unintentional, usually unknown to the author at the time of publishing the 
new package version, yet they can break the application.  

As an application author, when my application stops working after updating 
packages, it is little consolation that the API of a package remained 
backwards compatible.

Perhaps I was just unlucky, but I encountered show-stopper defects in the 
first two external packages I tried to use in my application. I had a local 
fix, but had to wait for the author several months to fix the problem (this 
is understandable, the author was busy and these packages were not his top 
priority).   The mechanism I came up with was driven by the following needs:

(1) sit out a package version because it has a defect
(2) while sitting out a package version, I want to be able to update 
other packages that are not affected by the defect
(3) use an alternate source for a package which contains a fix, until 
an official fix is released
(4) delay updating packages, until I have time to verify that the 
update does not break the application and/or address problems
(5) be able to reconstruct old software configurations including 
dependencies

Number (5) is very important to me: I have some development branches which 
are active for several months, and when I go bad to an older branch, to 
continue work, the last thing I want is to deal with a package upgrade -- 
this perhaps reflects personal circumstances: I quite often have 1 hour to 
try to progress a feature on an old branch, and if I spend 15 - 20 minutes 
merging master, updating packages and resolving conflicts, that's 25 - 30% 
of available time gone.
 

> (All this said, I'd like to learn more about setting up custom package 
> catalogs, as Alex mentioned, to take matters even more into your own hands.)
>

There is not much to it:  git submodules are widely documented, so I'll 
leave those out, but here is the script that sets up the package catalog 
https://github.com/alex-hhh/ActivityLog2/blob/master/etc/scripts/setup-catalog.sh

And here is the snipped from the build file which sets things up and 
installs packages (note that this install uses "isolation mode" to catch 
dependencies which are not tracked as submodules, don't use the -i switch 
on your development machine):
 

   
 bash ./etc/scripts/setup-catalog.sh -i pkgs/
 raco pkg install --auto tzinfo tzgeolookup data-frame plot-container


I also have added code to my application to verify that the packages are 
installed before building or compiling it and it produdces more user 
friendly error messages. (e.g. it tells the user that they forgot to 
install the "tzinfo" package, rather than failing with a "module not found" 
error).  You can find that here: 
https://github.com/alex-hhh/ActivityLog2/blob/777847f2cdb18ff09596848efc40a332e65da017/rkt/utilities.rkt#L446
 
Alex.
 

-- 
You received this message because you are subscribed to the Google Groups 

[racket-users] Re: Should I stop sending packages to the catalog?

2020-04-29 Thread Alex Harsanyi

You could both send packages to the package catalog and instruct your users 
to use a different package source if they wish to use old versions.  I 
don't see these two options in conflict with each other.

As an application writer, I am on the other side of this problem, by 
depending on other packages. Having limited time to work on my project I 
want to upgrade package dependencies at my own pace.   The solution I found 
is to use git submodules and add each package as a submodule to my 
application.  I  construct a catalog of these packages, at an exact git 
commit, and simply run a raco pkg install, knowing that the exact version 
that I want will be there.  From time to time, I update these submodules 
and allow some time for fixing any problems that might result from these 
updates.  This has worked reasonably well so far, and I can reliably 
reconstruct older versions of the application knowing that all dependencies 
will be correct for that old version.

For my part, for any packages that my application depends on, their authors 
can make any breaking changes they want, as this will not immediately break 
my application.  At a later date I can review these changes, update my 
application and move to the new version.

The only downside is that installed packages are at "user scope" rather 
than "application scope" so once installed from the git submodules, that 
package becomes available to all applications on my computer.   So far this 
has not been a real issue, although I had to uninstall, switch catalogs and 
re-install a few times.

I personally regard pkgs.racket-lang.org as the source for the latest 
package versions, for users which just started using the package. Users who 
need precise versioning, can always setup their own package catalogs (i 
discovered that it is a really simple process)

Alex.


On Thursday, April 30, 2020 at 12:47:25 AM UTC+8, Sage Gerard wrote:
>
> April 9th in the #general Slack channel taught me that there was no clean 
> way to
> release a breaking change in a package. I'm open to working on version 
> pinning
> support in raco pkg provided that a maintainer can walk me through some 
> code.
>
> In the meantime, as much as I appreciate the efforts made in the current 
> system,
> I'm considering stopping my contributions to the package catalog until 
> further notice.
> I'm open to submitting packages if I am confident in their longevity, but 
> I don't want
> to end up in the position I've been in for the last few weeks when 
> planning a release.
> That position being an inability to release an edition that is not in some 
> way "aware"
> of a prior edition. In my view, changing the package/collection name is an
> example of that problem, not a solution to it.
>
> I'm considering asking my users to specify different package sources in 
> their info.rkt
> files when dealing with my work. Before I commit to that decision, I 
> wanted to tap into
> those of you who have already been here. How have you handled breaking 
> changes
> for your projects? How have you communicated with your users to make sure 
> they
> were adequately prepared? Am I being too black-and-white about this?
>
> *~slg*
>
>
>

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


[racket-users] Re: ask a pict its colour?

2020-04-18 Thread Alex Harsanyi

I don't think such a procedure can be written. at least not for the general 
case.

First, the color of `(filled-rectangle 30 30)` is not black, but whatever 
color was installed in the drawing context when the filled rectangle was 
rendered.  You can change it to red using:

(colorize (filled-rectangle 20 20) "red")

Even if you could inspect the colorize pict, it would still not be 
sufficient for a general `get-color` function.  Users can write their own 
pict constructors using dc:


(define colors (list "red" "green" "blue" "yellow"))

(define (my-red-colorize other-pict)
  (dc (lambda (dc dx dy)

(define color (list-ref colors (random (length colors

(define old-pen (send dc get-pen))
(send dc set-pen (new pen% [width 1] [color color]))

(draw-pict other-pict dc dx dy)

(send dc set-pen old-pen))
  (pict-width other-pict)
  (pict-height other-pict)))

And a call like `(my-red-colorize (filled-rectangle 20 20))` will only 
result in a red rectangle about 25% of the time.

Even if you want to ignore cases like the above, what should `get-color` 
return for the picture below?

(hc-append (colorize (filled-rectangle 20 20) "red") (colorize 
(filled-rectangle 
20 20) "blue"))


Alex.


On Saturday, April 18, 2020 at 8:00:12 PM UTC+8, Raoul Schorer wrote:
>
> Hi,
>
> Using the 'pict' library, I could not find predicates regarding color in 
> the doc.
> Is there something like
>
> (get-color (filled-rectangle 30 30)) --> "black"
>
> somewhere?
> If not, how can I make a reliable color predicate?
>
> Thanks,
> Raoul
>

-- 
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/d3fa9021-63af-4129-bfb6-a82e219cfcf0%40googlegroups.com.


[racket-users] Re: plotting multiple data sets on one set of axes

2020-04-11 Thread Alex Harsanyi

The renderers  that you pass on to the `plot` function can be manipulated 
outside the call to plot, so you can read the datasets you need, construct 
a renderer for each one, group them in a list and pass them on to plot.  I 
am not familiar with Matlab, but based on your description, you can 
implement hold-on and hold-off as follows:

#lang racket
(require plot)

(define the-renderers '())

(define (hold-on renderer)
  (set! the-renderers (cons renderer the-renderers)))

(define (hold-off)
  (begin0
(plot (reverse the-renderers))
(set! the-renderers '(

;; add a renderer for SIN
(hold-on (function sin 0 10))

;; add a renderer for COS
(hold-on (function cos 0 10))

;; Show the plot
(hold-off)

Alternatively, if you want a separate plot for each function, you can 
implement hold-off as follows:

(define (hold-off-2)
  (begin0
(for/list ([renderer (reverse the-renderers)])
  (plot renderer))
(set! the-renderers '(

Alex.

On Thursday, April 9, 2020 at 2:35:04 PM UTC+8, greadey wrote:
>
> Hi All,
>
> Can anyone give me some pointers on plotting multiple data sets on one set 
> of axes.  Plotting two or more data sets on one set of axes is easy if you 
> know in advance what the data is called;
>
> (plot (list
>   (lines set1)
>   (points set2))
>  #:x-label "x" #:y-label "y")
>
> however I have a list of data sets generated from reading a bunch of files 
> in a directory and I wish to loop through the list and add each data-set to 
> an existing set of axes.
>
> Iterating through the data and plotting each set results in multiple plot 
> windows.
>
> In summary I am looking for something similar to Matlab's "hold on" e.g.
>
> ;Pseudo Matlab code
>
> figure()
> for idx = 1 : numel(list-of (list-of vector-pairs))
> plot(list-of (list-of vector-pairs))(idx)
> hold on
> end
> hold off
>
> I have got (plot-new-window? #t), however as far as I know this is just 
> causing a plot to appear in a new window rather than directly in the repl.
>
> Many thanks,
>
> greadey.
>

-- 
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/ec890e78-b254-4e7e-9970-6f0d46f50c20%40googlegroups.com.


[racket-users] Re: window on-move / move inconsistency: is this a bug?

2019-12-01 Thread Alex Harsanyi

On Monday, December 2, 2019 at 12:58:39 AM UTC+8, Simon Schlee wrote:
>
> created an issue for this:
> https://github.com/racket/gui/issues/149
>

Based on you description, it seems that the window manager you use on Linux 
will adjust the window position to make room for the border, but this seems 
to be specific to the window manager itself.  It is not necessarily a bug 
that `on-move` is called multiple times and not always in response to 
calling the `frame%/move`  method (for example, it will be called when the 
windows is dragged with the mouse).  

This does not seem like a Racket GUI problem to me: I think that if you 
wrote a GTK application in C, the behavior would be the same.

Also the windows platform is not without its quirks in this regard: if you 
use `frame%/move` to move the window to 0,0, you'll notice that the top 
menu bar is lined up with the top of the screen, but there is an 8 pixel 
gap on the left.  This is because, while only a 1 pixel border is drawn 
around the window, there are an extra 8 pixels of invisible border, so the 
user can find the resize handle for the window.  Visually, moving a window 
to 0,0 will not move it to the top-left corner of the screen.

On Windows, there are API calls you can access using FFI, which allow 
calculating the window border to adjust for it.  I suspect there are 
similar APIs on Linux for GTK.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/721a6840-e164-4b30-b4e7-707c3af37cde%40googlegroups.com.


[racket-users] Re: Looking for transducer early-adopters

2019-11-15 Thread Alex Harsanyi

I'm not sure if this would be useful to you, but, as part of writing my 
tzgeolookup package, I wrote a blog post exploring the performance of 
different ways in which the underlying data is organized.  As a result of 
that, I have a repository with 10 variants of the same program using 
different strategies, and these programs are all instrumented, so running 
them will run a test suite and print out the time taken by each procedure.  
You could implement a variant using transducers and compare it with all the 
others.

The repository is here: https://github.com/alex-hhh/time-zone-lookup-tests, 
and the blog post explains how the hole thing works:  
https://alex-hhh.github.io/2019/08/timezone-lookup.html

The final package uses vectors, so I am not sure that would be useful in 
converting it to transducers, but if you want to look at it, it is here: 
https://github.com/alex-hhh/tzgeolookup

Alex.



On Friday, November 15, 2019 at 3:18:23 PM UTC+8, Jack Firth wrote:
>
> Hello all! I'd like to get Rebellion's 
>  transducer 
>  and reducer 
>  libraries up to 
> feature parity with Racket's ordinary list-processing functions. So I'm 
> looking for people interested in migrating some of their open-source Racket 
> code to use transducers instead of using map / filter / fold / append-map / 
> etc. Even just pointing me to some of your code on GitHub that does list 
> processing would be a great help, since I could attempt to migrate it 
> myself and see if there's any functionality I'm missing that stands in the 
> way of migrating. Huge bonus points if your code has benchmarks I can run, 
> so I can compare the performance of manual list processing v.s. Rebellion 
> stream processing v.s. optimized for loops.
>

-- 
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/5df506a6-fa4c-4fa9-8897-998aa8d249a1%40googlegroups.com.


[racket-users] Re: raco setup equivalent for building standalone executables?

2019-11-08 Thread Alex Harsanyi

There is no such raco command, as far as I know.  I see two possible 
solutions to your problem:

1)  Place the raco commands in a shell script, so that the application can 
be built by running the single shell script

2) The raco pkg, make, exe and distribute commands all provide a Racket 
level API, so you could write a racket program which builds your 
application by running "racket build.rkt"

I took the second approach with my application, and the Racket program 
which builds it is here:  
https://github.com/alex-hhh/ActivityLog2/blob/master/build.rkt

In my application I decided not to install required modules, but instead to 
check if the required modules are present and report a helpful error 
message if they are not installed.

Hope this helps.

On Thursday, November 7, 2019 at 5:37:31 PM UTC+8, Martin DeMello wrote:
>
> I'd like to set up a project so that I can check out its git repo, call a 
> single raco command, and have it install all the packages it needs, compile 
> executables, and finally invoke raco distribute and generate a single 
> binary. I've gone through the docs for raco setup but it seems to be geared 
> towards installing into the current machine, and I couldn't find anything 
> else that looked relevant.
>
> martin
>

-- 
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/9761567c-fca1-4256-9599-a573fd60daf0%40googlegroups.com.


Re: [racket-users] Re: How to install an updated version of an installation-wide package?

2019-11-08 Thread Alex Harsanyi

On my machine, when I run the first command that you suggested, I get:

$ raco pkg update --lookup --catalog https://pkgs.racket-lang.org/ slatex
open-output-file: cannot open output file
  path: C:\Program Files\Racket\share\pkgs\_LOCKpkgs.rktd
  system error: Access is denied.; errid=5
Inferred package scope: installation

The problem is that my racket installation is read-only and cannot be 
modified by a non-admin user.  I suspect the situation would be the same on 
Linux, if Racket is installed in /usr/bin as root than the raco pkg update 
is run by a regular user.  

At least on Windows, Racket will install in C:/Program Files and this 
location is read-only by default, and anyone who installs Racket and tries 
to work on a package will encounter this problem: working on a package that 
ships with Racket requires a writable Racket installation, this was not 
obvious to me.  

So you are correct that one does not need to build Racket from sources, but 
"just run this raco command" does not work either...

Alex.

On Friday, November 8, 2019 at 9:58:23 AM UTC+8, Sam Tobin-Hochstadt wrote:
>
> You don't have to do that, there's just one extra step starting from a 
> pre-built distribution. 
>
> If you want to work on the "slatex" package for some reason, you'd do: 
>
> $ raco pkg update --lookup --catalog https://pkgs.racket-lang.org/ slatex 
> ... 
> $ raco pkg update --clone slatex 
>
> And then you have the "slatex" package linked to a clone in the 
> `slatex/` directory where you ran the second command. 
>
> Here's a demo: https://asciinema.org/a/lOASUq2O1AT8JHhGyNJzvOcqE 
>
> Sam 
>
> On Thu, Nov 7, 2019 at 8:28 PM Alex Harsanyi  > wrote: 
> > 
> > Hi Matthew, 
> > 
> > Thanks for clarifying this. 
> > 
> > The question was asked on this list several times in the past, and the 
> suggested approach was always to use `raco pkg update --clone`.  The 
> non-obvious part, at least to me, was that one has to clone and build 
> Racket before starting to work on any package that is shipped with the 
> Racket distribution, even if that package is in a separate repository. 
> > 
> > Alex. 
> > 
> > On Thursday, November 7, 2019 at 9:37:52 PM UTC+8, Matthew Flatt wrote: 
> >> 
> >> It's not technically ok to shadow a package in installation scope with 
> >> one in user scope, at least not if any package in installation scope 
> >> depends on the shadowed package. (That's why you have to use `--force` 
> >> to shadow in `--user` scope.) With that configuration, when the package 
> >> changes in user scope, then the installation-scope build is not 
> >> necessarily consistent with the changes. Things might work out anyway; 
> >> it depends on the nature of the dependency and the changes. 
> >> 
> >> The right answer may be a tool that starts with an existing 
> >> installation and more quickly clone it into another installation in a 
> >> user's space, and then a user can work on a package and rebuild 
> >> consistently. The configuration points and general tools to manage 
> >> packages are all there, but they need to be assembled and made 
> >> easy-to-use. 
> >> 
> >> Meanwhile, the current tools are better set up for starting with a 
> >> GitHub checkout and building there. In that setting, for example, it's 
> >> easier to use `raco pkg update --clone` to get started, as described at 
> >> 
> >> 
> https://docs.racket-lang.org/racket-build-guide/contribute.html#%28part._pkg-contribute%29
>  
> >> 
> >> 
> >> Matthew 
> >> 
> >> At Tue, 5 Nov 2019 15:48:41 -0800 (PST), Alex Harsanyi wrote: 
> >> > I wrote some notes about how to do something similar, when I worked 
> on the 
> >> > plot package: 
> >> > 
> >> > 
> >> > 
> https://alex-hhh.github.io/2018/01/changing-built-in-racket-packages.html 
> >> > 
> >> > These instructions will work for the case where Racket is installed 
> >> > globally and your current user does not have permissions to modify 
> any 
> >> > files in this global Racket installation.  They might not be the 
> simplest 
> >> > ones however, as I am not a raco pkg package expert either. 
> >> > 
> >> > Hope this helps, 
> >> > Alex. 
> >> > 
> >> > On Wednesday, November 6, 2019 at 2:18:18 AM UTC+8, Reuben Thomas 
> wrote: 
> >> > > 
> >> > > I'm trying to make a small improvement to the drracket package, and 
> of 
> >> > > course I'd like to

Re: [racket-users] Re: How to install an updated version of an installation-wide package?

2019-11-07 Thread Alex Harsanyi
Hi Matthew,

Thanks for clarifying this. 

The question was asked on this list several times in the past, and the 
suggested approach was always to use `raco pkg update --clone`.  The 
non-obvious part, at least to me, was that one has to clone and build 
Racket before starting to work on any package that is shipped with the 
Racket distribution, even if that package is in a separate repository.

Alex.

On Thursday, November 7, 2019 at 9:37:52 PM UTC+8, Matthew Flatt wrote:
>
> It's not technically ok to shadow a package in installation scope with 
> one in user scope, at least not if any package in installation scope 
> depends on the shadowed package. (That's why you have to use `--force` 
> to shadow in `--user` scope.) With that configuration, when the package 
> changes in user scope, then the installation-scope build is not 
> necessarily consistent with the changes. Things might work out anyway; 
> it depends on the nature of the dependency and the changes. 
>
> The right answer may be a tool that starts with an existing 
> installation and more quickly clone it into another installation in a 
> user's space, and then a user can work on a package and rebuild 
> consistently. The configuration points and general tools to manage 
> packages are all there, but they need to be assembled and made 
> easy-to-use. 
>
> Meanwhile, the current tools are better set up for starting with a 
> GitHub checkout and building there. In that setting, for example, it's 
> easier to use `raco pkg update --clone` to get started, as described at 
>
>
> https://docs.racket-lang.org/racket-build-guide/contribute.html#%28part._pkg-contribute%29
>  
>
>
> Matthew 
>
> At Tue, 5 Nov 2019 15:48:41 -0800 (PST), Alex Harsanyi wrote: 
> > I wrote some notes about how to do something similar, when I worked on 
> the 
> > plot package: 
> > 
> > 
> > 
> https://alex-hhh.github.io/2018/01/changing-built-in-racket-packages.html 
> > 
> > These instructions will work for the case where Racket is installed 
> > globally and your current user does not have permissions to modify any 
> > files in this global Racket installation.  They might not be the 
> simplest 
> > ones however, as I am not a raco pkg package expert either. 
> > 
> > Hope this helps, 
> > Alex. 
> > 
> > On Wednesday, November 6, 2019 at 2:18:18 AM UTC+8, Reuben Thomas wrote: 
> > > 
> > > I'm trying to make a small improvement to the drracket package, and of 
> > > course I'd like to test it! 
> > > 
> > > I have racket 7.4 installed on my Ubuntu system from the PPA, so of 
> course 
> > > drracket is installed as part of the installation. 
> > > 
> > > After reading the "raco pkg" docs, and searching the mailing list, I 
> can't 
> > > figure out how to make a user installation of the drracket package so 
> I can 
> > > test it. My best attempt so far is something like: 
> > > 
> > > raco pkg install ./drracket 
> > > raco pkg install: package is currently installed in a wider scope 
> > >   package: drracket 
> > >   installed scope: installation 
> > >   given scope: user 
> > > 
> > > Of course, I don't want to overwrite the installation's version of 
> > > drracket, I just want a user installation that takes precedence. 
> > > 
> > > I'm a total newbie with raco, so sorry if I've overlooked something 
> > > obvious. 
> > > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to racket...@googlegroups.com . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/racket-users/3635bd1f-ccde-41eb-b9d4-05cc6c36
>  
> > 777b%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/162bbd09-ed9e-4a33-853d-142e170cfc69%40googlegroups.com.


[racket-users] Re: How to install an updated version of an installation-wide package?

2019-11-05 Thread Alex Harsanyi
I wrote some notes about how to do something similar, when I worked on the 
plot package:


https://alex-hhh.github.io/2018/01/changing-built-in-racket-packages.html

These instructions will work for the case where Racket is installed 
globally and your current user does not have permissions to modify any 
files in this global Racket installation.  They might not be the simplest 
ones however, as I am not a raco pkg package expert either.

Hope this helps,
Alex.

On Wednesday, November 6, 2019 at 2:18:18 AM UTC+8, Reuben Thomas wrote:
>
> I'm trying to make a small improvement to the drracket package, and of 
> course I'd like to test it!
>
> I have racket 7.4 installed on my Ubuntu system from the PPA, so of course 
> drracket is installed as part of the installation.
>
> After reading the "raco pkg" docs, and searching the mailing list, I can't 
> figure out how to make a user installation of the drracket package so I can 
> test it. My best attempt so far is something like:
>
> raco pkg install ./drracket
> raco pkg install: package is currently installed in a wider scope
>   package: drracket
>   installed scope: installation
>   given scope: user
>
> Of course, I don't want to overwrite the installation's version of 
> drracket, I just want a user installation that takes precedence.
>
> I'm a total newbie with raco, so sorry if I've overlooked something 
> obvious.
>

-- 
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/3635bd1f-ccde-41eb-b9d4-05cc6c36777b%40googlegroups.com.


[racket-users] Re: drracket indentation in vim

2019-10-23 Thread Alex Harsanyi

Well, you could use the racket-mode from emacs to indent your files.  You 
will need to install GNU Emacs and racket-mode, and save the following in 
indent-racket-file.sh:

#!/bin/bash
FILE=$1
emacs --daemon --eval "
(progn
  (find-file \"$1\")
  (racket-mode)
  (indent-region (point-min) (point-max))
  (save-buffer (current-buffer))
  (kill-buffer (current-buffer))
  (setq confirm-kill-processes nil)
  (save-buffers-kill-terminal))"

You will than be able to indent racket files from the terminal by calling 
(and presumably you can setup vim to call this script).

indent-racket-file.sh some-file.rkt

This script will indent the file in place but you could write the file to a 
temporary one and indent that.  You could also update the shell script to 
read from stdin, save to a temporary file, load it in Emacs and indent it 
than pipe it out -- this would make the script work as a pipe, but it will 
not be very efficient.

Also, if Emacs startup is slow, you can write an indent helper function in 
elisp:

;; save to racket-indent-helper.el
(defun indent-racket-file (name)
  (find-file name)
  (racket-mode)
  (indent-region (point-min) (point-max))
  (save-buffer (current-buffer))
  (kill-buffer (current-buffer)))

and start emacs as a background process:

emacs --daemon --load racket-indent-helper.el

You can than update the shell script to be:

#!/bin/bash
FILE=$1
emacsclient --eval "(indent-racket-file \"$1\")"

Alex.

On Thursday, October 24, 2019 at 7:11:49 AM UTC+8, Martin DeMello wrote:
>
> Is there a good way to call out to the indentation code drracket uses from 
> within vim? even just manually piping the whole file through an indenter 
> would be fine.
>
> martin
>

-- 
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/895ceca0-8191-4e0c-96f6-a4077883be7d%40googlegroups.com.


[racket-users] Re: Parallel merge-sort leveraging futures

2019-10-07 Thread Alex Harsanyi
Hi Dominik,

I tried to use your package and you are missing a dependency for the 
`scribble-math` package in your info.rkt file, this has to be installed 
separately otherwise your package won't install.

However, I tried to use the `vector-futures-sort!` function and got an 
error:

> (vector-futures-sort! #(3 1 7 6 4) <)
. . vector-futures-sort!: broke its own contract
  promised: vector?
  produced: #
  in: the res result of
  (->i
   ((unsorted vector?))
   ((compare procedure?))
   (res vector?))
  contract from: /futures-sort/main.rkt
  blaming: /futures-sort/main.rkt
   (assuming the contract is correct)
  at: /futures-sort/main.rkt:40.2
> 

I would also be interested to know what performance gains did you get by 
using
futures.  I experimented with futures a few years ago and noticed that they
will block when accessing shared data structures.  My understanding is that
all the futures will wait for each other while trying to access and set
elements in the vector and this the execution will be mostly serial with no
performance gains.  I am curious if anything has changed with regards to 
this
in the last few years.

Alex.

On Monday, October 7, 2019 at 9:01:25 PM UTC+8, Dominik Pantůček wrote:
>
> Hello, 
>
> over the course of past few months I have been tasked with solving a 
> (real-world) problem of sorting the sums of all possible combinations of 
> numbers. Some boring accounting stuff revolving around invoices. As the 
> total number of combinations is 2^N where N is the number of source 
> numbers, this task got "interesting" once there were more than 24 
> numbers - that is on my laptop with: 
>
> model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 
>
> 4 cores, 8 hyper-threads and 16GB RAM. 
>
> Long story short, I had to implement a custom merge-sort for fxvectors 
> and managed to leverage futures for fully parallel execution. Now in 
> some spare time, I slightly polished the code and released it as 
> "futures-sort" package. 
>
> The source code is available on GitHub[1] and it is already in Racket 
> package index[2]. 
>
> The package provides four sorting functions - two for vector? and two 
> for fxvector?. There are two variants of each, one with progress 
> reporting and one without. For the original task I needed to show 
> progress using racket/gui gauge% and it might be helpful for others 
> (it's just a callback that gets current and total number of merges 
> performed regularly). 
>
> I would really appreciate any feedback regarding the naming conventions, 
> code style and generally anything else. 
>
> Yes, the tests are not there (yet). 
>
> The same algorithm without futures runs on par with Racket's default 
> sorting routines (tested for sets upto 2^30 - only 16G of memory here) 
> and for fixnums it is even (very slightly but consistently) faster than 
> vector-sort alone. With parallelism using futures it runs roughly N 
> times faster where N is the number reported by (processor-count). 
>
> I have already some benchmark results available and once I get more data 
> I am more than happy to share it as well. 
>
> The parallelism is configurable as parameter. 
>
> And yes, all of this can be seen in the documentation which is included 
> but I still have to look into how to build it - I was sort of assuming 
> this works automatically based on what I see for example in 
> scribble-math[3][4]. Any help with getting this right is also more than 
> welcome. 
>
>
> Lastly - thanks go out to Jens Axel Søgaard for pointing out that 
> fixnums and fxvectors might help (and why) and also to other helpful 
> folks on #racket at Freenode. 
>
>
> Cheers, 
> Dominik 
>
>
> [1] https://github.com/dzoep/futures-sort 
> [2] https://pkgd.racket-lang.org/pkgn/package/futures-sort 
> [3] https://docs.racket-lang.org/scribble-math/index.html 
> [4] https://pkgd.racket-lang.org/pkgn/package/scribble-math 
>
>

-- 
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/cc4e09cd-e968-4edf-8046-90e3cadb38fb%40googlegroups.com.


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

2019-10-07 Thread Alex Harsanyi
Hi Paulo,

I would be interested to know what your plans are for your Darwin package 
(which is a fork of the Frog blog generator, for those who didn't read the 
newsletter :-) ).  

Over the years several people have updated their copy of Frog with new 
features, you can see this on the Network tab in GitHub.  Do you plan to 
integrate these changes into Darwin and/or add new features to it?

Alex.

On Monday, October 7, 2019 at 11:01:15 PM UTC+8, Paulo Matos wrote:
>
> Hi, 
>
> RN Issue 17 is finally here. 
> https://racket-news.com/2019/10/racket-news-issue-17.html 
>
> Enjoy, 
>
> Paulo 
>

-- 
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/359319f6-9d06-4584-a8f5-caa127d75176%40googlegroups.com.


[racket-users] Re: Some guidance in setting up Racket as a game scripting language.

2019-10-02 Thread Alex Harsanyi

Unless your objective is to learn C and SDL, I would recommend writing the 
game entirely in Racket and using the Racket graphics facilities -- you 
will find that the performance will be more than enough for a roguelike 
game that you want to develop. Also, there are more people that can help 
you with Racket graphics questions, should you have any.

There is also a sdl2 package on pkgs.racket-lang.org, if you want to use 
SDL from Racket.

Alex.

On Wednesday, October 2, 2019 at 9:31:09 PM UTC+8, Hans Sjunnesson wrote:
>
> This is a hobby project of mine - a game in C, using SDL. I'd like to only 
> use C for the rendering part - rather use a scripting language for all of 
> the gameplay code. I want to try to use Racket for this - I've been doing 
> enough Clojure that I'm familiar with a lisp. My first approach was to 
> following along "Embedding into a Program" section of the Racket guide. But 
> I'm running into road blocks - and I can't find any good examples of 
> projects which embed Racket in a C program that calls functions in a Racket 
> environment. My initial plan was to define a Racket module that provided an 
> "init", an "update", and a "draw" function, then call those from the C 
> program. The embedding guide points me to using "raco" to generate a C 
> version of "racket/base", and that works - I can eval basic stuff, but I'm 
> getting an error when I (require "test.rkt"). So I'm guessing there's more 
> to be done with setting up the environment.
>
> My "test.rkt" file is this:
>
> #lang racket/base
>
> (printf "Hello World!\n")
>
> And this is the pertinent part of the main.c file, which links libracket.
>
> #include "scheme.h"
> #include "base.c"
>
> static int run(Scheme_Env* e, int argc, char* argv[]) {
> scheme_env = e;
>
> declare_modules(e);
>
> scheme_namespace_require(scheme_intern_symbol("racket/base"));
>
> Scheme_Config* config = scheme_current_config();
> Scheme_Object *curout = scheme_get_param(config, MZCONFIG_OUTPUT_PORT);
> Scheme_Object* v = scheme_eval_string("(+ 1 2)", scheme_env);
> scheme_display(v, curout);
> scheme_display(scheme_make_char('\n'), curout);
>
> scheme_eval_string("(require \"test.rkt\")", scheme_env);
>   
>   return 0;
> }
>
> int main(int argc, char* argv[]) {
> scheme_main_setup(1, run, argc, argv);
> return 0;
> }
>
> The output is:
>
> 3
> standard-module-name-resolver: collection not found
>   for module path: racket/base/lang/reader
>   collection: "racket/base/lang"
>   in collection directories:
>   context...:
>show-collection-err_0
>standard-module-name-resolver
>1/module-path-index-resolve
>do-dynamic-require5_0
>read-syntax3_0
>default-load-handler
>standard-module-name-resolver
>1/module-path-index-resolve
>perform-require!78.1
>for-loop_0
>expand-capturing-lifts
>temp118_0
>temp91_0
>compile15_0
>temp85_0
>
> I'm thinking that the environment isn't correctly setup here, the "in 
> collection directories" lists is empty.
>
> Am I going about this the wrong way though? Would I be better served in 
> setting up all of the game loops, etc. in Racket, then use FFI just for 
> rendering with SDL?
>
> The game I'm making is a roguelike, so performance isn't as critical.
>

-- 
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/4e4c300f-de73-496c-822d-41ea67f7da4d%40googlegroups.com.


[racket-users] Re: raco exe & distribute, and namespace-require'ing a module: missing racket/base?

2019-09-26 Thread Alex Harsanyi


On Wednesday, September 25, 2019 at 1:37:41 PM UTC+8, Jesse Alama wrote:
>
> I'm working on building a standalone executable for a #lang that can be 
> used in two ways:
>
> 1. foo awesome.foo: execute file awesome.foo, which is written in #lang foo
>
> 2. foo (no arguments): fire up a REPL. Expressions are to be written in 
> the foo language.
>
> I can get (1) to work, after wrestling with raco exe (using ++lang) and 
> raco distribute (using ++collects-copy). An invocation that works for me is:
>
> ### begin script snippet
>
> raco exe ++lang foo ++lang racket/base ++lang brag foo.rkt
>
> # copy the source code of foo into collects/foo
> mkdir -p collects/foo
>
> find . -mindepth 1 -maxdepth 1 -name '*.rkt' -exec cp {} collects/foo ';'
>
> raco distribute ++collects-copy collects dist foo
>
> ### end script snippet
>
> This works for making a standalone executable that can exectute foo 
> programs specified on the command line, but doesn't work for a REPL. The 
> difficulty seems to be the `namespace-require` part of `run-repl`, defined 
> like this:
>
> 
> (define (run-repl)
>   (parameterize ([current-namespace (make-base-empty-namespace)])
> (namespace-require 'foo/expander)
> (read-eval-print-loop)))
> 
>

This is a wild guess, but since no one replied, I would suggest two things 
to try:

1) try using `make-base-namespace` instead -- I am not sure what the 
difference is between "attached" and "attached + required", but sounds like 
`make-base-namespace` will require racket/base

2) try a compiled form:

(define (run-repl)
  (parameterize ([current-namespace (make-base-empty-namespace)])
(compile `(namespace-require `'foo/expander))
(read-eval-print-loop)))

Alex. 


> When I invoke the executable with no arguments, `run-repl` gets called. 
> But this leads to:
>
> 
> standard-module-name-resolver: collection not found
>   for module path: racket/base/lang/reader
>   collection: "racket/base/lang"
> 
>
> expander.rkt in foo is written in racket/base, so I suppose that's what 
> triggers the issue.
>
> My question, crudely put, is: How do I "embed" racket/base so that I can 
> use `namespace-require` as seen in `run-repl`? (I assume namespace-require 
> is what I need; if that's wrong, please do correct me.) It appears that 
> ++lang racket/base bit in raco exe isn't enough. A related question about 
> raco exe is: if racket/base isn't available, what *is* available?
>
>
>
>

-- 
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/0590b28c-2d3a-4245-a4da-c6deee8c53c3%40googlegroups.com.


Re: [racket-users] Re: Confusion with udp-receive!

2019-09-25 Thread Alex Harsanyi
Is there any tunneling involved for connecting to your AWS instance?

There is only one copy of the source port in an IP+UDP datagram, and this 
needs to be whatever the router is using for NAT, otherwise it would not be 
able to route replies back to your machine on the local network.  If you 
have some kind of tunneling set up to access the AWS servers, the router 
will wrap the original UDP packet into another UDP packet with its own 
source port, leaving the original source port unchanged.

You could also run tcpdump on your AWS server and dump the entire contents 
of the packet to see what the server actually receives.

Alex.

On Thursday, September 26, 2019 at 12:49:51 AM UTC+8, David Storrs wrote:
>
> We (my business partner and I) ran tcpdump on the router and 
> determined that no, it is not using the local port.  At first it bound 
> to 65395 and then after we stopped/started the process it bound to a 
> different port (49428) as expected. 
>
> After a bit of digging in the racket source code I note that the 
> various UDP functions are an FFI into librktio.  This leaves me with 
> two questions: 
>
> 1) Is it possible that there is a bug in the underlying C code? 
>
> 2) Why does Racket use a hand-rolled io library instead of a more 
> standard net stack element?  Is it for portability or...? 
>
> On Wed, Sep 25, 2019 at 9:28 AM David Storrs  > wrote: 
> > 
> > 
> > 
> > On Wed, Sep 25, 2019, 3:16 AM Alex Harsanyi  > wrote: 
> >> 
> >> Do you know what port the router is using for NAT?  Are you sure that 
> the router is not simply choosing the same port, so 25890 is both your 
> local port and the port used by the router? 
> > 
> > 
> > I haven't yet 100% ruled it out, but it doesn't look like it. I tried 
> sending traffic to :25890 and it was not received.  It's 
> possible that the port went stale and was released before my sending went 
> out, but that seems unlikely, as it should persist for seconds or tens of 
> seconds.My next step is to try again with a flood ping, just to be sure. 
> > 
> > Regards, it really shouldn't be doing that. If so, it's leaking 
> information about the inner network to the outside, and that's not what I'd 
> expect from the latest version of the FOSS OpenWRT. 
> > 
> > 
> >> 
> >> Alex. 
> >> 
> >> On Wednesday, September 25, 2019 at 1:08:16 PM UTC+8, David Storrs 
> wrote: 
> >>> 
> >>> udp-receive! is giving me unexpected results when my local machine -> 
> >>> router -> server shows the UDP port of the process running on the 
> >>> local machine instead of the one from the router.  I'm not sure how to 
> >>> get the router's port instead. 
> >>> 
> >>> 
> >>> The AWS server does this: 
> >>>   (define-values (len senders-host senders-port) (udp-receive! socket 
> buffer)) 
> >>> 
> >>> What I'm actually getting is: 
> >>> 
> >>> senders-host:   
> >>> senders-port: 25890 ; this is the UDP port bound by the process on the 
> >>> local machine 
> >>> 
> >>> What I'm expecting is: 
> >>> 
> >>> senders-host:   
> >>> senders-port:   >>> message from my machine to the AWS server> 
> >>> 
> >>> I've been digging through the  RFCs for UDP and Traditional NAT 
> >>> (https://www.ietf.org/rfc/rfc768.txt and 
> >>> https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't 
> >>> randomly gotten confused about how routers work but it seems to be 
> >>> what I recall: The local machine sends to the router using the port 
> >>> number 25890, the router rewrites it to an arbitrary port number 
> >>> chosen on the fly, the AWS server sees the router's assigned port and 
> >>> not 25890. 
> >>> 
> >>> What am I missing here?  I'm sure it's something embarrassingly 
> obvious. 
> >>> 
> >>> 
> >>> 
> >>> Simplified form of code for reference: 
> >>> 
> >>> --- 
> >>> shared code 
> >>> --- 
> >>> (struct Message (message-id attributes) #:prefab) 
> >>> (struct Binding-Request  Message () #:prefab) 
> >>> (struct Binding-Success-Response Message () #:prefab) 
> >>> (struct transport-address (ip port) #:prefab) 
> >>> 
> >>> (define (write-to-bytes v) 
> >>>   (define out (open-output-bytes)) 
> >>>   (write v out) 
> >>>   (get-out

[racket-users] Re: Confusion with udp-receive!

2019-09-25 Thread Alex Harsanyi
Do you know what port the router is using for NAT?  Are you sure that the 
router is not simply choosing the same port, so 25890 is both your local 
port and the port used by the router?

Alex.

On Wednesday, September 25, 2019 at 1:08:16 PM UTC+8, David Storrs wrote:
>
> udp-receive! is giving me unexpected results when my local machine -> 
> router -> server shows the UDP port of the process running on the 
> local machine instead of the one from the router.  I'm not sure how to 
> get the router's port instead. 
>
>
> The AWS server does this: 
>   (define-values (len senders-host senders-port) (udp-receive! socket 
> buffer)) 
>
> What I'm actually getting is: 
>
> senders-host:   
> senders-port: 25890 ; this is the UDP port bound by the process on the 
> local machine 
>
> What I'm expecting is: 
>
> senders-host:   
> senders-port:   message from my machine to the AWS server> 
>
> I've been digging through the  RFCs for UDP and Traditional NAT 
> (https://www.ietf.org/rfc/rfc768.txt and 
> https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't 
> randomly gotten confused about how routers work but it seems to be 
> what I recall: The local machine sends to the router using the port 
> number 25890, the router rewrites it to an arbitrary port number 
> chosen on the fly, the AWS server sees the router's assigned port and 
> not 25890. 
>
> What am I missing here?  I'm sure it's something embarrassingly obvious. 
>
>
>
> Simplified form of code for reference: 
>
> --- 
> shared code 
> --- 
> (struct Message (message-id attributes) #:prefab) 
> (struct Binding-Request  Message () #:prefab) 
> (struct Binding-Success-Response Message () #:prefab) 
> (struct transport-address (ip port) #:prefab) 
>
> (define (write-to-bytes v) 
>   (define out (open-output-bytes)) 
>   (write v out) 
>   (get-output-bytes out)) 
>
> --- 
> local machine: 
> --- 
> (define socket (udp-open-socket #f #f)) 
> (udp-bind! socket #f 25890 #t) 
> (thread 
>  (thunk 
>   (define-values (len senders-host senders-port) (udp-receive! socket 
> buffer)) 
>   (log-msg-debug "host: ~a, port ~a, buffer ~a " senders-host 
> senders-port buffer))) 
>
> (udp-send-to socket default-host default-port 
>  (wrap (Binding-Request 17 (hash 
>
> - 
> AWS server: 
> - 
> The server has its own UDP socket (bound to 54545, fwiw) and a receive 
> loop that identifies the Binding-Request and routes it to the 
> following code: 
>
> (define-values (len senders-host senders-port) (udp-receive! 
> socket buffer) 
> (define mapped-address (transport-address senders-host senders-port)) 
> (define msg-out 
>   (Binding-Success-Response mid 
> (hasheq 'mapped-address 
> mapped-address))) 
>  (udp-send-to socket senders-host senders-port (wrap msg-out)) 
>

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


[racket-users] Interactive Heat Maps

2019-09-21 Thread Alex Harsanyi
A few days ago I posted about adding maps to the DrRacket REPL -- while a 
nice demo, this is not why I implemented the `map-snip%` object.  The 
reason I implemented it is because I wanted to add maps to an interface 
which was designed for displaying plots produced by `plot-snip`.   While 
this is not technically a racket topic, the application itself is written 
in Racket and I think it is a nice showcase of Rackets' GUI capabilities, 
so here is a demo:

https://youtu.be/5Op6ywIqTRc

There is quite lot going  on "behind the scenes" here, and I covered some 
of the topics in this blog post, but if you have any questions I am happy 
to answer them: 
https://alex-hhh.github.io/2019/09/interactive-heat-maps.html

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ce9135a4-f317-4d6c-a3b7-eb2de88dc310%40googlegroups.com.


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

2019-09-18 Thread Alex Harsanyi


On Thursday, August 29, 2019 at 9:39:05 AM UTC+8, Alex Harsanyi wrote:
>
>
>
> On Wednesday, August 28, 2019 at 11:45:10 PM UTC+8, Joel Dueck wrote:
>>
>> On Wednesday, August 28, 2019 at 12:10:56 AM UTC-5, Alex Harsanyi wrote:
>>>
>>> I am curious to know how you plan to comply with section 4.d of the 
>>> LGPL, which states that the users of your application must be able to 
>>> replace the LGPL "library" with a modified version of their own -- this 
>>> means all the racket packages that you use in your application (even the 
>>> ones shipped with Racket):
>>>
>>
>> Excellent question. I don’t intend to comply with the LGPL.
>>
>>
> I was really hoping that you actually had a solution to the problem I
> mentioned...
>
> The LGPL clarification on https://download.racket-lang.org/license.html 
> states
> that we need to be able to re-link the software with modified versions of
> Racket.  I am not sure how to achieve that, so here are my technical
> questions, directed to anyone on this list who can answer them:
>
> 0) To simplify things, the same Racket version and OS can be used for both
>"raco make" to produce the bytecode files as well as the "raco exe" 
> part to
>"link" the executable.
>
> 1) Given a set of ZO files compiled using "raco make", is it possible to
>create an executable from these ZO files using "raco exe", or a call to
>`create-embedded-executable`, without having access to the source files
>themselves?  If it is possible, how?
>
> 2) Is it possible to distribute a Racket package as ZO files only and 
> actually
>be able to use it from Racket? If it is possible, how?
>

I did some investigations and it it turns out that the answer to both 
questions is YES, one can create and distribute the bytecode for a package 
or application and allow the user to link them with a, possibly modified, 
Racket runtime.  The trick is to use "raco pkg create", which allows 
creating binary only packages and works for regular applications too.  
Since no one responded to my message, it seems this is not common 
knowledge, so I wrote some notes about it, in case others find it useful: 
https://alex-hhh.github.io/2019/09/racket-binary-packages.html

Alex.
 

>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0275ec03-2c64-4f71-b6d1-a40f3543b47e%40googlegroups.com.


Re: [racket-users] What is a (the?) way to track requirements for a web or app with Racket?

2019-09-16 Thread Alex Harsanyi


On Monday, September 16, 2019 at 5:04:58 PM UTC+8, Bogdan Popa wrote:
>
>
> Marc Kaufmann writes: 
>
> > this is surely answered somewhere, but I have not made much progress. If 
> > you know python, what I want to do is essentially 
> > 
> > $ pip install requirements.txt 
> > 
>
> Although it's not exactly the same thing, I use `info.rkt'[1][2] 
> (similar to `setup.py') for this purpose and each one of 
> my web apps is its own package. 
>

Does this mean that the application itself is available as a package and 
you can require files from inside the application from another program?  
More importantly, can you have two copies of the application installed on 
your system, for example for development purposes?
 

>
> Here's an example of what that ends up looking like: 
>
>
> https://github.com/Bogdanp/koyo/blob/master/koyo-lib/blueprints/standard/app-name-here/info.rkt
>  
>
> and 
>
>
> https://github.com/Bogdanp/koyo/tree/master/koyo-lib/blueprints/standard#first-time-setup
>  
>
> For deployment, I leverage `raco exe' and `raco distribute' to create 
> self-contained distributions that I can ship to my server. 
>
> [1]: https://docs.racket-lang.org/pkg/metadata.html 
> [2]: https://docs.racket-lang.org/raco/setup-info.html 
>

-- 
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/26467935-c8b8-4965-9e2c-659f64fd9701%40googlegroups.com.


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

2019-09-09 Thread Alex Harsanyi


On Monday, September 9, 2019 at 10:09:02 PM UTC+8, Prokop Hapala wrote:
>
> Hi, 
>
> I recently found Racket when I was searching some tutorials about Lisp and 
> Metaprogramming. I really like that the community around DrRacket seems to 
> be very much interested in education, making talks and tutorials even for 
> childerens. The doc pages https://docs.racket-lang.org/ seems to be best 
> what I found up to now in Lisp-world.
>
> What I'm missing however is some example codes which I can just simply 
> download, load in DrRacket, run, and see what it does (without copying it 
> step by step from doc-pages). This is my favourite way of learning - 
> reverse-engineering finished cool demos. I don't like reading tutorials 
> step-by-step. I like just browsing over code examples and see what is 
> interesting.   
>
> I was searching for some time to find some links e.g. to 
> github-repositories with example codes for Racket, but I did not found 
> almost anything usefull (easily accessible, easy to make i run).
>
> Maybe you know processing (https://processing.org/), it is in some 
> aspects similar to DrRacket
>
>- It tries to bring programming to non-programmers (e.g. arts, 
>humanities)
>- It has own minimalistic IDE to make it easier for people
>
> but unlike DrRacket it has huge amount of example codes packed within the 
> standard instalation, (see attached picture). I think it would be great 
> addition to DrRacket, exactly in direction of what you try to achieve.
>
> [image: Screenshot_2019-09-09_15-55-18.png]
>
>
>
>
>
>
>
>
>
>
>
>
> Other great thing which help me learn to program are 
> https://www.shadertoy.com/
> https://www.openprocessing.org/
>
> ... it would be greate if something similar would be there for Racket, 
> Lisp, Haskell or any of these kind of languages
>

Most of the tutorials I wrote on GUI various topics have a link to a Github 
Gist which has the full code which you can download and run in DrRacket 
directly.  The link is usually provided at the end of each blog post -- 
some posts also require additional data files, and links to those files are 
provided too.

Here is a link to those blog posts, but not all of them are tutorials, 
though: https://alex-hhh.github.io/tags/racket.html
 
Alex.

>
> ( I come from graphics/physics background (imperative languages 
> C/C++,GLSL,OpenCL ...  , high-performace), I have no previous experience 
> with any Lisp-family language nor other functional language  )
>
>

-- 
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/eaa60f9e-5cdb-4588-b143-bda156f37725%40googlegroups.com.


Re: [racket-users] [OT] Cities and GPS

2019-09-06 Thread Alex Harsanyi
In fact, I updated the data frame package to be able to read the CSV file 
directly, without having to process it, so the example now becomes:

#lang racket
(require data-frame)

(define df (df-read/csv "worldcities.csv" #:quoted-numbers? #t))

(define ((is-city? name) v)
  (equal? (vector-ref v 0) name))

(df-select* df "city" "country" "lat" "lng" #:filter (is-city? "Perth"))

;; Produces:

;; '#(#("Perth" "Australia" -31.955 115.84)
;;  #("Perth" "United Kingdom" 56.4003 -3.47))

Alex.


On Saturday, September 7, 2019 at 8:13:28 AM UTC+8, Alex Harsanyi wrote:
>
>
> That database is simple enough to use directly, not sure if it needs a 
> separate package:
>
> #lang racket
> (require data-frame)
>
> ;; The worldcities.csv file has all values quoted, so df-read/csv reads 
> them
> ;; all as strings.  Convert a series to numbers.
> (define (->numeric df series)
>   (df-add-derived df series (list series) (lambda (v) (string->number (car 
> v)
>   
> (define df (df-read/csv "worldcities.csv"))
>
>   ;; Convert numeric series to numbers
> (for ([series '("lat" "lng" "population")])
>   (->numeric df series))
>
> (define ((is-city? name) v)
>   (equal? (vector-ref v 0) name))
>
> (df-select* df "city" "country" "lat" "lng" #:filter (is-city? "Perth"))
>
> ;; The above call produces:
>
> ;; '#(#("Perth" "Australia" -31.955 115.84)
> ;;#("Perth" "United Kingdom" 56.4003 -3.47))
>
>
>
> Alex.
>
> On Friday, September 6, 2019 at 8:37:59 PM UTC+8, Laurent wrote:
>>
>> There's a small free database here too:
>> https://simplemaps.com/data/world-cities
>>
>> I started writing a simple query system for it this morning (csv->rktd, 
>> then just list of assoc operations). 
>>
>> On Fri, Sep 6, 2019 at 1:35 PM Sage Gerard  wrote:
>>
>>> Would geonames help? 
>>> http://www.geonames.org/
>>>
>>>
>>>  Original Message 
>>> On Sep 6, 2019, 8:28 AM, Hendrik Boom < hen...@topoi.pooq.com> wrote:
>>>
>>>
>>> On Thu, Sep 05, 2019 at 10:42:01PM -0700, Alex Harsanyi wrote:
>>> ...
>>> >
>>> > >
>>> > > A package containing a database of the positions of the major cities 
>>> and
>>> > > countries would be nice too :)
>>> > >
>>> >
>>> >
>>> > A general facility able to resolve location names to GPS coordinates 
>>> would
>>> > be a lot of work, and I don't have time for such a thing. Sorry.
>>>
>>> There must be a GPS database of cities available somewhere already.
>>>
>>> -- hendrik
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to racket...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/20190906122801.w5yhwfbzkods2fqr%40topoi.pooq.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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com
>>>  
>>> <https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com?utm_medium=email_source=footer>
>>> .
>>>
>>>

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


Re: [racket-users] [OT] Cities and GPS

2019-09-06 Thread Alex Harsanyi

That database is simple enough to use directly, not sure if it needs a 
separate package:

#lang racket
(require data-frame)

;; The worldcities.csv file has all values quoted, so df-read/csv reads them
;; all as strings.  Convert a series to numbers.
(define (->numeric df series)
  (df-add-derived df series (list series) (lambda (v) (string->number (car v
)
  
(define df (df-read/csv "worldcities.csv"))

  ;; Convert numeric series to numbers
(for ([series '("lat" "lng" "population")])
  (->numeric df series))

(define ((is-city? name) v)
  (equal? (vector-ref v 0) name))

(df-select* df "city" "country" "lat" "lng" #:filter (is-city? "Perth"))

;; The above call produces:

;; '#(#("Perth" "Australia" -31.955 115.84)
;;#("Perth" "United Kingdom" 56.4003 -3.47))



Alex.

On Friday, September 6, 2019 at 8:37:59 PM UTC+8, Laurent wrote:
>
> There's a small free database here too:
> https://simplemaps.com/data/world-cities
>
> I started writing a simple query system for it this morning (csv->rktd, 
> then just list of assoc operations). 
>
> On Fri, Sep 6, 2019 at 1:35 PM Sage Gerard  > wrote:
>
>> Would geonames help? 
>> http://www.geonames.org/
>>
>>
>>  Original Message 
>> On Sep 6, 2019, 8:28 AM, Hendrik Boom < hen...@topoi.pooq.com 
>> > wrote:
>>
>>
>> On Thu, Sep 05, 2019 at 10:42:01PM -0700, Alex Harsanyi wrote:
>> ...
>> >
>> > >
>> > > A package containing a database of the positions of the major cities 
>> and
>> > > countries would be nice too :)
>> > >
>> >
>> >
>> > A general facility able to resolve location names to GPS coordinates 
>> would
>> > be a lot of work, and I don't have time for such a thing. Sorry.
>>
>> There must be a GPS database of cities available somewhere already.
>>
>> -- hendrik
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/20190906122801.w5yhwfbzkods2fqr%40topoi.pooq.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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com?utm_medium=email_source=footer>
>> .
>>
>>

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


Re: [racket-users] Embedding a map widget in the DrRacket REPL

2019-09-05 Thread Alex Harsanyi


On Thursday, September 5, 2019 at 10:14:15 PM UTC+8, Laurent wrote:
>
> This is utterly cool!
>
> If I may, I suggest to rebind up and down to page up and page down (or 
> even the converse, as "down" means to me "go downwards towards Earth"), use 
> the arrows to navigate NESW, and bind mouse scrolls to zooming too.
>

The map-snip% already uses the mouse wheel for zooming, but DrRacket binds 
those events to scroll the REPL window up and down, so the snip never 
receives these events -- this is the reason why I added the "up" and "down" 
keys.   The REPL example is just a side benefit of using snips for the map 
object, but for my own use, I put the map-snip% in a pasteboard% which I 
fully control, so the keyboard navigation is not an issue.  Perhaps I'll 
add some keymap% bindings for more general control of the map snip, so that 
users can bind whatever keys they prefer...
 

>
> A package containing a database of the positions of the major cities and 
> countries would be nice too :)
>


A general facility able to resolve location names to GPS coordinates would 
be a lot of work, and I don't have time for such a thing.  Sorry.

Alex.

 

> On Wed, Sep 4, 2019 at 12:50 PM Stephen De Gabrielle  > wrote:
>
>> Dr Racket is amazing. Need to a demo of this and plot side by side. 
>>
>> DrRacket is so close to being an electronic lab notebook it’s almost 
>> painful
>>
>> Stephen
>>
>> On Wed, 4 Sep 2019 at 12:20, Sage Gerard > > wrote:
>>
>>> How cool is that! DrRacket's flexibility is pretty amazing 
>>>
>>>
>>>
>>>  Original Message 
>>> On Sep 4, 2019, 5:41 AM, Alex Harsanyi < alexha...@gmail.com 
>>> > wrote:
>>>
>>>
>>>
>>> As part of another project, I had to update my map-widget to act as a 
>>> snip% so it can be inserted into a pasteboard%.   An unintended side 
>>> benefit of this work is that maps can now be embedded in the DrRacket REPL 
>>> -- this in itself is not very useful, but it does make for a cool demo, so 
>>> I thought I would record a video of it and share it here:  
>>> https://youtu.be/MrS0FG-X8DI
>>>
>>> Here is a screenshot too:
>>>
>>> [image: map-snip-demo.PNG]
>>>
>>>
>>> For those who want to try it out, you can install the map-widget 
>>> package, than type the following in the REPL:
>>>
>>> (require map-widget)
>>> (new map-snip%)
>>>
>>> Note that map tile download is not very fast, but the code does cache 
>>> all downloaded data locally, this means that once tiles are downloaded, 
>>> subsequent runs which show the same area will be fast.  In the linked video 
>>> you don't see any tiles being loaded, as I did a practice run before 
>>> recording it and all map data was locally available, making it load 
>>> instantly -- you can do that too if you run the code a second time.
>>>
>>> And in case you want to have a look at the code itself, it is here: 
>>> https://github.com/alex-hhh/map-widget
>>>
>>> Enjoy,
>>> 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...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/fdc50657-4125-4c2f-b0a9-03bc701fe869%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/racket-users/fdc50657-4125-4c2f-b0a9-03bc701fe869%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to racket...@googlegroups.com .
>>>
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/IyQJpx7V3hwBoRhSKLdOfYxktKfIFtpP0_Wl5_be2mPSg6RIUSJQMQHR6tTBL6qr0FbY210RV2u9ksNrj1vbh_KS3Dh9GguXONj-slVw75s%3D%40sagegerard.com
>>>  
>>> <https://groups.google.com/d/msgid/racket-users/IyQJpx7V3hwBoRhSKLdOfYxktKfIFtpP0_Wl5_be2mPSg6RIUSJQMQHR6tTBL6qr0FbY210RV2u9ksNrj1vbh_KS3Dh9GguXONj-slVw75s%3D%40sagegerard.com?utm_medium=email_source=footer>
>>> .
>>>
>>> -- 
>> 
>>
>> -- 
>> 

Re: [racket-users] Embedding a map widget in the DrRacket REPL

2019-09-05 Thread Alex Harsanyi


On Wednesday, September 4, 2019 at 7:50:19 PM UTC+8, Stephen De Gabrielle 
wrote:
>
> Dr Racket is amazing. Need to a demo of this and plot side by side. 
>

I can do better than just put a plot and a map widget side by 
side: https://youtu.be/R2KU0ZvIJws

Alex.
 

>
> DrRacket is so close to being an electronic lab notebook it’s almost 
> painful
>
> Stephen
>
> On Wed, 4 Sep 2019 at 12:20, Sage Gerard  > wrote:
>
>> How cool is that! DrRacket's flexibility is pretty amazing 
>>
>>
>>
>> ---- Original Message 
>> On Sep 4, 2019, 5:41 AM, Alex Harsanyi < alexha...@gmail.com 
>> > wrote:
>>
>>
>>
>> As part of another project, I had to update my map-widget to act as a 
>> snip% so it can be inserted into a pasteboard%.   An unintended side 
>> benefit of this work is that maps can now be embedded in the DrRacket REPL 
>> -- this in itself is not very useful, but it does make for a cool demo, so 
>> I thought I would record a video of it and share it here:  
>> https://youtu.be/MrS0FG-X8DI
>>
>> Here is a screenshot too:
>>
>> [image: map-snip-demo.PNG]
>>
>>
>> For those who want to try it out, you can install the map-widget package, 
>> than type the following in the REPL:
>>
>> (require map-widget)
>> (new map-snip%)
>>
>> Note that map tile download is not very fast, but the code does cache all 
>> downloaded data locally, this means that once tiles are downloaded, 
>> subsequent runs which show the same area will be fast.  In the linked video 
>> you don't see any tiles being loaded, as I did a practice run before 
>> recording it and all map data was locally available, making it load 
>> instantly -- you can do that too if you run the code a second time.
>>
>> And in case you want to have a look at the code itself, it is here: 
>> https://github.com/alex-hhh/map-widget
>>
>> Enjoy,
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/fdc50657-4125-4c2f-b0a9-03bc701fe869%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/fdc50657-4125-4c2f-b0a9-03bc701fe869%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/IyQJpx7V3hwBoRhSKLdOfYxktKfIFtpP0_Wl5_be2mPSg6RIUSJQMQHR6tTBL6qr0FbY210RV2u9ksNrj1vbh_KS3Dh9GguXONj-slVw75s%3D%40sagegerard.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/IyQJpx7V3hwBoRhSKLdOfYxktKfIFtpP0_Wl5_be2mPSg6RIUSJQMQHR6tTBL6qr0FbY210RV2u9ksNrj1vbh_KS3Dh9GguXONj-slVw75s%3D%40sagegerard.com?utm_medium=email_source=footer>
>> .
>>
>> -- 
> 
>

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


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

2019-08-28 Thread Alex Harsanyi


On Wednesday, August 28, 2019 at 11:45:10 PM UTC+8, Joel Dueck wrote:
>
> On Wednesday, August 28, 2019 at 12:10:56 AM UTC-5, Alex Harsanyi wrote:
>>
>> I am curious to know how you plan to comply with section 4.d of the LGPL, 
>> which states that the users of your application must be able to replace the 
>> LGPL "library" with a modified version of their own -- this means all the 
>> racket packages that you use in your application (even the ones shipped 
>> with Racket):
>>
>
> Excellent question. I don’t intend to comply with the LGPL.
>
>
I was really hoping that you actually had a solution to the problem I
mentioned...

The LGPL clarification on https://download.racket-lang.org/license.html 
states
that we need to be able to re-link the software with modified versions of
Racket.  I am not sure how to achieve that, so here are my technical
questions, directed to anyone on this list who can answer them:

0) To simplify things, the same Racket version and OS can be used for both
   "raco make" to produce the bytecode files as well as the "raco exe" part 
to
   "link" the executable.

1) Given a set of ZO files compiled using "raco make", is it possible to
   create an executable from these ZO files using "raco exe", or a call to
   `create-embedded-executable`, without having access to the source files
   themselves?  If it is possible, how?

2) Is it possible to distribute a Racket package as ZO files only and 
actually
   be able to use it from Racket? If it is possible, how?

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/44d6a1fc-677f-4a8b-a584-92c3bf12ab32%40googlegroups.com.


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

2019-08-27 Thread Alex Harsanyi


On Wednesday, August 28, 2019 at 12:17:46 AM UTC+8, Joel Dueck wrote:
>
> On Friday, August 23, 2019 at 10:40:13 AM UTC-5, Alexis King wrote:
>>
>> Distributing a closed-source, non-LGPL Racket application without 
>> violating Racket’s licensing terms is likely to be very difficult or 
>> impossible, pending the still-ongoing MIT + Apache 2 relicensing effort. 
>>
>>
> This was startling for me to read, as I have been contemplating doing that 
> very thing.
>

I am curious to know how you plan to comply with section 4.d of the LGPL, 
which states that the users of your application must be able to replace the 
LGPL "library" with a modified version of their own -- this means all the 
racket packages that you use in your application (even the ones shipped 
with Racket):

Option 4.d.1 is not possible, since racket packages are not shared 
libraries.  

Option 4.d.0 would essentially require you to provide your customers with 
all the compiled object code (.zo files), along with instructions on how 
the user can reconstruct your application using a different Racket version 
-- I am not sure if this is even possible.  I guess, you could provide your 
customers with the source code for your application (along with a license 
which prevents them from re-distributing it), in this case they would be 
able to "link in" another version of Racket.  Perhaps there are other ways?

I like the intent of LGPL, but I think this detail makes it a poor fit for 
an environment like Racket.

Also, I am not a lawyer.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c1dc8177-429f-4b08-a817-4eeb2fcc2f09%40googlegroups.com.


[racket-users] Re: Error when I try to use slideshow?

2019-08-23 Thread Alex Harsanyi
If anyone is interested, this is the minimal program which reproduces the 
issue on Windows 10, version1809:

#lang racket/gui
(require racket/draw)

(define f (new frame% [label "hello"] [width 100] [height 100]))

(define bmp
  (let* ([bm (make-object bitmap% 32 32)]
 [dc (make-object bitmap-dc% bm)])
(send dc set-brush "red" 'solid)
(send dc draw-rectangle 0 0 (send bm get-width) (send bm get-height))
(send dc set-bitmap #f)
bm))

(send f set-icon bmp #f 'both)
(send f show #t)


Any program which tries to set the icon on a frame will fail regardless of 
the icon.  Slideshow fails because it tries to set the icon on the frame.  
It seems that the W32 API call CreateIconIndirect() fails because it thinks 
the bitmap passes in is invalid...

Alex.

On Thursday, August 22, 2019 at 12:58:13 PM UTC+8, Alex Harsanyi wrote:
>
> This may or may not work for them, but ask the user to open the 
> "viewer.rkt" file in their racket installation (it should be in C:\Program 
> Files\Racket\share\pkgs\slideshow-lib\slideshow) and comment out the 
> `set-icon` call around line 1512.   That is, comment out the following 
> block:
>
> (let* ([bm slideshow-bm]
>[mbm slideshow-mbm])
>   (when (send bm ok?)
> (send f set-icon bm (and (send mbm ok?) mbm) 'both)))
>
> This is the line in GitHub:
>
>
> https://github.com/racket/slideshow/blob/c61c80de63cf7b2197d67c078bdc9133823c0030/slideshow-lib/slideshow/viewer.rkt#L1509
>
> ---
>
> Others may come up with better workarounds, but this looks to me like a 
> problem with the Racket GUI library.  Slideshow fails on my home PC but 
> works on my work PC, both Windows 10 but different build numbers.  The 
> problem is that the windows CreateIconIndirect API call is passed an 
> invalid parameter (this is what code 87 means).  Not sure what the invalid 
> parameter is (or why it is invalid), but it is probably either the bitmap 
> or the mask.
>
> Alex.
>
> On Thursday, August 22, 2019 at 11:40:45 AM UTC+8, Stephen De Gabrielle 
> wrote:
>>
>> Hi
>>
>> I’m trying to help a user who is getting an error when trying to run 
>> slideshow:
>>
>> I typed "#lang slideshow" into DrRacket and got the following error:
>>
>> CreateIconIndirect: call failed (87)
>>
>> Interactions disabled: slideshow does not support a REPL (no 
>> #%top-interaction)
>>
>> They have two computers - slideshow works on a newer pc(win 10) but fails 
>> on one that has been upgraded from windows 7 to 10. I can’t determine any 
>> other difference.
>>
>>
>> Any ideas how I can help this user ?
>>
>>
>>
>> https://www.reddit.com/r/Racket/comments/ct95b0/error_when_i_try_to_use_slideshow/?utm_source=share_medium=ios_app
>>
>>
>> Kind regards
>>
>> Stephen
>>
>

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


[racket-users] Re: Error when I try to use slideshow?

2019-08-21 Thread Alex Harsanyi
This may or may not work for them, but ask the user to open the 
"viewer.rkt" file in their racket installation (it should be in C:\Program 
Files\Racket\share\pkgs\slideshow-lib\slideshow) and comment out the 
`set-icon` call around line 1512.   That is, comment out the following 
block:

(let* ([bm slideshow-bm]
   [mbm slideshow-mbm])
  (when (send bm ok?)
(send f set-icon bm (and (send mbm ok?) mbm) 'both)))

This is the line in GitHub:

https://github.com/racket/slideshow/blob/c61c80de63cf7b2197d67c078bdc9133823c0030/slideshow-lib/slideshow/viewer.rkt#L1509

---

Others may come up with better workarounds, but this looks to me like a 
problem with the Racket GUI library.  Slideshow fails on my home PC but 
works on my work PC, both Windows 10 but different build numbers.  The 
problem is that the windows CreateIconIndirect API call is passed an 
invalid parameter (this is what code 87 means).  Not sure what the invalid 
parameter is (or why it is invalid), but it is probably either the bitmap 
or the mask.

Alex.

On Thursday, August 22, 2019 at 11:40:45 AM UTC+8, Stephen De Gabrielle 
wrote:
>
> Hi
>
> I’m trying to help a user who is getting an error when trying to run 
> slideshow:
>
> I typed "#lang slideshow" into DrRacket and got the following error:
>
> CreateIconIndirect: call failed (87)
>
> Interactions disabled: slideshow does not support a REPL (no 
> #%top-interaction)
>
> They have two computers - slideshow works on a newer pc(win 10) but fails 
> on one that has been upgraded from windows 7 to 10. I can’t determine any 
> other difference.
>
>
> Any ideas how I can help this user ?
>
>
>
> https://www.reddit.com/r/Racket/comments/ct95b0/error_when_i_try_to_use_slideshow/?utm_source=share_medium=ios_app
>
>
> Kind regards
>
> Stephen
>

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


[racket-users] Re: gui widgets over canvas

2019-08-05 Thread Alex Harsanyi
I can think of two options which only use the functionality that is 
currently
available in the racket GUI library:

One option is to use a `pasteboard%` instead of the `canvas%` and use an
`editor-snip%` for the text input, with the snip being moved where you need
it.  This solution will be limited to the text input widget only, unless you
want to write additional widgets, which will have to be implemented as 
`snip%`
instances.

Another option is to write your own panel widget by deriving from `panel%` 
and
overriding `container-size` and `place-children` -- this will give full
control over the placement of child items inside the panel: e.g. the canvas
could be placed at 0,0 and fill the entire client area, while the text input
will be placed on top of the canvas at the correct position.  This solution
allows placing arbitrary controls on the canvas.  For scrolling, I would
suggest making the canvas itself scrollable and have the panel update the
position of the text input: a scrollable panel works, but the canvas will 
not
know its viewing area and will have to draw all the rows and let the
underlying draw routines clip them -- this might be a performance issue for
very large number of rows.

Good luck with your project,
Alex.

On Monday, August 5, 2019 at 7:28:17 PM UTC+8, Neil Van Dyke wrote:
>
> For a million-rows spreadsheet GUI widget that's based on a canvas, and 
> wants to overlay a single normal widget like a `text-field%` at a time, 
> over the canvas, for cell value editing... what's the best way to get 
> that overlay to happen in Racket `gui`? 
>
> One idea: in the implementation of `panel%`, looks like I can force it 
> to be implemented as a canvas (`wx-vertical-canvas-panel%`).  If I could 
> draw the spreadsheet viewport to that same canvas, as well as parent 
> overlaid widgets to it, I suppose I could use panes to position and size 
> the editing widget.  I don't know whether that would work at all, on all 
> platforms, and in future Racket releases. 
>
> Or is there a better way? 
>
>

-- 
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/3b932c2d-c6c2-48ea-8906-605695579fe2%40googlegroups.com.


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

2019-08-01 Thread Alex Harsanyi
I installed the latest version, and Racket and raco run fine, but I am 
sorry to report some more problems with it: 

When I runActivityLog2 there is some code which prints out a number to the 
console when the application starts up -- this does not happen if I build 
the application with Racket 7.3, so it is not a spurious printf in my 
code.  It is just a number: if I run it using racket.exe, it is always 
98908, if I build an executable, the value printed out is always 98914, and 
a new console window is opened, which is very annoying for a GUI 
application. I tried creating a simple GUI application, with just a frame, 
but nothing was printed out when I ran that one, so I am not sure how to 
investigate it further.

Also, in one of the test runs, I got a warning printed out on the console:

(racket.exe:6532): Pango-WARNING **: 20:39:36.824: couldn't load font 
"Helvetica Bold Not-Rotated 14px", falling back to "Sans Bold Not-Rotated 
14px", expect ugly output.

I only got this warning once and could not reproduce it anymore.  As with 
the number, I never saw this warning (or any unexpected text) printed out 
on the console with previous Racket versions.

Should I create issues for these in the Racket, or some other repository?

Alex.


On Wednesday, July 31, 2019 at 10:06:40 AM UTC+8, Matthew Flatt wrote:
>
> The latest release candidate at pre-release.racket-lang.org fixes this 
> problem. 
>
> Thanks again! 
>
> At Fri, 26 Jul 2019 22:58:38 -0700 (PDT), Alex Harsanyi wrote: 
> > I can install the windows version of Racket CS and DrRacket (and my 
> > program) runs fine, however when I try to run "raco" I get a message 
> > windows with the "Can't find C:\Program FIles\Racket\.\racket > Variant:Replace This>.exe": 
> > 
> > 
> > 
> > I have no extra packages installed or migrated to this installation. 
> > 
> > Alex. 
> > 
> > On Friday, July 26, 2019 at 8:41:15 PM UTC+8, Matthew Flatt wrote: 
> > > 
> > > At Tue, 23 Jul 2019 18:50:57 -0600, Matthew Flatt wrote: 
> > > > At Tue, 23 Jul 2019 17:47:35 -0700 (PDT), Alex Harsanyi wrote: 
> > > > > I installed the windows version of the Racket CS build and, when 
> > > trying to 
> > > > > run DrRacket I get the following error in a console: 
> > > > > 
> > > > > variable force-unfasl is not bound 
> > > > 
> > > > This is a build problem that we're investigating. 
> > > 
> > > The latest pre-release build of Racket CS for Windows installs and 
> runs 
> > > (at least for me): 
> > > 
> > >  http://pre-release.racket-lang.org/ 
> > > 
> > > 
> > > Thanks again for helping us check the pre-release builds! 
> > > 
> > > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to racket...@googlegroups.com . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/racket-users/b6d41e86-bbcd-4c8b-82de-7fa99e4f
>  
> > 7dd4%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/82bf365e-92e0-4188-88c0-7dda0e833a45%40googlegroups.com.


[racket-users] [standard-fish] map of the world

2019-07-30 Thread Alex Harsanyi
Here is a map of the world, rendered using a 40 line Racket program and 
country outline data from https://geojson-maps.ash.ms/.  You can find the 
source here: 
https://gist.github.com/alex-hhh/2c0f5a02d9e795cbedf90cf84ef84281

[image: world.png]
The program is similar to the one described here, which contains more 
details about the map rendering: 
https://alex-hhh.github.io/2019/05/timezone-visualization.html

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/926f6bd8-8fa9-4047-9820-046fa1a55687%40googlegroups.com.


Re: [racket-users] Directory-specific installation of packages?

2019-07-28 Thread Alex Harsanyi
On Sunday, July 28, 2019 at 3:48:24 PM UTC+8, james.geddes wrote:
>
>
> My workaround is to tell my colleagues to use homebrew to install Racket; 
> then use `raco pkg` to install the app; and to specify `(define 
> racket-launcher-names …)` in the info.rkt file to make an executable.


> It’s a workaround because it requires an additional step beyond this: the 
> default location for such executables is not typically in one’s PATH, so my 
> users have to set the PATH. For most of them that’s fine, but for some it’s 
> not great. 
>

You can always create an executable (using "raco exe") and a distribution 
(using "raco dist") which packs all dependencies in a single directory.  
The resulting executable will be stand-alone and will contain all the 
Racket libraries, including any external packages you use, and will run on 
computers that don't have Racket installed.  You could even sign the 
resulting executable, if you have a developer certificate.

You could also provide a small shell script to update the PATH, which users 
will have to run once for installation (I believe MacOS stores environment 
variables in a plist?)

The only downside of this approach is that it does not provide a 
distribution mechanism.  But given that you write this program for your 
colleagues, you could just place the program on an internal network share 
and tell them to fetch it from there.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0db5ce91-919e-41f5-8355-efcecfe4d4b3%40googlegroups.com.


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

2019-07-26 Thread Alex Harsanyi
I can install the windows version of Racket CS and DrRacket (and my 
program) runs fine, however when I try to run "raco" I get a message 
windows with the "Can't find C:\Program FIles\Racket\.\racket.exe":



I have no extra packages installed or migrated to this installation.

Alex.

On Friday, July 26, 2019 at 8:41:15 PM UTC+8, Matthew Flatt wrote:
>
> At Tue, 23 Jul 2019 18:50:57 -0600, Matthew Flatt wrote: 
> > At Tue, 23 Jul 2019 17:47:35 -0700 (PDT), Alex Harsanyi wrote: 
> > > I installed the windows version of the Racket CS build and, when 
> trying to 
> > > run DrRacket I get the following error in a console: 
> > > 
> > > variable force-unfasl is not bound 
> > 
> > This is a build problem that we're investigating. 
>
> The latest pre-release build of Racket CS for Windows installs and runs 
> (at least for me): 
>
>  http://pre-release.racket-lang.org/ 
>
>
> Thanks again for helping us check the pre-release builds! 
>
>

-- 
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/b6d41e86-bbcd-4c8b-82de-7fa99e4f7dd4%40googlegroups.com.


[racket-users] Re: Using errortrace with repl-driven-development?

2019-07-23 Thread Alex Harsanyi
If you are using DrRacket, you can go to the "Language/Choose Language..." 
menu, click on "Show Details", than make sure the "Preserve Stack Trace" 
checkbox is ticked.

If you are using racket-mode in Emacs, you can evaluate the current buffer 
using "C-u F5" which will do the same thing.

If you use racket from the command line, I think you can run it as:

racket -l errortrace -l racket -i

Hope this helps,
Alex.

On Wednesday, July 24, 2019 at 9:45:47 AM UTC+8, Anthony Quizon wrote:
>
> I've been trying to find a way to get better error messages in the racket 
> repl via the command line.
> Specifically, better stack traces. At the moment, if you load a file in 
> the repl via ',enter' it doesn't give you any information about the line 
> number for errors.
>
> I've looked around in the users group but could only find:
> racket -l errortrace -t .rkt
>
> This is pretty much what I'm looking for except that it only lets me use 
> this once and non-interactively. 
>
> Is there an option in the (x)repl that lets me use errortrace 
> interactively for each input?
>

-- 
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/4cd2db48-0520-4d4b-b144-83b1e7badc1c%40googlegroups.com.


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

2019-07-23 Thread Alex Harsanyi

On Wednesday, July 24, 2019 at 12:55:40 AM UTC+8, Greg Hendershott wrote:
>
> Although I'm still skeptical that changing the surface syntax will be a 
> sufficiently big net gain, and ought to be the next, highest priority? 
> I'm running with that idea for the following. 
>

I had a look at the proposals at 
https://github.com/racket/racket2-rfcs/issues, and they seem reasonable 
changes which, in my opinion, would improve the Racket language.  Most of 
these changes, if they are implemented, would also allow a relatively easy 
transition of existing Racket code.

I can see only one proposal for changing the syntax and it is no more 
radical than "#lang at-exp", which is already part of Racket, and seems to 
be popular.

On the other hand, anyone who is reading the posts on racket-users list, 
would think that the Racket is a risky language to learn and use at this 
time.  Perhaps it is time to stop the speculation and comment on the actual 
proposals being made?

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3aea6a05-1c10-4b70-b942-88583080f43d%40googlegroups.com.


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

2019-07-23 Thread Alex Harsanyi
I installed the windows version of the Racket CS build and, when trying to 
run DrRacket I get the following error in a console:

variable force-unfasl is not bound
  context...:
   condition->exn
   body of data
   dynamic-wind
   body of data
   compiled-module->dh+h+data-instance+declaration-instance
   eval-module8
   standard-module-name-resolver
   module-path-index-resolve5
   namespace-module-instantiate!96
   for-loop
   for-loop
   run-module-instance!125
   perform-require!78
   namespace-require+
   #%for-each

I get the same error if I try to run racket.exe in a console.

As a separate note, this pre-release build tries to install itself as 
"Racket", which will replace the main Racket installation, I would prefer 
if pre-release builds would install in versioned directories (i.e. 
Racket-7.3.0.900), this was the case with past pre-releases.  I could tell 
the installer to use a versioned directory though, so this is not a big 
issue.

Alex.



On Tuesday, July 23, 2019 at 11:48:48 PM UTC+8, johnbclements wrote:
>
>Version 7.3.0.900 is now available for testing from 
>
>   https://pre-release.racket-lang.org/ 
>
> (Note that this is not available from the usual download site.) 
>
> If all goes well, we will turn this version into a v7.4 release 
> within a couple of weeks. 
>
> This release is the first one to include Chez-Scheme-based builds 
> (labeled “Racket CS” on the pre-release page), and we’d be interested in 
> hearing about any issues you encounter with these builds. 
>
> Your help and feedback in testing this new release candidate would be 
> much appreciated. 
>
>
>
>

-- 
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/99e25a5e-f6c2-4a6c-b97b-6f56e6fda856%40googlegroups.com.


[racket-users] Re: Problem with `copy` method of image-snip%

2019-07-21 Thread Alex Harsanyi

I am not entirely sure why (because I already spent more than 15 minutes on 
this :-) ), but the problem is with the `get-extent` method: just remove 
it, and let `image-snip%` handle the method.

The `copy` method is not used in this case.

Also, in your `on-char` and `on-event` methods, you might want to pass back 
any un-handled events back to the editor's `on-default-event` and 
`on-default-char` methods, otherwise, you will notice that the editor stops 
responding to some events since your code discards them.

Alex.

On Tuesday, July 16, 2019 at 11:01:41 PM UTC+8, Kshitij Sachan wrote:
>
> Update:
>
> I've narrowed down the problem to the `copy` method of the snip. When I 
> delete the copy method, I can see the snip perfectly, but it can't be 
> resized (because no copy method implemented).
>
> I removed the GL component, so now I'm only attempting to extend the 
> image-snip% class to resize a custom bitmap I load in (in my case just a 
> plain red circle I drew). When I highlight over the snip with my cursor, I 
> can see the bitmap below and it is resizing as well on a click (using 
> `set-bitmap`). However, if I don't highlight over the snip it appears plain 
> white.
>
> Another observations that may or may not help is:
> Calling (send s get-bitmap) always returns the bitmap of the same size, 
> even if I've pressed on the snip several times to resize it.
>
> Here's the simplified code:
> (require racket/gui
>  racket/gui/base)
>
> ;; bitmap stuff
> (define bits (make-bitmap 250 250))
> (define bits-dc (new bitmap-dc% [bitmap bits]))
> (send bits-dc set-brush "red" 'solid)
> (send bits-dc set-pen "black" 3 'solid)
> (send bits-dc draw-ellipse 1 1 248 248)
>
> (define snip (make-object image-snip% bits))
>
> ;; snip stuff
> (define scroll-snip%
>   (class image-snip%
> (init bit-init)
> (define snip-bitmap bit-init)
> (inherit/super get-admin set-flags set-bitmap)
> (init-field [w 100] [h 100])
> 
> (super-make-object snip-bitmap)
> (set-flags (list 'handles-events))
> 
> (define/override (get-extent dc x y width height descent space lspace 
> rspace)
>   (define (maybe-set-box! b v) (when b (set-box! b v)))
>   (maybe-set-box! width w)
>   (maybe-set-box! height h)
>   (maybe-set-box! descent 1.0)
>   (maybe-set-box! space 1.0)
>   (maybe-set-box! lspace 1.0)
>   (maybe-set-box! rspace 1.0))
>
> (define/override (on-char dc x y editorx editory event)
>   (cond
> [(equal? (send event get-key-code) 'down)
>  (define admin (get-admin))
>  (set! w (+ w 20))
>  (set! h (+ h 20))
>
>  ;; brush/pen/draw ellipse
>  (define new-bits (make-object bitmap% w h))
>  (send bits-dc set-bitmap new-bits)
>  (send bits-dc draw-ellipse x y (- w 2) (- h 2))
>  (set! snip-bitmap new-bits)
>  
>  (when admin
>(send admin resized this #t))]
> [(equal? (send event get-key-code) 'up)
>  (define admin (get-admin))
>  (set! w (- w 20))
>  (set! h (- h 20))
>
>  ;; brush/pen/draw ellipse
>  (define new-bits (make-object bitmap% w h))
>  (send bits-dc set-bitmap new-bits)
>  (send bits-dc draw-ellipse x y (- w 2) (- h 2))
>  (super set-bitmap new-bits)
>  
>  (when admin
>(send admin resized this #t))]
> [(equal? (send event get-key-code) 'escape)
>  (define admin (get-admin))
>  (set! w 150)
>  (set! h 150)
>
>  ;; brush/pen/draw ellipse
>  (define new-bits (make-object bitmap% w h))
>  (send bits-dc set-bitmap new-bits)
>  (send bits-dc draw-ellipse x y (- w 2) (- h 2))
>  (super set-bitmap new-bits)
>  
>  (when admin
>(send admin resized this #t))]))
>
> (define/override (on-event dc x y editorx editory event)
>   (cond
> [(send event button-down?)
>  (define admin (get-admin))
>  (set! w (+ w 20))
>  (set! h (+ h 20))
>
>  ;; brush/pen/draw ellipse
>  (define new-bits (make-object bitmap% w h))
>  (send bits-dc set-bitmap new-bits)
>  (send bits-dc draw-ellipse x y (- w 2) (- h 2))
>  (super set-bitmap new-bits)
>  
>  (when admin
>(send admin resized this #t))]))
>
> (define/override (draw dc x y left top right bottom dx dy draw-caret)
>   ;; brush/pen/draw ellipse
>   ;(define new-bits (make-object bitmap% w h))
>   ;(send bits-dc set-bitmap new-bits)
>   ;(send bits-dc draw-ellipse x y (- w 2) (- h 2))
>   ;(set! snip-bitmap new-bits)
>   (super draw dc x y left top right bottom dx dy draw-caret))
>
> (define/override (copy)
>   (make-object scroll-snip% snip-bitmap))
> ))
>
> (define s (make-object scroll-snip% bits))
> s
>
> I believe there must be a problem with the default implementation of 

[racket-users] Re: Creating movable Fonts on a Canvas

2019-06-23 Thread Alex Harsanyi
Have a look at the `snip%` and `pasteboard%` classes: you can represent 
each glyph using a `snip%` and the pasteboard will handle the moving it 
with the mouse.  You can derive the `snip%` and `pasteboard%` objects to 
add new functionality -- this is easier than implementing a mouse move 
operation using the `canvas%`  `on-event` method.

While not exactly what you need, I wrote a blog post about using `snip%` 
objects, and in the first example, the chess pieces themselves are actually 
Unicode Glyphs, so you could easily modify it to have different 
Glyphs/Letters that can be moved around in a canvas:

https://alex-hhh.github.io/2018/10/chess-game-using-racket-s-pasteboard.html

Alex.

On Monday, June 24, 2019 at 4:40:34 AM UTC+8, Amir Teymuri wrote:
>
> If i want to use fonts on a canvas in a way that each single Glyph/Font is 
> movable around the canvas by mouse, is it a good idea to have a class 
> drivative of canvas% for each new font and then override the on-event 
> method of them to update its coordinates on the main canvas? Or is there a 
> better more effiicient way for doing this?
>
> Greetings,
> Amir
>

-- 
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/71492a5d-ba15-4191-9a74-67880e36cb88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Request for Feedback (SQL, Plisqin)

2019-06-21 Thread Alex Harsanyi

While I am familiar with SQL, I am not familiar with any of the libraries 
you
mention on the wiki page (Ecto, Honey SQL and Slick), so maybe I am not the
target audience...

Your sections about "Joins Are Values" and "Aggregates are self-contained"
seem difficult to follow: I think I understand the overall idea, but it is 
not
clear from the document how any of it can be useful.  Also, it is not clear
what `Department?` and `Course?` are in the first code snippet -- are they
functions that the user has to provide or is it something that your library
generates by looking at the database schema?

I would suggest to provide a database schema and some sample data in a
database, and use this in the subsequent examples.  Start with a simple but
complete working example and construct more complex, but still complete and
working examples from them, at each step illustrating the benefits that the
library provides.  Maybe contrast each step with how the plain SQL would 
look
as well?

Alex.


On Saturday, June 22, 2019 at 12:41:31 AM UTC+8, Ryan Kramer wrote:
>
> Target Audience: you have 10 minutes and you're familiar with libraries 
> that do SQL kinda like this:
>
> (from i "Item"
>   (where i".ReleaseDate > '2018-01-01'")
>   (select i".ItemName"))
>
> Article: 
> https://github.com/default-kramer/plisqin/wiki/Towards-Better-Relational-Query-Language
>
> Context: Plisqin is my SQL generation library, but I think of it as an 
> "alternate query language" because theoretically it doesn't have to 
> generate SQL. (But it probably always will.)
>
> I'm gearing up to release Plisqin 0.3 and want to improve my 
> documentation. If I can't explain these concepts to fellow Racketeers, I 
> don't stand a chance of explaining them to the general public.
>
> Thanks for any feedback!
>

-- 
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/4299131f-3e59-44e0-b53b-52186a3bf95f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket 7.3 Plot Performance Regression

2019-06-07 Thread Alex Harsanyi
The paint times for 7.2 seem inconsistent with your previous tests...

In any case, it seems mouse event handling takes longer in 7.3 based your 
results.  What happens if you update the callback to discard any mouse 
events older than, say 50 milliseconds?

Alex.

On Friday, June 7, 2019 at 7:27:32 PM UTC+8, evdubs wrote:
>
> I changed the Linux line of code to:
>
> [time-stamp (current-milliseconds)]
>
> Is there a reason why you did not want to do that?
>
> Any way, when I do that, here are the results I get:
>
> $ ~/racket-7.2/bin/racket chart-lag-test.rkt
> Mouse
> Min: 0.132080078125
> Max: 23.10107421875
> Mean: 3.257062241367008
> StdDev: 4.589805152078677
>
> Paint
> Min: 0.178955078125
> Max: 102.94091796875
> Mean: 28.86041259765625
> StdDev: 42.84071031974706
>
> $ ~/racket-7.3.0.4/bin/racket chart-lag-test.rkt
> Mouse
> Min: 0.126953125
> Max: 202.34912109375
> Mean: 25.70277455891149
> StdDev: 38.4063903237421
>
> Paint
> Min: 0.175048828125
> Max: 21.754150390625
> Mean: 7.548767089843749
> StdDev: 8.728339324923978
>
> If this modification is okay, I guess this is getting somewhere?
>
> Evan
>
> On Wednesday, June 5, 2019 at 5:43:40 PM UTC-10, Alex Harsanyi wrote:
>>
>>
>>
>> On Wednesday, June 5, 2019 at 9:23:26 PM UTC+8, Alex Harsanyi wrote:
>>>
>>>
>>>
>>> On Wednesday, June 5, 2019 at 8:51:48 PM UTC+8, evdubs wrote:
>>>>
>>>> I ran the program with your modifications, but counter to the 
>>>> documentation 
>>>> <https://docs.racket-lang.org/gui/event_.html?q=get-time-stamp#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._event~25%29._get-time-stamp%29%29>,
>>>>  
>>>> the values I get from get-time-stamp don't seem at all similar to 
>>>> current-milliseconds or current-inexact-milliseconds. I ended up 
>>>> defining delta as follows (with 1559695139340 being a guess):
>>>>
>>>> (define delta (- (current-inexact-milliseconds) 1559695139340 (send 
>>>> event get-time-stamp)))
>>>>
>>>>
>>> On my machine, `get-time-stamp` always returns 0 -- this indicates that 
>>> the event% object itself is copied somewhere along the way but the 
>>> timestamp is not copied, The 1559695139340 is just the unix timestamp from 
>>> when you ran the code first time.  I don't think the mouse test is relevant 
>>> as is...  unfortunately I don't have any more suggestions for now...
>>>
>>
>> It looks like the `get-time-stamp` returns a value that is not what the 
>> documentation specifies and it is also platform specific, I created an 
>> issue with the relevant details here: 
>> https://github.com/racket/gui/issues/132
>>
>> For now, I cannot think of a way to determine how old a mouse event is 
>> when the callback is invoked.
>>  
>>
>>>
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2c303a34-c647-42f8-8c29-aeb1779c8807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket 7.3 Plot Performance Regression

2019-06-05 Thread Alex Harsanyi


On Wednesday, June 5, 2019 at 9:23:26 PM UTC+8, Alex Harsanyi wrote:
>
>
>
> On Wednesday, June 5, 2019 at 8:51:48 PM UTC+8, evdubs wrote:
>>
>> I ran the program with your modifications, but counter to the 
>> documentation 
>> <https://docs.racket-lang.org/gui/event_.html?q=get-time-stamp#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._event~25%29._get-time-stamp%29%29>,
>>  
>> the values I get from get-time-stamp don't seem at all similar to 
>> current-milliseconds or current-inexact-milliseconds. I ended up 
>> defining delta as follows (with 1559695139340 being a guess):
>>
>> (define delta (- (current-inexact-milliseconds) 1559695139340 (send event 
>> get-time-stamp)))
>>
>>
> On my machine, `get-time-stamp` always returns 0 -- this indicates that 
> the event% object itself is copied somewhere along the way but the 
> timestamp is not copied, The 1559695139340 is just the unix timestamp from 
> when you ran the code first time.  I don't think the mouse test is relevant 
> as is...  unfortunately I don't have any more suggestions for now...
>

It looks like the `get-time-stamp` returns a value that is not what the 
documentation specifies and it is also platform specific, I created an 
issue with the relevant details here: 
https://github.com/racket/gui/issues/132

For now, I cannot think of a way to determine how old a mouse event is when 
the callback is invoked.
 

>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/10aa0c2f-b5f5-48ff-8f0a-66ce99fbd2b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket 7.3 Plot Performance Regression

2019-06-05 Thread Alex Harsanyi


On Wednesday, June 5, 2019 at 8:51:48 PM UTC+8, evdubs wrote:
>
> I ran the program with your modifications, but counter to the 
> documentation 
> ,
>  
> the values I get from get-time-stamp don't seem at all similar to 
> current-milliseconds or current-inexact-milliseconds. I ended up defining 
> delta as follows (with 1559695139340 being a guess):
>
> (define delta (- (current-inexact-milliseconds) 1559695139340 (send event 
> get-time-stamp)))
>
>
On my machine, `get-time-stamp` always returns 0 -- this indicates that the 
event% object itself is copied somewhere along the way but the timestamp is 
not copied, The 1559695139340 is just the unix timestamp from when you ran 
the code first time.  I don't think the mouse test is relevant as is...  
unfortunately I don't have any more suggestions for now...

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8f52e281-b9eb-4cfb-ad0d-0efde6b35363%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket 7.3 Plot Performance Regression

2019-06-05 Thread Alex Harsanyi
I had a look at the code and it is not exactly what I had in mind for the 
measurements.  The problem with your measurements is that the canvas is 
re-drawn only when needed, so the time between two calls to on-paint is not 
relevant for performance measurements.

For the on-paint, the time of the draw itself needs to be measured:

(define/override (on-paint)
  (define begin-timestamp (current-inexact-milliseconds))
  (super on-paint)
  (define end-timestamp (current-inexact-milliseconds))
  (set! paint-event-stats
(update-statistics paint-event-stats (- end-timestamp begin-
timestamp

For the mouse event, the time between when the event is created and the 
time it is passed to the callback:

(define ((make-current-value-renderer fn) snip event x y)
  (define delta (- (current-inexact-milliseconds) (send event get-time-stamp
)))
  (set! mouse-event-stats (update-statistics mouse-event-stats delta))
  (define overlays
(and x y (eq? (send event get-event-type) 'motion)
 (list (vrule x #:style 'long-dash)
   (point-label (vector x (fn x)) #:anchor 'auto
  (send snip set-overlay-renderers overlays))


Alex.

On Wednesday, June 5, 2019 at 8:06:26 PM UTC+8, evdubs wrote:
>
> Thanks for responding, Alex.
>
> Here's what I came up with <http://pasterack.org/pastes/893> that I think 
> satisfies your recommendations. It shows the sin() plot, expects 
> interaction for 10 seconds, then prints min/max/mean/std dev for both the 
> mouse-event-callback for the snip and on-paint for the editor-canvas%.
>
> Here's the output from running that with Racket 7.2 and Racket 7.3.0.4:
>
> $ ./racket-7.2/bin/racket ~/Code/racket/chart-lag-test.rkt 
> Mouse
> Min: 1.115966796875
> Max: 1209.123046875
> Mean: 40.23961775104986
> StdDev: 81.88591520019294
>
> Paint
> Min: 3.35302734375
> Max: 275.579833984375
> Mean: 79.6534423828125
> StdDev: 113.45367443728956
>
> $ ./racket-7.3.0.4/bin/racket ~/Code/racket/chart-lag-test.rkt 
> Mouse
> Min: 1.072021484375
> Max: 1095.2412109375
> Mean: 21.93592705160883
> StdDev: 54.53777963909044
>
> Paint
> Min: 3.18798828125
> Max: 284.447998046875
> Mean: 80.8831787109375
> StdDev: 117.90272049413493
>
> These numbers seem to suggest that 7.3 is an improvement, at least from 
> the mouse-event stats, even though that is counter to the experience from 
> interacting with the plot. Have any other ideas?
>
> Evan
>
> On Tuesday, June 4, 2019 at 1:39:49 PM UTC-10, Alex Harsanyi wrote:
>>
>>
>>
>> On Tuesday, June 4, 2019 at 11:32:42 AM UTC+8, evdubs wrote:
>>>
>>> Thanks for trying it out.
>>>
>>> I just tried using the bash installer from 
>>> https://download.racket-lang.org/ and I experience the same issue of 
>>> lagginess in 7.3. I also tried using a snapshot release from 
>>> https://plt.eecs.northwestern.edu/snapshots/ and I experienced the same 
>>> issue. 
>>>
>>> I am not sure what I should try next other than maybe profiling, but I 
>>> have not had much luck making effective use of the profiler in the past for 
>>> interactive applications.
>>>
>>
>> Here are a few things you can try:
>>
>> First, check again whether there’s a performance drop in Racket 7.2 too 
>> -- you
>> don’t want to spend time tracking down a Racket problem only to find out 
>> that
>> the latest Ubuntu update disabled the hardware acceleration on the 
>> graphics
>> card.
>>
>> If it is indeed a regression in Racket 7.3, you can try narrowing the 
>> problem
>> down to either rendering or mouse event delays:
>>
>> * you can measure the time it takes to render the plot by measuring the 
>> time
>>   the paint method of the `editor-canvas%`. You will need to create a 
>> custom
>>   `editor-canvas%` and override `on-paint` and use
>>   `current-inexact-milliseconds` to measure the time.
>>
>> * to check if mouse events are delivered too late to the callback. You 
>> can use
>>   the `get-time-stamp` method on the event and compare it against
>>   `current-inexact-milliseconds` to determine the delay.
>>
>> You will need to compare both values against Racket 7.2 to see which one 
>> is
>> causing the slow down.
>>
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a21321c2-372f-45bf-806f-ec07344986f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket 7.3 Plot Performance Regression

2019-06-04 Thread Alex Harsanyi


On Tuesday, June 4, 2019 at 11:32:42 AM UTC+8, evdubs wrote:
>
> Thanks for trying it out.
>
> I just tried using the bash installer from 
> https://download.racket-lang.org/ and I experience the same issue of 
> lagginess in 7.3. I also tried using a snapshot release from 
> https://plt.eecs.northwestern.edu/snapshots/ and I experienced the same 
> issue. 
>
> I am not sure what I should try next other than maybe profiling, but I 
> have not had much luck making effective use of the profiler in the past for 
> interactive applications.
>

Here are a few things you can try:

First, check again whether there’s a performance drop in Racket 7.2 too -- 
you
don’t want to spend time tracking down a Racket problem only to find out 
that
the latest Ubuntu update disabled the hardware acceleration on the graphics
card.

If it is indeed a regression in Racket 7.3, you can try narrowing the 
problem
down to either rendering or mouse event delays:

* you can measure the time it takes to render the plot by measuring the time
  the paint method of the `editor-canvas%`. You will need to create a custom
  `editor-canvas%` and override `on-paint` and use
  `current-inexact-milliseconds` to measure the time.

* to check if mouse events are delivered too late to the callback. You can 
use
  the `get-time-stamp` method on the event and compare it against
  `current-inexact-milliseconds` to determine the delay.

You will need to compare both values against Racket 7.2 to see which one is
causing the slow down.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e0eb4b36-d37b-4688-bb02-6d3c645f37cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2019-04-11 Thread Alex Harsanyi


On Thursday, April 11, 2019 at 1:50:23 PM UTC+8, travis@gmail.com 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?
>

The trick is to use nested functions, like so:

(define (project-pop-1 y r k thetasd t)

  (define (logmod y)
(define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0))
(* y (- r (* r (/ y k))) (exp theta)))

  (define (loop y i)
(if (= i t)
(list y)
(cons y (loop (logmod y) (add1 i)

  (loop y 1))

(project-pop-1 1.0 1.8 20.0 0.1 25)

Also, multiplication accepts any number of arguments, instead of (* a (* b 
c)) when you can write (* a b c)

Also, if you want to use structures, you can use `struct-copy` and 
`match-define` and the code looks much nicer.  Your implementation of 
logmod can be written as:

(define (logmod-1 args-struct)
  (match-define (args y r k thetasd) args-struct)
  (define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0))
  (define new-y (* y (- r (* r (/ y k))) (exp theta)))
  (struct-copy args args-struct [y new-y]))
Alex.


 

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


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

2019-04-05 Thread Alex Harsanyi
Here are some notes that I wrote to deal with this situation, except they 
use the plot package:


https://alex-hhh.github.io/2018/01/changing-built-in-racket-packages.html

You will also find some more information about this topic if you search 
this group, but most of what is explained in those posts seems to be for 
cases where raco can modify the main Racket installation and it does not 
work if the racket is installed at system level and you run raco as a user 
only.

OTOH, my process does not seem to work with "raco setup" commands for the 
cloned package, so you will than have to manually run "raco make" to 
compile your changes and run scribble to generate the documentation.  Maybe 
I just have to pass some special arguments to "raco setup" but I have not 
found what those are (but did I look very hard :-) )

Alex.

On Saturday, April 6, 2019 at 4:03:06 AM UTC+8, zeRusski wrote:
>
> I thought about hacking on /rackunit/ a bit and if it pans out maybe send 
> my changes upstream. Typically I would clone a repo and then do raco pkg 
> install in its folder so that I have it linked and code that may require 
> it picks up latest changes. Very convenient workflow. Except /rackunit/ is 
> special (no surprise there) it comes pre-installed and in the installation 
> scope and basically other things depend on it, so don't touch it says 
> /raco/. Here's what I tried next:
>
> cd to rackunit parent dir and
>
> raco pkg update -i --force --type dir ./rackunit/
>
>
> but I don't see the "Linking directory ..." message there. Is it copying 
> stuff? See, not only do I want my changes picked up automatically by other 
> code, I also want to be able to jump to definition and arrive at that local 
> repo. And its a good litmus test for whether I'm actually linking or moving 
> stuff to collects somewhere.
>
> Trying nuclear (but, really, I have no clue what I'm doing here):
>
> ~/Code/rackunit $ raco pkg remove --force rackunit
>> ~/Code/rackunit $ raco pkg install --force
>> Linking current directory as a package
>> raco setup: version: 7.2.0.12
>
>
> Looks good. Also I think I installed it as in -user scope. Except, nope. 
> Jump to definition still takes me to some share 
> racket-7.2.0.12/share/pkgs/rackunit-lib/rackunit/private.
>
> Same goes for changing code in locally cloned repo. Changes aren't picked 
> up. Is /rackunit/ special somehow? Or is there some weird PATH that's 
> shadowing linked /rackunit/? Should I nuke dirs that mention /rackunit/ 
> inside racket-7.2.0.12/share/
>
> 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.


Re: [racket-users] Generate really large random numbers in Racket

2019-04-01 Thread Alex Harsanyi
You can use `crypto-random-bytes` to generate large random numbers, 
however, that function returns a string of bytes, which you have to combine 
into an integer:

(define 

 (random-bignum bits)
  (define 

 num-bytes (exact-ceiling 

 (/ 

 bits 8)))
  (for/fold 

 ([result 0])
([byte (in-bytes 

 (crypto-random-bytes 

 num-bytes))])
(+ 

 byte (* 

 result 256


Alex.

On Tuesday, April 2, 2019 at 5:39:46 AM UTC+8, Shaobo He wrote:
>
> Thank you for your reply. This is my thought too but I'm not sure if 
> combining multiple random bits break any good properties of random number 
> generators. Sorry I should've mentioned it. I was talking about bounded 
> random numbers.
>
> Robby Findler > 于2019年4月1日周一 
> 下午3:35写道:
>
>> Generate multiples of those and combine them (shifting old ones over
>> and adding new ones as the lowest digits)?
>>
>> I'm not sure of a good way to generate nats uniformly at random where
>> you don't specify an upper bound, but Neil Toronto suggested something
>> crazy we used this paper:
>> http://users.cs.northwestern.edu/~robby/pubs/papers/jfp2017-nfmf.pdf
>>
>> Robby
>>
>> On Mon, Apr 1, 2019 at 4:31 PM > wrote:
>> >
>> > Hello everyone,
>> >
>> > It appears that the largest number returned by the random function in 
>> Racket is 4294967087-1 for a good reason. Are there any libraries or simple 
>> approaches to generate a number larger than that?
>> >
>> > Thanks,
>> > Shaobo
>> >
>> > --
>> > You received this message because you are subscribed to the Google 
>> Groups "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to racket...@googlegroups.com .
>> > 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] Emacs scribble-mode

2019-03-31 Thread Alex Harsanyi
I started writing Scribble documentation more often lately and Emacs has no 
good support for editing such documents.  For me the main feature that I 
would like is indentation, like it is done in other programming modes.   I 
found a `racket-mode` on GitHub, but it only supports some basic syntax 
highlighting and nothing else.

In any case, I started implementing a scribble mode with aims of supporting 
indentation, document navigation and some more advanced syntax 
highlighting.  At this point it supports indentation and some basic code 
navigation (beginning/end of defun), but I indent to improve it as I use it 
for Scribble editing (unless there is a better package that I don't know 
about?)

If you are also interested in Scribble support for Emacs, you can check out 
the source here:

https://github.com/alex-hhh/racket-mode/blob/master/scribble-mode.el

Best Regards,
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.


[racket-users] Re: Intriguing performance difference between Windows and Linux on `(factorial 100000)`

2019-03-24 Thread Alex Harsanyi
You can check if the big number multiplication is the problem, by using a 
factorial version which does not need so many big number multiplications:

#lang racket/base
(require racket/math)
(define (fact n)
  (if (zero? n) 1 (* n (fact (- n 1)

(define (fact-1 n)
  (define nslots (exact-truncate (sqrt n)))
  (if (<= nslots 1)
  (fact n) ;; use simple implementation for small numbers
  (let ((slot (make-vector nslots 1)))
(for ([x (in-range 1 (add1 n))])
  (define index (modulo x nslots))
  (vector-set! slot index (* (vector-ref slot index) x)))
(for/fold ([result 1])
  ([n (in-vector slot)])
  (* result n)

On my Windows machine, the difference between the two is huge: 16.7 seconds 
for `fact` (your original implementation)  and only 0.5 seconds for `fact-1`

> (equal? (fact 10) (fact-1 10))
#t
> (time (void (fact-1 10)))
cpu time: 469 real time: 468 gc time: 111
> (time (void (fact 10)))
cpu time: 16797 real time: 16782 gc time: 7082
> 



On Monday, March 25, 2019 at 1:20:33 AM UTC+8, Phil Nguyen wrote:
>
> With Racket 7.2, the following program takes >13 seconds to run on 
> Windows, and <7 seconds on Linux either on Virtualbox on the same machine, 
> or native Linux on another machine with slightly lower-powered processor:
>
> #lang racket/base
> (define (fact n)
>   (if (zero? n) 1 (* n (fact (- n 1)
> (time (void (fact 10)))
>
> ; Windows native, i7-7660U
> ;   cpu time: 13610 real time: 13633 gc time: 4459
> ; Linux on Virtualbox, i7-7660U
> ;   cpu time: 6691 real time: 6706 gc time: 1298
> ; Linux native, i7-8500Y:
> ;   cpu time: 6894 real time: 6882 gc time: 1129
>
>
>
> While the difference is unlikely to matter in practice, given `fact 10` 
> is a very large number, I'm curious what accounts for this difference? Is it 
> some big-integer library that Racket relies on?
>
>

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


[racket-users] Re: SQL DB tooling

2019-03-23 Thread Alex Harsanyi

The package is called "north" and you can find it here:

https://pkgs.racket-lang.org/package/north

There is also the announcement on Reddit:

https://www.reddit.com/r/Racket/comments/akob56/ann_north_database_migrations/

Alex.


On Saturday, March 23, 2019 at 12:40:48 PM UTC+8, Aidan Gauland wrote:
>
> I see that Racket has a couple of nice libraries for talking to SQL 
> databases  and 
> , but I have been unable to find any 
> equivalent to the so-called "migrations" capability of DB libraries from 
> other languages (see 
>  and 
>   for examples).  Is there 
> anything like this for Racket, or even some language-agnostic, CLI tool 
> that does the same thing? 
>
> Thanks, 
> Aidan Gauland 
>
>

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


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

2019-03-22 Thread Alex Harsanyi

On Saturday, March 23, 2019 at 5:17:22 AM UTC+8, James Platt wrote:
>
> Well, I might make some kind of compromise.  What I don't want to allow is 
> the possibility of the user experience being "I click on the button and 
> nothing happens."  


You can wrap each button callback with a `with-handlers` call that displays 
a message box when an exception is raised inside the callback, but this 
user interface might not be very pleasant to use.  Also this will not help 
you if your callback does something like:

(when #f 
   ;; rest of the code here
   )
 

> Next worst is to display a raw error message which the user can only 
> interpret by cutting and pasting it into a web search.  


If the user can do nothing about this error except report it back to the 
developer, you can just log this error to a file, display an "Internal 
Error" dialog box and instruct the user to add the log file to their bug 
report.
 

> So yes, I could just get that far and then try and fix all the bugs rather 
> than try and handle every possible exception gracefully.


If you have a limited amount of time available, I would suggest you spend a 
little of that time on code that displays "Internal Error" and most of that 
time in detecting and fixing these bugs.  You won't be able to fix all of 
them, but you can go a long way of making the "Internal Error" dialog box 
be a rare occurrence in your application.

You should display more information to the user, only if the user can 
actually do something to fix the problem (e.g if you cannot open a file, 
tell the user which file you cannot open), otherwise your application 
should just log the exception into a file, along with other debugging 
information so you can reproduce the problem, than instruct the user to 
report a bug and attach the log file.
 

>  More likely, meet somewhere in the middle of those approaches.   
>
>
> On Mar 22, 2019, at 4:55 PM, Robby Findler wrote: 
>
> > I know this will sound silly, but you could just consider them bugs and 
> the fix them? (I went through a similar thought process with DrRacket years 
> ago and that was the conclusion I came to-- just slap an "internal error" 
> message on it so people aren't confused about it being a bug in their 
> program.) 
> > 
> > Robby 
> > 
> > On Fri, Mar 22, 2019 at 3:09 PM James Platt  > wrote: 
> > I'm working on displaying informative error messages in a GUI and I have 
> been finding that many of the things I need to handle are contract 
> violations in downstream functions.  The thing is that it seems like there 
> ought to be a better way than the methods I can think of.   
> > 
> > It's very simple to use the predicate exn:fail:contract? to tell if 
> there was a contract violation but this doesn't tell me which downstream 
> function or which parameter caused the error.  I could parse the full error 
> message with regular expressions and use that to build my error message for 
> the user.  However, this turns out to be a lot of code and it also seems 
> like it could break down if a future update to Racket or some package 
> changes the wording of an error message.  I could go to the downstream 
> functions, remove their contracts and, instead, have them raise custom 
> exceptions.  Then catch those exceptions in the GUI code.  Not only is this 
> a lot of code to change but it seems wrong to start with code created 
> according to good practice and then undo it for further improvement.   
> > 
> > So my question is whether there is a better way to do this than I am 
> aware of? 
> > 
> > -- 
> > 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...@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-21 Thread Alex Harsanyi

I created a pull request for items (1) and (2), illustrating the changes 
that I propose, you can find it here:

https://github.com/racket/plot/pull/52

Alex.

On Wednesday, March 20, 2019 at 12:17:47 PM UTC+8, Alex Harsanyi wrote:
>
>
>
> On Wednesday, March 20, 2019 at 10:35:51 AM UTC+8, Ben Greenman wrote:
>>
>> > Could you (or Ben or Matt) elaborate on how do you see this work for 
>> non 
>> > plot programs? 
>>
>> I'm thinking a color-map% object would define a possibly-infinite 
>> sequence of colors that look nice in some way. The colors might be 
>> useful anywhere where someone wants a "rainbow" of colors ... maybe 
>> for: 
>>
>> - fonts in a slideshow (colorblind-friendly? grayscale-friendly?), 
>> - coloring the error messages made by a linter or program analyzer, 
>> - drawing a sunset, etc. 
>>
>
> The examples listed above might be better served by other color choosing
> mechanisms, for example, I have implemented some color manipulation code 
> based
> on https://tallys.github.io/color-theory/, you can find it here:
> https://github.com/alex-hhh/data-frame/blob/master/private/colors.rkt .  
> In
> particular the `pick-color` function might do something similar to what 
> Pyret
> is using (as suggested by Justin Zamora).
>
> Other solutions are also possible, including using gradient color maps, but
> this is a larger scope that I originally planned for and I don't have
> the time to prepare and submit a patch for such changes.
>
> My proposal is more limited, to allow plot users to produce good looking 
> plots
> with minimum effort.  What I propose is:
>
> (1) Add a mechanism (via parameters) to replace the `pen-colors` and
> `brush-colors` vectors in the plot package with custom defined colors.  
> This
> means that the existing `->pen-color` and `->brush-color` functions would 
> now
> return a different color depending on what `pen-colors` or `brush-colors` 
> are
> installed.  This also has the benefit that the existing mechanism of
> specifying numbers for colors will now work with color maps:
>
> (plot (list (function sin -5 5 #:color 1)))
>
> (2) "Borrow" the qualitative color maps from matplotlib, so the user has 
> some
> nice predefined set of colors to choose from for their plots.
>
> Also, possibly the following backwards incompatible changes:
>
> (3) change the default set of `pen-colors` and `brush-colors` to one of the
> new color maps, so the nicer colors are on by default.
>
> (4) change the default plot behavior so that a different color is chosen 
> for
> each renderer, this means that things like the code below would result in
> different colors used for the `sin` and `cos` functions:
>
> (plot (list (function sin -5 5) (function cos -5 5)))
>
> 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.
>
> 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.


Re: [racket-users] color-maps for the plot package

2019-03-19 Thread Alex Harsanyi


On Wednesday, March 20, 2019 at 10:35:51 AM UTC+8, Ben Greenman wrote:
>
> > Could you (or Ben or Matt) elaborate on how do you see this work for non 
> > plot programs? 
>
> I'm thinking a color-map% object would define a possibly-infinite 
> sequence of colors that look nice in some way. The colors might be 
> useful anywhere where someone wants a "rainbow" of colors ... maybe 
> for: 
>
> - fonts in a slideshow (colorblind-friendly? grayscale-friendly?), 
> - coloring the error messages made by a linter or program analyzer, 
> - drawing a sunset, etc. 
>

The examples listed above might be better served by other color choosing
mechanisms, for example, I have implemented some color manipulation code 
based
on https://tallys.github.io/color-theory/, you can find it here:
https://github.com/alex-hhh/data-frame/blob/master/private/colors.rkt .  In
particular the `pick-color` function might do something similar to what 
Pyret
is using (as suggested by Justin Zamora).

Other solutions are also possible, including using gradient color maps, but
this is a larger scope that I originally planned for and I don't have
the time to prepare and submit a patch for such changes.

My proposal is more limited, to allow plot users to produce good looking 
plots
with minimum effort.  What I propose is:

(1) Add a mechanism (via parameters) to replace the `pen-colors` and
`brush-colors` vectors in the plot package with custom defined colors.  This
means that the existing `->pen-color` and `->brush-color` functions would 
now
return a different color depending on what `pen-colors` or `brush-colors` 
are
installed.  This also has the benefit that the existing mechanism of
specifying numbers for colors will now work with color maps:

(plot (list (function sin -5 5 #:color 1)))

(2) "Borrow" the qualitative color maps from matplotlib, so the user has 
some
nice predefined set of colors to choose from for their plots.

Also, possibly the following backwards incompatible changes:

(3) change the default set of `pen-colors` and `brush-colors` to one of the
new color maps, so the nicer colors are on by default.

(4) change the default plot behavior so that a different color is chosen for
each renderer, this means that things like the code below would result in
different colors used for the `sin` and `cos` functions:

(plot (list (function sin -5 5) (function cos -5 5)))

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.

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.


Re: [racket-users] color-maps for the plot package

2019-03-19 Thread Alex Harsanyi


On Tuesday, March 19, 2019 at 9:53:23 PM UTC+8, 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.
>

Could you (or Ben or Matt) elaborate on how do you see this work for non 
plot programs?

For plots, the reason that color maps are useful is because the user will 
usually not care what the colors are, as long as they stand out visually 
and look pleasing next to each other.  My proposed interface would allow 
the user to essentially say "use the first color for the first data set, 
the second color for the second data set, etc" and than the meaning of 
"first color" and "second color" are defined as a parameter (the color map 
itself) and will look good with minimal effort.

The above description would not work well for general draw programs, 
however there is `the-color-database` which allows selecting individual 
colors by name.  Maybe we need more color names added to that one?

Also, both matplotlib and mathematica support continuous color maps, 
presumably because they can plot images or 2d arrays and they need 
gradients.  Since the racket plot package does not support this, I just 
wanted to implement color maps as a distinct set of colors, not as a linear 
gradient (see the link to the prototype code)

Also, even if this is added to the `plot` package itself, it can still be 
used outside of it, just as you can use `->pen-color` for things not 
related to plots.

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.


[racket-users] color-maps for the plot package

2019-03-19 Thread Alex Harsanyi

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.


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

2019-03-13 Thread Alex Harsanyi
On Thursday, March 14, 2019 at 9:06:12 AM UTC+8, Matt Jadud wrote:
>
> 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. 
>


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

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.


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

2019-03-13 Thread Alex Harsanyi
You can use the table pict constructor to construct tables, 
https://docs.racket-lang.org/pict/Pict_Combiners.html?q=table#%28def._%28%28lib._pict%2Fmain..rkt%29._table%29%29

Here is an example:

#lang racket
(require racket/draw pict)

(define (make-pretty-table items)
  (define column-count (length (car items)))
  (define picts '())
  (for (([row index] (in-indexed items)))
(define font
  (if (= index 0) ;; header
  (send the-font-list find-or-create-font 12 'default 'normal 
'normal)
  (send the-font-list find-or-create-font 10 'default 'normal 
'normal)))
(define color
  (if (= index 0)
  (make-object color% #x77 #x88 #x99)
  (make-object color% #x2f #x4f #x4f)))
(define face (cons color font))
(for ([item (in-list row)])
  (set! picts (cons (text (~a item) face) picts
  (let ((p0 (table column-count (reverse picts) lc-superimpose 
cc-superimpose 15 3)))
(cc-superimpose
 (filled-rounded-rectangle (+ (pict-width p0) 20) (+ (pict-height 
p0) 20) -0.1
   #:draw-border? #f
   #:color "LightYellow")
 p0)))

Will produce

[image: Capture.PNG]
You can control how the text in the columns is aligned as well and gives 
you full flexibility on how each cell is displayed (it can be an arbitrary 
pict).

The disadvantage is that the output is not interactive, and for large sets 
of data it is impractical, still, you can get really nice results for small 
amounts of data.

A snip% would also be feasible, and this would allow to implement scrolling 
and other nice interactive features, but that is more of a weekend project, 
not a "before my morning coffee one" like the above code :-)

Alex.

On Thursday, March 14, 2019 at 2:19:07 AM UTC+8, 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 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.


[racket-users] Re: What is the best way to "raco make" all *.rkt files in a directory tree?

2019-03-11 Thread Alex Harsanyi
To add one more answer to this thread :-)

In addition to compiling files specified on the command line, `raco make` 
will recursively compile all files referenced via `require`.  This means 
that if you have a top level file for your application, you can tell `raco 
make` to compile that file, and it will compile all the files that it 
references, the will be compiled only if they have changed.  There is also 
a `-j` option which allows compiling in parallel.  So, for example, if the 
toplevel file in your application is main.rkt you can do:

raco make -j 8 main.rkt

and all your project files will be updated.

Alex.

On Tuesday, March 12, 2019 at 3:00:34 AM UTC+8, Brian Adkins wrote:
>
> I looked over the documentation for raco make, and I didn't see anything 
> about how to recursively make all *.rkt files in a directory tree. I 
> suppose I could use something like:  find . -name \*.rkt | xargs raco make, 
> but I like being able to use all 8 "cores" with -j 8, and I *think* I'd 
> lose that with xargs.
>
> What is the best practice for making a tree of Racket code?
>
> Thanks,
> Brian
>

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


Re: [racket-users] "table" data structure in Racket

2019-02-21 Thread Alex Harsanyi


On Thursday, February 21, 2019 at 7:19:39 AM UTC+8, travis.h...@gmail.com 
wrote:
>
> Hi All,
>
> I'm resurrecting this thread to ask if anyone in the Racket community has 
> Apache Arrow on their radar. It seems like Apache Arrow might be gaining 
> steam.
>

> Apache Arrow is a cross-language development platform for in-memory data. 
>> It specifies a standardized language-independent columnar memory format for 
>> flat and hierarchical data, organized for efficient analytic operations on 
>> modern hardware. It also provides computational libraries and zero-copy 
>> streaming messaging and interprocess communication. Languages currently 
>> supported include C, C++, C#, Go, Java, JavaScript, MATLAB, Python, R, 
>> Ruby, and Rust. [Source 
>> 
>> ]
>
>
> I have no clue what it would take to make Racket a supported language. I 
> also don't have a sense of what kind of demand the Racket community has for 
> this sort of thing. Just curious if anyone is thinking about a Racket and 
> Apache Arrow pairing.
>
>
I had looked at Apache Arrow when it was first mentioned in this thread, 
but the project is large and providing bindings seemed like a large task -- 
the Java, Rust, JavaScript and Python bindings are large projects by 
themselves.  I suspect Apache Arrow (along with numpy and other scientific 
/ data-processing packages) are backed by several large companies who 
provide the development resources.

Providing usable Racket bindings for Apache Arrow is not something one can 
do as a hobby in a few weekends.  I ended up writing my own data frame 
package, which is smaller, simpler and has the features and performance 
levels that I need.

Alex. 
 

> Thanks,
>
> Travis 
>
> On Wednesday, April 6, 2016 at 1:27:56 AM UTC-7, Konrad Hinsen wrote:
>>
>> On 05/04/2016 21:12, Asumu Takikawa wrote: 
>>
>> > I haven't built anything like that, but I was hoping that we could get 
>> a GSoC 
>> > student for it (that didn't pan out though obviously). The idea was to 
>> use 
>> > packages from Python/Julia/R as inspiration: 
>> > 
>> >http://pandas.pydata.org/pandas-docs/stable/index.html 
>> >http://dataframesjl.readthedocs.org/en/latest/ 
>> >https://github.com/Rdatatable/data.table/wiki 
>>
>> Also consider this one: 
>>
>> https://arrow.apache.org/ 
>>
>> Konrad. 
>>
>

-- 
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: Autocomplete from a list

2019-02-14 Thread Alex Harsanyi
There are two solutions I can think of:

(1) derive combo-field% and override the on-popup method to construct the 
choice menu dynamically based on what is selected in the combo box field.  
This has a few disadvantages, namely (a) you have to produce the menu 
immediately, so if you have to query a database for the list of items, 
there might be a long delay for the menu to show up and (b) the menu will 
not update when the user types more text in the field, instead it will have 
to be closed and reopened.

(2) you can use a combination of text-field% and a list-box%, where the 
callback on the text field will populate the list box with the filtered 
contents.  The user would have to select an item from the list box, but 
this can be populated in a separate thread to prevent the GUI from freezing 
up during a database query.  It does not look as nice as GUI widgets from 
other applications though...

Here is some example code for both options, including an animation of what 
it looks like:

https://gist.github.com/alex-hhh/20f03dcf2f7f340d20b95cb36da39f61

Alex.


On Friday, February 15, 2019 at 5:39:31 AM UTC+8, James Platt wrote:
>
> I have a situation where I want a Racket GUI combo-field% (or some other 
> GUI element) to allow the user to select an exact item (uniquely matching a 
> database key) from a list that is too long to display all at once.  I'm 
> thinking that some form of auto completion would be best.  In Framework, I 
> see that there is an auto-complete method in text% but I don't see a way to 
> give it a specific search space to work from.  I see the opposite. You can 
> get the list which it is auto completing from but I don't see how to set 
> it.   
>
> I mention combo-field% because the equivalent item in the LibreOffice 
> database module does what I want.  I had a LibreOffice document which was 
> connecting as client to a PostgreSQL database.  The combo-field list items 
> were populated with an SQL query which got all the official human gene 
> symbols from the database.  At the time there were something like 40,000 
> unique official gene symbols.  The user could start typing and it would 
> reduce the list, as you go, to the remaining items that match.  Also, when 
> there are too many items to display at once, LibreOffice only displays the 
> first 10 or 20 items in the combo-field menu and gives you a scroll bar. 
>  This worked out pretty well for that use case.  I now have a very similar 
> one.   
>
> What would be the best way to handle this situation?  The user needs to 
> select an exact item from a database but there are too many items for a 
> simple menu. 
>
> James

-- 
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: Loading foreign libraries on Windows

2019-02-12 Thread Alex Harsanyi
The only thing I can suggest than is to try to debug the problem.

I would first try to use procmon from the sysinternals suite to determine 
what API calls are made when the library is loaded into Racket, which one 
returns an error and what are the parameters to that call.  I would also 
use dependency walker to determine what other DLLs are used by libgit -- 
sometimes a DLL fails to load because some other DLL it depends on is 
missing or corrupted, but when that is the case, the error messages are 
very confusing.

Alex.

On Tuesday, February 12, 2019 at 11:11:10 PM UTC+8, Philip McGrath wrote:
>
> As far as I can tell, yes. I've confirmed that the install script is 
> getting Racket from 
> https://mirror.racket-lang.org/installers/7.2/racket-7.2-x86_64-win32.exe
>
> -Philip
>
>
> On Tue, Feb 12, 2019 at 2:01 AM Alex Harsanyi  > wrote:
>
>> Do you have x64 Racket installed? This is an error that usually comes up 
>> when a 32 bit application tries to load a 64 bit DLL.
>>
>> Alex.
>>
>> On Tuesday, February 12, 2019 at 2:18:55 PM UTC+8, Philip McGrath wrote:
>>>
>>> I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The 
>>> problem appears to be specific to Racket, as I seem to be able to load the 
>>> same DLL from Python.
>>>
>>> Specifically, I'm trying to build platform-specific packages for 
>>> libgit2. I can build the library and run its test suite successfully, but 
>>> when I try to load the DLL with `ffi-lib`, using an absolute path to avoid 
>>> any search issues, it fails with the message "%1 is not a valid Win32 
>>> application.; errid=193". The AppVeyor build log is here 
>>> <https://ci.appveyor.com/project/philipmcgrath/native-libgit2-pkgs/build/job/urfo34x53oh0fr4l>,
>>>  
>>> and this is the Racket script 
>>> <https://github.com/LiberalArtist/native-libgit2-pkgs/blob/linker-errors/tmp-w64-test.rkt>
>>>  
>>> that fails to load the DLL. As I mentioned, I can load the DLL successfully 
>>> with this Python script 
>>> <https://github.com/LiberalArtist/native-libgit2-pkgs/blob/linker-errors/py-w64-test-tmp.py>
>>> .
>>>
>>> I'm not much of a Windows person, and I'm not sure what else to do to 
>>> debug this.
>>>
>>> -Philip
>>>
>> -- 
>> 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...@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 foreign libraries on Windows

2019-02-11 Thread Alex Harsanyi
Do you have x64 Racket installed? This is an error that usually comes up 
when a 32 bit application tries to load a 64 bit DLL.

Alex.

On Tuesday, February 12, 2019 at 2:18:55 PM UTC+8, Philip McGrath wrote:
>
> I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The 
> problem appears to be specific to Racket, as I seem to be able to load the 
> same DLL from Python.
>
> Specifically, I'm trying to build platform-specific packages for libgit2. 
> I can build the library and run its test suite successfully, but when I try 
> to load the DLL with `ffi-lib`, using an absolute path to avoid any search 
> issues, it fails with the message "%1 is not a valid Win32 application.; 
> errid=193". The AppVeyor build log is here 
> ,
>  
> and this is the Racket script 
> 
>  
> that fails to load the DLL. As I mentioned, I can load the DLL successfully 
> with this Python script 
> 
> .
>
> I'm not much of a Windows person, and I'm not sure what else to do to 
> debug this.
>
> -Philip
>

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


  1   2   3   >