Re: [racket-users] Re: how to show raco full (non-abbreviated) error messages

2018-08-12 Thread Greg Hendershott
> given procedure: ...amm-3.1/util.scm:58:6

It seems you had something like `(map (lambda (x) x) (list 1 2 3)
(list 1 2 3))` and the error message wants to show the name of the
function.

What is the name of an anonymous function?  That sounds like a Zen
koan. But there is an automatically inferred name, using the source
location:

  https://docs.racket-lang.org/reference/syntax-model.html#(part._infernames)

So `(object-name (lambda (x) x))` is something like
`'/path/to/file.rkt:11:22`.  But it seems to be elided for
/somewhat/long/pathname/for/file.rkt.

How to avoid this? I suppose you could do (procedure-rename (lambda
(x) x) 'shorter-name). But then you might as well just `define` a
named function or bind the lambda to a value using `let`.

-- 
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: bug#30680: [racket-users] Using Racket's raco on on Guix(SD)

2018-08-12 Thread Christopher Lemmer Webber
Good news: this seems fixed with this patch.  Some more comments inline.

Timothy Sample writes:

>>> Also, I checked all of this from Racket without grafts, and it never
>>> complained about compiling OpenSSL stuff.  Running “raco setup” gives
>>> some other errors, though.
>>
>> You're right... without grafts it doesn't have the openssl error.  The
>> other writing to the store issues still seem to persist, but it doesn't
>> block running "raco setup" (after a "raco pkg install", a step I had
>> omitted earlier).
>
> Okay.  I was confused about the “raco setup” example, but the other step
> makes more sense now.
>
> I will say that even on Debian, with an regular user, I have seen
> “permission denied” errors because Racket tries to update files in
> “/usr/share”.

Okay... on that note, "raco pkg install" now completely works IME
without permission errors, I should mention.  I'm still seeing a couple
of permission errors on "raco setup", but they don't look like they
matter unlike the ones that were appearing earlier.  And you're right,
I tried on Debian and got some errors too.

For the record, the ones I saw looked like this:

delete-file: cannot delete file
  path: /gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/bin/raco
  system error: Read-only file system; errno=30
  context...:
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/launcher/launcher.rkt:358:0:
 make-unix-launcher
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:1451:13:
 for-loop
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:1428:8:
 make-launcher
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:1556:8:
 for-loop
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:178:50
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:1425:4:
 for-loop
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/setup-core.rkt:71:0:
 setup-core
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/setup/main.rkt:
 [running body]
   
/gnu/store/33rx7rh6q22h3r11x8prz37nl7ygfl22-racket-6.12/share/racket/collects/raco/main.rkt:
 [running body]

But again, I don't think they matter.

>> ISTM that this is a separate bug.  In fact I'm afraid I've polluted this
>> bug with what I thought were all the same bug but turned out to be
>> several different bugs, of which a couple are fixed now thanks to your
>> help.
>>
>> PS: About the bounty, my thoughts are that some of these smaller issues
>> being resolved are already worth a smaller amount of compensation (and
>> thanks!), but there are *two different* larger issues of which probably
>> either is worth the full amount (though I can only afford to pay for
>> one)... one of them is the issue of the grafts breaking eg openssl
>> (which maybe we should file as a separate bug?), and the other is this
>> original bug (30680) about the attempts to compile to the store (which
>> does not seem as big of a blocker as it did previously, but is still
>> very annoying).  Does that seem fair?  (Feel free to contact me
>> off-list.)
>
> Actually I think there is only one bug, which is the grafts thing.  This
> bug was originally about compiling OpenSSL files to the store.  Grafting
> doesn’t break OpenSSL it just makes Racket try to recompile its OpenSSL
> FFI wrappers.
>
> I have a patch, too.  I sent it to guix-patches, but I must have made a
> mistake because it ended up in bug-guix attached to this bug report.
> The patch can be found at .  Also, the
> attachment didn’t get sent to the list, but did make it to the bug page.
> Hm  Sorry for the goof!

It seems good to me.  I'm going to push it.  Thanks for your work on
this!

I'll email you off-list about paying the bounty :)

-- 
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] racket 7.0 typed racket, a small problem with the type of the method set-pixel from Bitmap-DC%

