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

2020-08-12 Thread Simon Schlee
Another approach might be to use multiple editor-snip% 
https://docs.racket-lang.org/gui/editor-snip_.html
within a pasteboard% https://docs.racket-lang.org/gui/pasteboard_.html

Or possibly together with other snip instances, I currently don't have the 
time to experiment with it
and no experience with pasteboards, so I am not sure whether that would 
work well and I am just dropping the idea ;)

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


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

2020-07-07 Thread Simon Schlee
yes it works again!

-- 
You received this message because you are subscribed to the Google 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/0673a1d4-5cf0-4969-97b6-9bb1dbb3c298o%40googlegroups.com.


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

2020-07-07 Thread Simon Schlee


> I think you probably went to www.racket-news.com, but you should go to 
> racket-news.com (without the www) instead. 
>

With or without www I get a certificate error, when I ignore the 
certificate I get a 502 from gitlab.
With different browsers and curl all give me the same responses. 
Does racket-news.com work for you? If so what could I check on my end?

(I don't know how reliable this site is but) this also claims that 
racket-news.com is down
https://downforeveryoneorjustme.com/racket-news.com

I think the site is hosted via gitlab and something there stopped working.

-- 
You received this message because you are subscribed to the Google 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/b1ba1196-027e-4c00-8459-dcb6fc9a6480o%40googlegroups.com.


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

2020-07-07 Thread Simon Schlee
When I ignore the certificate error I get a gitlab styled 502 response code.

I wanted to read the news so I found the gitlab repository and within it 
this markdown file: 
https://gitlab.com/racket-news/racket-news.gitlab.io/-/blob/master/_src/posts/2020-07-06-issue34.md
Posting this in case others have trouble seeing racket-news.com too.

-- 
You received this message because you are subscribed to the Google 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/9f1b9ef1-b272-40cb-b850-d7960412bf7do%40googlegroups.com.


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

2020-07-07 Thread Simon Schlee
I am getting an error message for the https certificate:

Websites prove their identity via certificates. Firefox does not trust this 
> site because it uses a certificate that is not valid for racket-news.com. 
> The certificate is only valid for the following names: *.gitlab.io, 
> gitlab.io
>

 

-- 
You received this message because you are subscribed to the Google 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/63e57ecc-63af-44fd-8730-5715b38f4097o%40googlegroups.com.


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

2020-06-20 Thread Simon Schlee
Declaring the dependencies explicitly is good in a lot of cases, but I 
guess there are cases where it is unnecessary.

If you do decide to create the uber package you can create the info.rkt, 
`raco pkg install` the package and then use `raco setup --fix-pkg-deps 
--unused-pkg-deps ` to let setup create the list of 
package dependencies.

-- 
You received this message because you are subscribed to the Google 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/8dc1fae7-5f7e-480d-81bf-4aee9ef69d14o%40googlegroups.com.


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

2020-06-20 Thread Simon Schlee


> What I'd like to do is to create a personal catalog that represents the 
> packages I currently have installed, but it doesn't appear there's a super 
> easy `raco pkg` command to do that - I still need to research a bit.
>

raco pkg archive --help
Create catalog from installed packages

Usage:
raco pkg archive [  ... ]   [] ...
 where  is one of
  --include-deps : Include dependencies of specified packages
* --exclude  : Exclude  from new catalog
  --relative : Make source paths relative when possible
  --help, -h : Show this help
  -- : Do not treat any remaining argument as a switch (at this level)
 * Asterisks indicate options allowed multiple times.
 Multiple single-letter switches can be combined after one `-'; for
  example: `-h-' is the same as `-h --'
 

-- 
You received this message because you are subscribed to the Google 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/1ce74a5d-ca53-42f6-a83e-666b77d4a4a1o%40googlegroups.com.


Re: [racket-users] Re: local variables are hyperlinked inscribble/manual

2020-06-13 Thread Simon Schlee
I struggled with a similar case, in my case the easiest/simplest solution 
was to use:
@var[identifier] instead of @racket[identifier]
(this works well for function arguments, but might not work for your case)
https://docs.racket-lang.org/scribble/scribble_manual_code.html?q=var#%28form._%28%28lib._scribble%2Fmanual..rkt%29._var%29%29

Writing this mainly for others who have overlooked var like I did.

Simon

-- 
You received this message because you are subscribed to the Google 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/dd6a15cc-684c-4998-b9bf-93e943a476ado%40googlegroups.com.


Re: [racket-users] raco setup --only-docs Is there something like this?

2020-06-02 Thread Simon Schlee
This cuts the time down from 6-7 seconds to 2-3 seconds for me, that is 
great, thank you!

previous:
time raco setup --doc-index --no-pkg-deps layout  6.85s user 1.29s system 
209% cpu 3.888 total

now:
raco setup -n -j 1 --doc-index --no-pkg-deps --avoid-main layout  2.31s 
user 0.47s system 99% cpu 2.792 total

-- 
You received this message because you are subscribed to the Google 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/0aa1ef51-8292-4ada-bfd9-42d5e8e58e07%40googlegroups.com.


[racket-users] raco setup --only-docs Is there something like this?

2020-06-02 Thread Simon Schlee
Hello,

I like that I can run: 
raco setup --doc-index my-collection-name

and it builds the documentation and makes it searchable on my local machine.
But I was wondering if there is a way to speed-up/skip some of the usual 
setup stuff that happens before building the documentation?

Should I use raco scribble instead?
If so is there a certain set of raco scribble arguments that is equivalent 
to what raco setup does?


Simon

-- 
You received this message because you are subscribed to the Google 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/5bd3ccd6-c5ba-4bca-9bde-8c0efbbdd8c2%40googlegroups.com.


[racket-users] pkgs.racket-lang.org Why are the links so inconsistent?

2020-05-26 Thread Simon Schlee
Hello,

searching through a bunch of different packages I noticed that the 
code/download links are quite inconsistent.

For some packages there is a download button clicking that button does 
nothing (in firefox) because it contains a git:// protocol url, here is an 
example package:
https://pkgs.racket-lang.org/package/pict-lib

But in the bottom table there is the row "Version exceptions" that uses the 
git protocol in the link text but a https protocol in the actual link.

What is the reason that the download button at the top uses the git 
protocol?
I would have expected https.

Why is it a download button? 
It could be a source button with the https address from the bottom.


I know that within the package preferences/edit-form it is possible to 
choose between simple url and git repository.
I suspect that the differences in the buttons that are shown for that 
package result from these different modes.

I think that it would be more user friendly to show the code button (with 
https address to github/gitlab/etc) for as many packages as possible,
this way you can easily get to the git repository of most packages. 
It is frustrating when packages that have a github repo are linked to with 
the git protocol, resulting in a download button that does nothing.

There are packages which aren't git repositories and for those it makes 
sense that there is only a download button, but no source button.


If the download button with git protocol is useful for some people (because 
they have taught their browser to open a git viewer application or 
something like that),
then it would make sense to have both buttons.

When I am on the documentation page and I click the package link I get to 
the package detail page, 
for many packages I can then click a second time on the code or download 
button and get to a website where I can explore the code without needing to 
download it.
When this works, it is excellent.
When it does not, it is frustrating.


Simon

-- 
You received this message because you are subscribed to the Google 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/cb8504c8-0fc2-4780-bf72-e6fec120e8a7%40googlegroups.com.


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

2020-05-23 Thread Simon Schlee
I think pollen uses racket's compiled directories to store some of its own 
cached/generated code, maybe a similar technique could be helpful for you.

Do you want to create submodules for arbitrary modules or only for modules 
using a certain library or language?
When its the latter I think its a community coordination issue.

I can understand wanting to encapsulate everything but it seems that module 
names are expected to be public interned symbols in the current 
implementation:
https://docs.racket-lang.org/reference/Module_Names_and_Loading.html?q=module#%28def._%28%28quote._~23~25kernel%29._make-resolved-module-path%29%29
"A resolved module path is interned. That is, if two resolved module path 
values encapsulate paths that are equal?, then the resolved module path 
values are eq?."
I think gensyms are not allowed, because they are not interned.

I also would find it interesting to have something functor like, in the 
sense of being able to create parameterized module instances.
My guess is that constructs like that are difficult to optimize and the 
separation between runtime and compile time can become extremely blurry.
To the point that certain dynamic constructs would cause big chunks of code 
to become ready for compiling at run-time only and at that time an 
interpreter might be faster.

These are just my intuitions, I have only limited experience with modules 
and functors with my own toy language experiments.

Maybe if you need very dynamic/custom behavior, instead of generating 
module files:
You could create a program which creates and evaluates certain in memory 
generated module-forms at runtime, attaches them to a namespace and then 
runs the other code with that namespace.
Allowing that code or your library to require and interact with the 
dynamically generated module.

So far my namespace usage was limited to attaching certain modules, but I 
think this is possible.
Think of it as a custom program launcher that acts like a 
"scripted"/automated interactive repl session.

Simon

-- 
You received this message because you are subscribed to the Google 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/be993550-da25-496b-abcb-705db0473a28%40googlegroups.com.


Re: [racket-users] How to run multiple Racket installations?

2020-05-09 Thread Simon Schlee
You could use the nix package manager https://nixos.org/nix/ it runs on 
many linux platforms and macOS.

It has predefined racket and racket-minimal packages, you can define 
derived versions of those packages and adapt them to your needs.
It allows you to easily switch between different packages, you could e.g. 
use different profiles within nix to manage the different installations or 
create a own/private package for each one.

I just started using nix, but so far I would recommend it, it is refreshing 
to be able to undo your changes by just activating a previous 
state/generation.
https://pyvideo.org/europython-2014/rethinking-packaging-development-and-deployment.html

Simon

-- 
You received this message because you are subscribed to the Google 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/fa21bcff-7aa3-4e0a-bb4a-cd4aa561e302%40googlegroups.com.


[racket-users] Re: On the importance of testing for noobs - or 'there's no such thing as a stupid test'.

2020-05-04 Thread Simon Schlee
And use contracts. 
I can't claim that all my code uses contracts everywhere, but when I 
encounter unexpected/bewildering behavior I add contracts to break those 
chains of "piped functions".
You can start with define/contract for ease of use.

Later on you can put functions that belong together in one module and test 
that they work as expected.
Then use (provide (contract-out ...)) to put contracts on the exposed 
functions, structs, etc. to make sure that they can't be used with 
unexpected values from the outside.
This way your module can have internal invariants which can't be broken 
from the outside.

Simon

-- 
You received this message because you are subscribed to the Google 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/f2bd097c-5718-4ead-b497-7703942af12b%40googlegroups.com.


[racket-users] Re: bitmap% performance

2020-04-23 Thread Simon Schlee
Hi,

have you tried using read-bitmap? 
https://docs.racket-lang.org/draw/Drawing_Functions.html?q=read-bitmap#%28def._%28%28lib._racket%2Fdraw..rkt%29._read-bitmap%29%29

Personally I have only used the second constructor that takes a parameter 
named "in" here:
https://docs.racket-lang.org/draw/bitmap_.html

I didn't notice any performance problems, but my images have much lower 
resolution.

I resize my images by using the bitmap function which returns a pict, then 
using scale-to-fit, then using pict->bitmap to convert back to a bitmap.

Hope that is helpful,
otherwise you could provide an example that I can test on my computer, I am 
on linux.

Good luck!
Simon

-- 
You received this message because you are subscribed to the Google 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/b5d6bac2-bc9f-4966-a2a8-8b872825dd17%40googlegroups.com.


[racket-users] Re: Lightweight, lazy trees (new package)

2020-04-22 Thread Simon Schlee
Hi Sid,

this looks like a nice, clean, simple to use interface,
that could replace some of my adhoc tree traversals hidden within,
some of my code.
I am looking forward to playing around with it and seeing where I can use 
it, thank you for creating it!

Have a great day!

Simon

-- 
You received this message because you are subscribed to the Google 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/47c44020-4f17-4581-a973-3c519a9f33ea%40googlegroups.com.


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

2019-12-02 Thread Simon Schlee
Yes, when I put on my pragmatic thinking hat, I certainly agree with you.
But it also makes me think about whether I should create a utility library 
which does a more abstracted window placement and restoring.
That library would care more about logical "human" positioning and for 
example snap to screens and possibly use platform specific code like you 
suggested.
Currently such a library seems to be nice to have, but not that urgent to 
me.

On the other hand when I play devil's advocate I think racket/gui is a 
cross-platform gui library and should have a highlevel api where these 
platform specific quirks don't leak through.

I am unsure what is most reasonable and the better approach, I guess 
changing the move behavior might be difficult because of backwards 
compatibility,
so the utility library might be the way to go.

-- 
You received this message because you are subscribed to the Google 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/49c69439-2590-4429-ae58-b7edd18b6898%40googlegroups.com.


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

2019-12-01 Thread Simon Schlee
created an issue for this:
https://github.com/racket/gui/issues/149

-- 
You received this message because you are subscribed to the Google 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/6cfb6e25-81fb-40f3-8da0-973c4bfc45f4%40googlegroups.com.


Re: [racket-users] question re downloading a PDF file

2019-11-25 Thread Simon Schlee
Hello,

call-with-output-file and copy-port makes this task easier.
Took me a while before I found out about copy-port, too.
Maybe there are a few places in the documentation that should have explicit 
mentions of it.

#lang racket

(require net/url)

(define/contract (download-file uri save-as-path)
  (-> string? path-string? any/c)
  (call-with-output-file save-as-path
(λ (out)
  (define in (get-pure-port (string->url uri)))
  (copy-port in out))
#:exists 'replace))

(module+ main
  (download-file "https://racket-lang.org/img/racket-logo.svg; 
"racket-logo.svg"))

-- 
You received this message because you are subscribed to the Google 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/9ea93faa-c38a-45e6-94cf-e5504d77cc30%40googlegroups.com.


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

2019-11-21 Thread Simon Schlee
Hello,

I am writing a gui application it is supposed to save the position of the 
window and upon restart restore the position.
For this I get the position via overriding the on-move method of frame%.
Upon restoring I call (send frame move x y).

The problem is that on my system (linux manjaro xfce gtk) move seems to 
treat the position as the outer window position (left-top of the decorated 
window).
When move is called and x y is different than what is returned via get-x 
and get-y then on-move is called two times the first time with x and y.
The second time with the delta added which corresponds to 
outer-window-pos+delta = inner-window-pos.

(send frame move outer-x outer-y) -> (on-move outer-x outer-y) -> (on-move 
inner-x inner-y)

The resulting problem is that after every restart the window moves by the 
delta because move adds the delta.
To me it seems like on-move should only be called once after a call to move 
and move should take inner-xy directly.
That would mean it sets the position of the inner-window-coordinate instead 
of setting the outer position.

Here is an example showing the move behaviour:
#lang racket/gui

(define moveframe%
  (class frame%
(super-new)

(define/override (on-move x y)
  (displayln (format "~a ~a" x y)

(define (example)
  (define f (new moveframe% [label "move frame"] [width 300] [height 300]))
  (define (m msg x y)
(displayln (~a msg " " x " " y ":"))
(send f move x y))

  (m "init" 100 100)
  (send f show #t)
  (sleep/yield 1)
  (m "reset" 100 100)
  (sleep/yield 1)
  ;; this depends on the window decoration specific delta which is (1 24) 
on my system
  (m "stays the same, because x y are already" (send f get-x) (send f 
get-y))
  (sleep/yield 1)
  (m "window decoration delta gets added" (add1 (send f get-x)) (send f 
get-y))
  (sleep/yield 1)
  (m "window decoration delta gets added again" (add1 (send f get-x)) (send 
f get-y))
  (sleep/yield 1)
  (send f show #f))

(module+ main
  (example))

;; OUTPUT
;; init 100 100:
;; 100 100
;; 101 124
;; reset 100 100:
;; 100 100
;; 101 124
;; stays the same, because x y are already 101 124:
;; window decoration delta gets added 102 124:
;; 102 124
;; 103 148
;; window decoration delta gets added again 104 148:
;; 104 148
;; 105 172


And here is an ugly workaround I created that calculates the delta between 
the outer and inner of the window:
#lang racket

(provide get-delta)

(require racket/gui/base)

(define deltaframe%
  (class frame%
(init-field channel)
(super-new [label "get-delta-frame"])

(define ch channel)
(define first-pos #f)
(define/override (on-move x y)
  (when ch
(if (not first-pos)
(set! first-pos (list x y))
(begin
  (calc-delta ch first-pos (list x y))
  (set! ch #f)

(define (calc-delta ch first second)
  (match-define (list hx hy) first)
  (match-define (list vx vy) second)
  (define delta (list (- hx vx) (- hy vy)))
  (thread
   (thunk
(channel-put ch delta)
(send this show #f

(send this move 100 100)
(send this show #t)))

(define (get-delta/fetch)
  (define ch (make-channel))
  (thread
   (thunk (new deltaframe% [channel ch])))
  (define (loop)
(sync (handle-evt ch (λ (delta) delta))
  (handle-evt always-evt (λ (x) (sleep/yield 0) (loop)
  (loop))

(define delta #f)
(define (get-delta)
  (set! delta (get-delta/fetch))
  (set! get-delta (λ () delta))
  delta)

;; result of get-delta on my system: (list -1 -24)

Does somebody else experience this behaviour?

-- 
You received this message because you are subscribed to the Google 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/20ea5aea-3ed4-42b4-865b-51012637c6bf%40googlegroups.com.


Re: [racket-users] Modeling a context-sensitive evaluation context with PLT Redex?

2019-11-10 Thread Simon Schlee
I have no experience with Redex (it is one of the things I want to get more 
familiar with in the future), but I happened to watch this talk:
"Finding bugs without running or even looking at code" by Jay Parlar
https://www.youtube.com/watch?v=FvNRlE4E9QQ

Maybe a tool like this is interesting to you?
I am not sure if it would be helpful for you to model some of your ideas 
with a tool like in the talk.
Maybe it could be useful for especially difficult to imagine combinations 
of features, or sub problems. Just guessing here...
It also reminds me of miniKanren.

Anyways good luck with your research!

-- 
You received this message because you are subscribed to the Google 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/f906eac4-e31b-4ac9-a3b2-4d4c66316895%40googlegroups.com.


[racket-users] Re: Mandelbrot set compute pipeline functional in racket-vulkan

2019-11-03 Thread Simon Schlee
Thank you, for creating this!

Currently I am still using opengl for my projects, until I have time to 
learn vulkan and port to it.
I created a pull request which saves the image via a bitmap% to get rid of 
the external `convert` program.

-- 
You received this message because you are subscribed to the Google 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/0f8c6b84-e61b-4b21-8a35-df97583cbc31%40googlegroups.com.


Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-30 Thread Simon Schlee
Hi Tomas,

you say you drain the set, do you remove elements one by one from it?
Do you need more from that set than only getting successive elements from 
it?

It seems you are implementing something, which might require going lower 
level or using different data structures.
I am still not really able to fully grasp your use-case.
Just thinking out loud here:
It could be that the internal structure of the implementation would allow 
to add some operation that lets you directly do what you want?

A long time ago before I found racket, I used python and before that c++, 
this thread reminds me of playing around with an early version of this 
library 
https://www.boost.org/doc/libs/1_71_0/libs/multi_index/doc/index.html 
Maybe racket should have something similar which lets you create custom 
data-types with multiple access semantics in a generative programming 
family of types way, through some kind of dsl that describes/configures the 
datatype that is being generated.

But currently I don't work on lowlevel / highly optimized code, although I 
find it very interesting.

-- 
You received this message because you are subscribed to the Google 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/a10988c1-af1b-49c7-9d70-25791dc30406%40googlegroups.com.


Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-30 Thread Simon Schlee
Hi Thomas,

it seems to me that you may have a misleading intuition for racket's hash 
tables.
Racket has mutable and immutable hash tables these are implemented 
differently.
Because as a user of hash tables you have to differentiate between mutable 
and immutable,
there are also different hash operations some of which can only be used 
with mutable and other that are used with immutable hash tables.

Immutable hash tables are excellent for your use case, because you can 
easily keep around the original version just by keeping a 
variable/reference to it.
As its name implies it is immutable/not changed, so when you "update" the 
hash that you are using as a set you aren't really updating it, instead you 
create a new updated hash from it, while the original version remains as it 
was. Because the immutable hash is implemented as a persistent 
data-structure with structural sharing, this is efficient, 
because it doesn't copy everything but instead only copies a few small 
internal nodes, those which need to be changed, the rest refers to the 
old/original version.
Depending on the racket version there are different internal 
implementations of immutable hashes, 
but you can expect operations like hash-set to create a small extended 
version of your hash (if you are using racket's immutable hashes) that 
doesn't copy the complete hash.

Immutable hash tables actually provide O(log N) access and update. Since N 
> is limited by the address space so that log N is limited to less than 30 
> or 62 (depending on the platform), log N can be treated reasonably as a 
> constant.
>
from https://docs.racket-lang.org/reference/hashtables.html 

If you want to use the original hash as if it were a set you can do that by 
using hash operations instead of set operations like Stephen suggested.
Another possibility is to create a custom-set implementation which wraps 
the hash to appear like a set, here is an example implementation:

#lang racket

(provide (contract-out
  [proxy-set (-> (and/c hash? immutable?) generic-set?)])
 proxy-set->set
 proxy-set->seteq
 proxy-set->seteqv)

(require racket/struct)

(struct proxy-set [hash]
  ;; #:transparent
  #:methods gen:set
  [(define (set-member? s k)
 (hash-has-key? (proxy-set-hash s) k))
   (define (set-add s v)
 (proxy-set (hash-set (proxy-set-hash s) v #f)))
   (define (set-remove s v)
 (proxy-set (hash-remove (proxy-set-hash s) v)))
   (define (set-empty? s)
 (hash-empty? (proxy-set-hash s)))
   (define (set-count s)
 (hash-count (proxy-set-hash s)))
   (define (set->stream s)
 (sequence->stream (in-immutable-hash-keys (proxy-set-hash s]

  #:methods gen:custom-write
  [(define write-proc
 (make-constructor-style-printer
  (lambda (s) 'proxy-set)
  (lambda (s) (in-immutable-hash-keys (proxy-set-hash s)])

;; these functions are in case you eventually don't need the proxy anymore
;; and want to convert to a plain racket set
(define/contract (proxy-set->set s)
  (-> proxy-set? (and/c generic-set? set-equal? set?))
  (for/set ([k (in-immutable-hash-keys (proxy-set-hash s))])
k))

(define/contract (proxy-set->seteq s)
  (-> proxy-set? (and/c generic-set? set-eq? set?))
  (for/seteq ([k (in-immutable-hash-keys (proxy-set-hash s))])
k))

(define/contract (proxy-set->seteqv s)
  (-> proxy-set? (and/c generic-set? set-eqv? set?))
  (for/seteqv ([k (in-immutable-hash-keys (proxy-set-hash s))])
k))

(define-syntax-rule (show x)
  (displayln (format "~a: ~a" (quote x) x)))

(define (example)
  (define original-map (hasheq 'a 4 'b 7 'c 1))
  (show original-map)

  (define extended-map (hash-set original-map 'another 42))
  (show extended-map)

  (define derived-set (proxy-set original-map))
  (show derived-set)

  (define extended-set (set-union derived-set (seteq 'd 'e)))
  (show extended-set)

  (displayln "after all that the original map remains unchanged")
  (show original-map)
  (displayln "and the extended set does not modify the derived set")
  (show derived-set)

  (displayln "you also can merge the new keys from the extended-map")
  (displayln "with the extended-set at a later point")
  (define merged-set (set-union extended-set (proxy-set extended-map)))
  (show merged-set)

  (displayln "or convert the proxy-set to a plain racket set")
  (define plain-set (proxy-set->seteq merged-set))
  (show plain-set))

(module+ main
  (example))

;; output
;; original-map: #hasheq((a . 4) (b . 7) (c . 1))
;; extended-map: #hasheq((a . 4) (another . 42) (b . 7) (c . 1))
;; derived-set: #
;; extended-set: #
;; after all that the original map remains unchanged
;; original-map: #hasheq((a . 4) (b . 7) (c . 1))
;; and the extended set does not modify the derived set
;; derived-set: #
;; you also can merge the new keys from the extended-map
;; with the extended-set at a later point
;; merged-set: #
;; or convert the proxy-set to a plain racket set
;; plain-set: #

-- 
You received this message because 

[racket-users] Re: horizontal alignment in a message% or equivalent

2019-10-13 Thread Simon Schlee
Another possibility is to set the stretchable-width of the message to #f, 
this way the message does not take more than its minimal required space.

#lang racket/gui

(define (example)
  (define frame (new frame% [label "Alignment example"] [width 400]))
  (define vbox  (new vertical-panel% [parent frame]))

  (define (test h-align)
(define p (new horizontal-panel% [parent vbox] [alignment `(,h-align 
center)]))
(new message% [parent p] [label (symbol->string h-align)] 
[stretchable-width #f]))

  (for-each test '(left center right))

  (send frame show #t))

(module+ main
  (example))


[image: RacketPanelAlignmentExample.png]

-- 
You received this message because you are subscribed to the Google 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/1654c527-87df-4b5c-ac86-68f616c06733%40googlegroups.com.


[racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Simon Schlee
I meant to write (less confusing):
"You say you want to use some definitions in your macro, why not just pass 
the relevant ones as arguments to your macro?" 

-- 
You received this message because you are subscribed to the Google 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/75ca34f2-4aa7-4b05-9421-bb143ff225c0%40googlegroups.com.


[racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Simon Schlee
Your second macro does not work as you expect, because by default macros in 
racket are hygienic, described roughly that means that a macro only 
"manipulates" the syntax it is given as arguments, not with the syntax 
around its invocation. As gfb has mentioned one way to do this is to use 
parameters, this way you can achieve dynamic effects without breaking 
hygiene.

Why is hygiene good? This section in the guide explains: 
https://docs.racket-lang.org/guide/pattern-macros.html?q=macro#%28part._.Lexical_.Scope%29

You say you want to use some definitions in your macro, why not just pass 
the relevant ones as parameters? 
Without knowing more about what you are trying to do, it is difficult to 
suggest a good direction/solution.

Not part of the answer, but related and interesting:
(fifth RacketCon): Matthew Flatt — Bindings as Sets of Scopes
https://www.youtube.com/watch?v=ABWLveMNdzg

-- 
You received this message because you are subscribed to the Google 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/05e6ed93-596d-472e-8e3e-b2e7d87c695b%40googlegroups.com.


Re: [racket-users] Re: third-party package tips and developer concerns (Was: New version of file-watchers)

2019-09-02 Thread Simon Schlee
Am So., 1. Sept. 2019 um 22:55 Uhr schrieb Neil Van Dyke <
n...@neilvandyke.org>:

> Simon Schlee wrote on 9/1/19 3:28 PM:
> >
> > Try not to make identifiers be simple generic terms, like `watch`
> >
> >
> > I strongly disagree with this statement.
>
> I think what you say is valid, and I agree in some situations.
>
> However, we're talking about reusable third-party packages, which are
> used pretty much the same as much of the "standard library" of Racket.


Maybe the differences in our priorities stem from the differences in the
way that we use racket.
I do not have the perspective of working on multi-person big code bases
with racket and the special gotchas that come up with that.
Maybe that is one requirement that should be considered and talked about
explicitly.
Consider creating an rfc/issue that describes some of the sticking points
with current racket with big projects?
I think it would give valuable insight and allow me and other people to see
problems from a different perspective.
I imagine that there is a big design space of solutions that would help for
big projects and probably also rackety inventions that could still be made.

The reason why I find it appropriate to just call it `watch` is, because
from my personal experience I find it highly unlikely that a file watching
package would be used globally throughout an entire code base. It is much
more likely that it will be used in 1-3 small modules and it is also likely
that those modules will convey a general idea that they are all about
handling files and the require will make it obvious that a file-watching
library is used.
Especially if you are using DrRacket and its ability to show arrows to the
require that provides that identifier.

I think we might not completely agree on the watch example, but it is good
to see the different perspective and something to keep in mind while
further thinking about it.

When it comes to worse is better, I do agree in the sense of getting things
started and producing results in the short term. But I also think that it
is valuable to sometimes take a break on short term solutions and consider
what long term possibilities there could be. This might only result in a
vague idea for future development or direction and you may end up needing
the short term solution anyway, but I think its worth it to try to imagine
different ways of doing things.

-- 
You received this message because you are subscribed to the Google 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/CA%2BoR%3DW%2Bi9-2W7wh0yQi%3DoN6bQA80n5fNaq1FFvivUWtdcnR9bg%40mail.gmail.com.


Re: [racket-users] Re: third-party package tips and developer concerns (Was: New version of file-watchers)

2019-09-01 Thread Simon Schlee

>
> Try not to make identifiers be simple generic terms, like `watch`
>

I strongly disagree with this statement.
Rackets require possibilities are highly flexible so if you want more 
specific names use prefix-in and prefix the module name or whatever you 
like.
The way racket does imports is one of the things I highly value because you 
can use modules to aggregate identifiers from different modules/packages,
resolve name conflicts by renaming / or not exporting the 2 identifiers 
that clash.
This creates a lot of freedom to create specific sets of functionality 
exported by one simple module.
This way I can create my custom set of things which are most needed in the 
particular codebase.
Instead of having to write 40 lines of requires like you have to in other 
languages.
Adding prefixes to imports is easy, having to create a prefix-remove that 
can be used in require to cut away prematurely added prefixes would annoy 
me.

Finding things in the documentation is a whole other technical issue.
If you find the documentation search features lacking for your search 
needs, we should figure out how the search could be improved, instead of 
making the code unnecessary verbose.
You already could use "watch M:" to only find 
identifiers exported by modules that use that module path.

-- 
You received this message because you are subscribed to the Google 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/ebdb13a3-13ab-465f-a115-9681c76b1dfd%40googlegroups.com.


[racket-users] Re: gen:stream doc fix?

2019-08-27 Thread Simon Schlee
I agree with your explanation and your version.
I think nobody expects stream-rest to change the concrete type of stream, 
unless there is a good reason for it.
My guess is that nobody noticed because it happens to work.

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


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

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

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


[racket-users] Re: returning GUI elements in function?

2019-07-09 Thread Simon Schlee
Classes are really nice and easy for tasks like this, it took me a little 
bit to get used to the class syntax, but now I love them.
I found that it helps to look at real code that uses classes, because the 
documentation quickly goes into quite advanced/special use cases.
You can use them to wrap-up/encapsulate a bunch of smaller gui parts and 
then just expose some methods that handle the updates etc. 

As always, I welcome people sharing alternative ways to write the same 
> code. 
>
Here you go:

#lang racket/gui

(define progress-bar%
  (class horizontal-pane%
(super-new)

(define gauge (new gauge%
   [label #f]
   [parent this]
   [range 100]))

;; initialize to 100% with no auto resize
;; this way the label has the right size
;; so that everything can be seen
;; and it does not "wobble" around while filling up
(define msg (new message%
 [parent this]
 [label "100%"]))

(define/public (set-value val)
  (send gauge set-value val)
  (send msg set-label (string-append (~a val) "%")))

;; set back to 0%
(set-value 0)))


(module+ main
  (define frame (new frame%
 [label "Progress Bar"]
 [width 300]))
  (define progress (new progress-bar% [parent frame]))

  (send frame show #t)
  (for ([i (in-range 1 101)])
(sleep 0.05)
(send progress set-value i)))


-- 
You received this message because you are subscribed to the Google 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/0aed70ba-65e0-4d49-a1c4-f1b67faced92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Seeking users to try file monitoring package

2019-06-30 Thread Simon Schlee
After some more reading I think I understand the purpose for 
watch-directories as a simple way to define callbacks for changes.
Maybe it could return a shutdown procedure but I guess using a custom 
custodian and shutting that down might be easier.

-- 
You received this message because you are subscribed to the Google 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/042dc9e3-bb1b-4db1-8f13-e2933dba5e88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Seeking users to try file monitoring package

2019-06-30 Thread Simon Schlee
I Just had a quick look at the documentation, it states:

watch-directories
> Starts threads using thread-maker to watch each given directory. Meant 
> for use with file-watcher procedures, namely apathetic-watch, 
> intensive-watch, or robust-watch. This will block the current thread 
> until all threads created with thread-maker terminate.
>

My understanding is that this watches for a single change for every 
directory and then unblocks. Creating a thread for each directory seems 
unnecessary (see example below).

Usually my filesystem-watching-needs are of a different nature:
- Get informed about changed files in a directory or one of its 
subdirectories, and what that changed file is
- do something with the filepath for that file (e.g. calculate the new sha1 
hash compare with the old one, etc.)
- continue watching for other changes

To accomplish this I usually use a hash to map monitored pathes to the 
filesystem-change-evt that monitors that path.
If you use wrap-evt you can make your life easier by returning the path as 
the syncronization result instead of the filesystem-change-evt itself:

(define (wrap path)
  (wrap-evt (filesystem-change-evt path)
(λ (evt) path)))

Then you can monitor all directories with one big sync, that returns one of 
the changed pathes, then you can immediately create a new 
filesystem-change-evt for that path to get further changes.
Here is an example:
#lang racket

(define (wrap path)
  (wrap-evt (filesystem-change-evt path)
(λ (evt) path)))

(define (watch-pathes pathes proc)
  (define state
(for/hash ([p (in-list pathes)])
  (values p (wrap p

  (define watcher
(thread
 (thunk
  (let loop ()
(define changed-path (apply sync (hash-values state)))
(set! state (hash-update state changed-path (λ (old) (wrap changed-
path
;; at this point the change events are all updated and ready to 
detect new changes
;; so it is not problematic if we do not sync right away
;; send changed-path to some queue/async-channel/small lambda 
etc.
(proc changed-path)
(loop)

  (define (stop)
(kill-thread watcher))

  stop)


(module+ main
  (require racket/async-channel)

  (define changed-pathes (make-async-channel))
  (define watcher
(watch-pathes (list "." "..")
  (λ (path)
(async-channel-put changed-pathes path

  (define tmp "./tmp.txt")
  (with-output-to-file tmp #:mode 'text (thunk (displayln "temp temp 
temp")))
  (sleep 1)
  (delete-file tmp)

  (let loop ()
(define path (async-channel-get changed-pathes))
(when path
  (displayln (~a "Directory has changed: " path))
  (loop

;; In a full example you would also handle when filesystem-change-evt fails 
with an error
;; if the path does not exist, but that seems to be higher-level logic
;; and quite dependend on the application

>From the documentation I don't quite get what the typical usecase for your 
watch-directories function would be, because I would have to call the 
function multiple times if I want to get more than one change notification 
per directory.
And if I specify two directories and one has many changes but the second 
only 1 after an hour, the application would only react to the changes in 
the first directory after a long time.

I am a Linux user so I can't help you with the mac testing.


Well after looking into the code I realize that you already do something 
similar with bulk-filesystem-change-evt and apathetic-watch.
And the example for apathetic-watch seems quite clear, but I think you want 
kill-thread instead of thread-wait ?
Anyways I will leave the example because it is already written, maybe it is 
somewhat useful.


-- 
You received this message because you are subscribed to the Google 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/18221b2a-1a82-4776-b40f-58b8ff7294e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: db module 'query' does not return insert-id

2019-04-24 Thread Simon Schlee


> > (require db)
> > (define db (postgresql-connect  ...args...))
> > (simple-result-info (query db "insert into collaborations (name) values 
> ('foojalskdsfls')"))
> '((insert-id . #f) (affected-rows . 1))
>

With postgresql instead of doing a plain insert you can use returning to 
return your id:
(assuming your collaborations table has a id field that is automatically 
initialized)

> (query-row db "insert into collaborations (name) values ('foojalskdsfls') 
returning id")

'#(3);; the id of your inserted row


see returning in the postgres-documentation: 
https://www.postgresql.org/docs/9.5/sql-insert.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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: [how to] search for #lang languages in packages and GitHub?

2019-01-21 Thread Simon Schlee

>
> Does anyone know good way to search for Racket #lang languages in packages 
> and github?  (GitHub advanced search is dire)
>

Maybe this helps you: https://searchcode.com/?q=%23lang=143

-- 
You received this message because you are subscribed to the Google 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] crashing scrollbars (gtk3 bug?)

2018-05-26 Thread Simon Schlee
Hello,

while writing this email I found a solution to my problem.
By setting the PLT_GTK2 environment variable to:
export PLT_GTK2=/usr/lib64/libgtk-x11-2.0.so
like described in https://docs.racket-lang.org/gui/libs.html
The program runs with gtk2 and no longer crashes (with gtk3 it does for me)

This seems to indicate that this is gtk3 bug.
Below my original question. 

I have a short gui program which crashes when I move my cursor over the 
list box and then leave its area while passing the scrollbar.
I am not sure whether this is a gtk or racket bug.

I am running Manjaro 17.1 with Xfce 4.12 and Racket v6.12
Someone on irc tried it and could not reproduce it with Xfce 4.12 and 
Racket v6.12.

Here is the program:

#lang racket

(require racket/gui)

(module+ main
  (define frame (new frame% [label "Bug: crashing scrollbars"]))
  (define box (new list-box%
   [label #f]
   [choices (list "A" "B")]
   [parent  frame]))
  (send frame show #t))

;; after leaving the list-box hovering over the scrollbar with the mouse:
;; Gtk: _gtk_css_image_get_concrete_Thank you
size: assertion 'default_width > 0' failed
;; Gtk: _gtk_css_image_get_surface: assertion 'surface_width > 0' failed
;; SIGSEGV MAPERR si_code 1 fault on addr 0x1c
;; [1]4105 abort (core dumped)  racket gtkbug.rkt

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