2018-08-12 Thread Matthias Felleisen

This sounds like a bug in the initial type environment for Typed Racket. It’s 
worth a Github Issue or PR. 


> On Aug 12, 2018, at 2:56 PM, Axel Schnell  wrote:
> 
> I just encountered a problem while I was experimenting with typed racket and 
> the drawing toolkit. I called (send my-bitmap-dc some-x-value some-y-value 
> my-color) and the interpreter complained that set-pixel broke it's own 
> contract. I decided to look at the type of this method (or should I better 
> call it function?). The type is defined in a file named "gui-types.rkt". In 
> the section of the type-definition of Bitmap-DC% is the line
> [set-pixel (Real Real (Instance Color%) -> Boolean)]
> I changed that into 
> [set-pixel (Real Real (Instance Color%) -> Void)]
> Now my code worked perfectly and I'm happy for the time being.
> 
> But as I am not really a developer I don't feel too comfortable changing 
> program code which should be private to the racket-lang system. So my 
> questions are now was it alright to make this change or is there something 
> which has to be considered first before making such changes deep in the 
> racket-lang system?
> 
> Thanks in advance for any suggestions.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


Re: [racket-users] Question about style

2018-08-12 Thread Greg Hendershott
As others said, naming intermediate values can make things clearer.
(Taken too far, maybe it's hard to see the forest for the trees? I
think it depends on the audience and the domain.)

You happened to choose an example that illustrates a reason maybe not
to do this with let* or define -- cleaning up resources like input
ports. I would write this particular thing using call/input-url.

  
https://docs.racket-lang.org/net/url.html#(def._((lib._net%2Furl..rkt)._call%2Finput-url))

For instance, I'd probably change construct-url to return a url struct
like its name suggests, then write something like:

(define (get-data input)
  (define url (construct-url input))
  (call/input-url url get-pure-port read-json))

or perhaps just:

(define (get-data input)
  (call/input-url (construct-url input)
  get-pure-port
  read-json))

This takes care of closing the port, even if read-json errors.

Also, I like the way it reads: "From this URL, connect this way, and
read this way."  So, this is another way to name pieces, taking
advantage of well-chosen names for the functions.

-- 
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] racket 7.0 typed racket, a small problem with the type of the method set-pixel from Bitmap-DC%

2018-08-12 Thread Axel Schnell
I just encountered a problem while I was experimenting with typed racket 
and the drawing toolkit. I called (send my-bitmap-dc some-x-value 
some-y-value my-color) and the interpreter complained that set-pixel broke 
it's own contract. I decided to look at the type of this method (or should 
I better call it function?). The type is defined in a file named 
"gui-types.rkt". In the section of the type-definition of Bitmap-DC% is the 
line
[set-pixel (Real Real (Instance Color%) -> Boolean)]
I changed that into 
[set-pixel (Real Real (Instance Color%) -> Void)]
Now my code worked perfectly and I'm happy for the time being.

But as I am not really a developer I don't feel too comfortable changing 
program code which should be private to the racket-lang system. So my 
questions are now was it alright to make this change or is there something 
which has to be considered first before making such changes deep in the 
racket-lang system?

Thanks in advance for any suggestions.

-- 
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] Do I need macros to flag unbound identifiers as failing unit tests?

2018-08-12 Thread Sage Gerard
Regarding #lang racket/koans, I opened
https://github.com/zyrolasting/racket-koans/issues/24 and would appreciate
comments from those more familiar with defining syntaxes if there are rough
edges in this design.

On Sun, Aug 12, 2018 at 10:57 AM Sage Gerard  wrote:

> This is great feedback, thank you both so much! I like using a language
> for this approach as the project evolves, and You's feedback is a good
> stopgap that does work, and can be applied in-place.
>
>
> On Sat, Aug 11, 2018 at 1:01 PM Matthew Butterick  wrote:
>
>>
>> On Aug 11, 2018, at 9:00 AM, Sage Gerard  wrote:
>>
>> I'm starting to think writing these kind of exercises in a friendly way
>> is only possible with macros, but before I go that far, is it possible for
>> me to catch a module-level unbound identifier error and print a rackunit
>> failure outright *without *distracting the student?
>>
>> I'd appreciate feedback on the design here too, since I have to pick a
>> direction to handle this kind of problem project-wide.
>>
>>
>> Perhaps consider making a little `racket/koan` language for your
>> exercises that includes some extra conveniences. For instance, one way to
>> address your unbound identifiers is to redefine `#%top` as shown below. But
>> you could move that into `racket/koan`.
>>
>>
>> #lang racket/base
>>
>> (require rackunit)
>>
>> (require (for-syntax racket/base))
>> (define-syntax (#%top stx)
>>   (syntax-case stx ()
>> [(_ . id) (not (identifier-binding #'id)) #'(λ _ (format "unbound
>> identifier: ~a" 'id))]
>> [(_ . id) #'id]))
>>
>> ;; Produce a single struct that passes all assertions.
>> (let ([p "?"])
>>   (check-pred racketeer? p)
>>   (check-pred programmer? p)
>>   (check-pred struct? p)
>>   (check-pred procedure? set-programmer-salary!)
>>   (check-equal? (programmer-confusion-level p) 10)
>>   (check-equal? (racketeer-desire-for-racket-jobs p) 9001))
>>
>

-- 
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: bug#30680: [racket-users] Using Racket's raco on on Guix(SD)

2018-08-12 Thread Christopher Lemmer Webber
Timothy Sample writes:

> Christopher Lemmer Webber  writes:
>
>> Likewise, Gregor and Raart do not install:
>>
>> $ mv ~/.racket ~/.racket-borked
>> $ raco pkg install gregor   # lots of errors during install
>> $ racket
>> racket@> (require gregor)
>> explode-path: contract violation
>>   expected: (or/c path-for-some-system? path-string?)
>>   given: #f
>>   context...:
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/path.rkt:116:0:
>>  do-explode-path
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/path.rkt:126:0:
>>  find-relative-path7
>>/home/cwebber/.racket/6.12/pkgs/tzinfo/tzinfo/private/zoneinfo.rkt:117:2: 
>> for-loop
>>/home/cwebber/.racket/6.12/pkgs/tzinfo/tzinfo/private/zoneinfo.rkt:107:0: 
>> read-tzids
>>/home/cwebber/.racket/6.12/pkgs/tzinfo/tzinfo/private/zoneinfo.rkt:70:0: 
>> make-zoneinfo-source
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/contract/private/arrow-val-first.rkt:388:18
>>/home/cwebber/.racket/6.12/pkgs/tzinfo/tzinfo/main.rkt:63:0: system-tzid
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/contract/private/arrow-val-first.rkt:388:18
>>/home/cwebber/.racket/6.12/pkgs/gregor-lib/gregor/private/moment.rkt: 
>> [running body]
>>/home/cwebber/.racket/6.12/pkgs/gregor-lib/gregor/private/generics.rkt: 
>> [traversing imports]
>>/home/cwebber/.racket/6.12/pkgs/gregor-lib/gregor/private/clock.rkt: 
>> [traversing imports]
>>/home/cwebber/.racket/6.12/pkgs/gregor-lib/gregor/main.rkt: [traversing 
>> imports]
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/misc.rkt:88:7
>
> This is a timezone issue.  The “tzinfo” package cannot find the
> “zoneinfo” directory in GuixSD.  If you install the “tzdata” Racket
> package, things seem to settle down.  (It would be better to tell
> “tzinfo” to use the system database, but that’s harder to do.)

Oh that's true.  I guess this was multiple issues.  Anyway, horray, that
one seems ok now!

>> ... install raart, lots of "cannot open output file" error messages ...
>> racket@> (require raart)
>> get-module-code: no such file: 
>> #
>>   context...:
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/syntax/modcode.rkt:120:0:
>>  get-module-path54
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/syntax/modcode.rkt:225:0:
>>  get-module-code82
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/more-scheme.rkt:261:28
>>standard-module-name-resolver
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/more-scheme.rkt:261:28
>>standard-module-name-resolver
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/more-scheme.rkt:261:28
>>standard-module-name-resolver
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/require-transform.rkt:266:2:
>>  expand-import
>>parse-reprov-spec1
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/syntax/wrap-modbeg.rkt:46:4
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/more-scheme.rkt:261:28
>>standard-module-name-resolver
>>
>> /gnu/store/jx0bkmaafb8fq0mqs5ywgnxq8rbpn8j1-racket-6.12/share/racket/collects/racket/private/misc.rkt:88:7
>
> I got better results with “raart” when “gcc-toolchain” was available
> (i.e., “guix environment --ad-hoc gcc-toolchain”).  I guess it has to
> compile a bit of native code, so it needs a compiler.  It still brakes
> due to a syntax error, but I get the same error on Debian, so I guess
> that’s something.  :)

Yep... that seems to have fixed the install of that issue.

> Also, I checked all of this from Racket without grafts, and it never
> complained about compiling OpenSSL stuff.  Running “raco setup” gives
> some other errors, though.

You're right... without grafts it doesn't have the openssl error.  The
other writing to the store issues still seem to persist, but it doesn't
block running "raco setup" (after a "raco pkg install", a step I had
omitted earlier).

ISTM that this is a separate bug.  In fact I'm afraid I've polluted this
bug with what I thought were all the same bug but turned out to be
several different bugs, of which a couple are fixed now thanks to your
help.

PS: About the bounty, my thoughts are that some of these smaller issues
being resolved are already worth a smaller amount of compensation (and
thanks!), but there are *two different* larger issues of which probably
either is worth the full amount (though I can only afford to pay for
one)... one of them is the issue of the grafts breaking eg openssl
(which may

Re: [racket-users] Do I need macros to flag unbound identifiers as failing unit tests?

2018-08-12 Thread Sage Gerard
This is great feedback, thank you both so much! I like using a language for
this approach as the project evolves, and You's feedback is a good stopgap
that does work, and can be applied in-place.


On Sat, Aug 11, 2018 at 1:01 PM Matthew Butterick  wrote:

>
> On Aug 11, 2018, at 9:00 AM, Sage Gerard  wrote:
>
> I'm starting to think writing these kind of exercises in a friendly way is
> only possible with macros, but before I go that far, is it possible for me
> to catch a module-level unbound identifier error and print a rackunit
> failure outright *without *distracting the student?
>
> I'd appreciate feedback on the design here too, since I have to pick a
> direction to handle this kind of problem project-wide.
>
>
> Perhaps consider making a little `racket/koan` language for your exercises
> that includes some extra conveniences. For instance, one way to address
> your unbound identifiers is to redefine `#%top` as shown below. But you
> could move that into `racket/koan`.
>
>
> #lang racket/base
>
> (require rackunit)
>
> (require (for-syntax racket/base))
> (define-syntax (#%top stx)
>   (syntax-case stx ()
> [(_ . id) (not (identifier-binding #'id)) #'(λ _ (format "unbound
> identifier: ~a" 'id))]
> [(_ . id) #'id]))
>
> ;; Produce a single struct that passes all assertions.
> (let ([p "?"])
>   (check-pred racketeer? p)
>   (check-pred programmer? p)
>   (check-pred struct? p)
>   (check-pred procedure? set-programmer-salary!)
>   (check-equal? (programmer-confusion-level p) 10)
>   (check-equal? (racketeer-desire-for-racket-jobs p) 9001))
>

-- 
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] Bitmaps and Canvas sizes

2018-08-12 Thread silverfire675
That works perfectly,  thanks David!

(define (resize-draw canvas0 bm)
  (let* ((dc (send canvas0 get-dc))
 (t (send dc get-transformation)))
(send dc scale
  (/ (send canvas0 get-width) (send bm get-width))
  (/ (send canvas0 get-height) (send bm get-height)))
(send dc draw-bitmap bm 0 0)
(send dc set-transformation t)))



On Saturday, August 11, 2018 at 10:36:16 PM UTC-4, david.vanderson wrote:
>
> Usually you adjust the drawing context's scale.  Something like 
> (untested): 
>
> (define bm (read-bitmap ...)) 
> (define dc (send image-box get-dc)) 
> (define t (send dc get-transformation))  ; save old scale 
> (send dc scale 
>   (/ (send image-box get-width) (send bm get-width)) 
>   (/ (send image-box get-height) (send bm get-height))) 
> (send dc draw-bitmap bm 0 0) 
> (send dc set-transformation t)  ; restore old scale 
>
> If you want to create a new bitmap with the exact size you want, then 
> you create a new bitmap and use the same strategy: 
> (define new-bm (make-bitmap w h)) 
> (define dc (send new-bm get-dc)) 
> ; same as above 
>
> Does that help? 
> Dave 
>
> On Sat, Aug 11, 2018 at 9:48 PM,  > 
> wrote: 
> > (define image-box 
> >   (new canvas% [parent frame] 
> >[min-width 300] 
> >[min-height 300])) 
> > 
> > I'm still trying to figure out how the racket/gui library works but I'm 
> > having some difficulty understanding how to have an image fill a canvas. 
> > 
> > I'd like for instance to have a canvas in my gui that is 300x300 and 
> have 
> > any image I load resized to fit those dimensions. 
> > 
> > (send (send image-box get-dc) 
> >   draw-bitmap 
> >   (read-bitmap (string->path (send list-box 
> get-string 
> > select))) 
> >   0 0)) 
> > 
> > Here I have some quickly thrown together code for selecting a list of 
> > pathnames to images from a list-box.  The images are all different sizes 
> and 
> > usually end up exceeding the canvas size. 
> > 
> > I've looked around the documentation, especially in the racket/draw 
> module 
> > but I can't find anything beyond a "scale" which doesn't really seem all 
> > that helpful.  If anyone knows how to change images to certain sizes 
> that'd 
> > be helpful.  I tried looking at racket/pict too but that doesn't seem to 
> > have anyway to absolutely set a image's dimensions. 
> > 
> > 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...@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] Searching for packages

2018-08-12 Thread Stefan Schmiedl
"Andrew J" , 12.08.2018, 02:09:

> I typically use either threading or composition...

> (require threading)
> (define (foo x)
>   (~> x 
> f g h bar))

"threading" is not included in the default racket installer, so
how do I get it?

The package manager tells me that there is a "threading" package,
but I'm not sure if it is the correct one.

Browsing over to https://pkgs.racket-lang.org and searching for
"threading" offers me a few more options, the three "threading"
packages amongst them. But now there is a link to "Documentation"
(yay, well-written documentation) and I see that the "threading"
package indeed provides the threding macro quoted above.


Wouldn't it be nice to have a link to https://pkgs.racket-lang.org 
in the "Related Web Sites" submenu of DrRacket's "Help" menu?

Reasons:
1. I started looking there instead of under File, Package Manager,
   and expected to find the "official" package site listed there.
2. The web site allows me to browse the documentation before
   installing anything, which I can't do from the PM window

Regards,
s.

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