Re: [racket-users] Implementation of threading macros

2018-03-31 Thread Alex Knauth
The `~>` form provided by the `threading` package is a macro, and it treats 
parentheses differently than a normal function would.

What you are looking for is probably the ~> *function*, provided by the 
`point-free` package. That has simpler behavior, doing what you expect with 
lambdas, curried functions, and other function expressions:

#lang racket
(require point-free)

(define (add2 x) (+ x 2))
(~> 1 add2) ; ok
(~> 1 (lambda (x) (+ x 2))) ; ok
(~> 1 (curry + 2))  ; ok

(define adder%
  (class object%
(super-new)
(init-field x)
(define/public (incr) (lambda (y) (+ x y)

(define adder (new adder% [x 2]))
(send adder incr); ok
(~> 1 (send adder incr)) ; ok


> On Mar 31, 2018, at 9:24 PM, 若草春男  wrote:
> 
> Hi, everyone.
> 
> I think that racket threading macros can mix with expressions(lambda, curry, 
> class, ...), but not in fact.
> 
> #lang racket
> (require threading)
> 
> (define (add2 x) (+ x 2))
> (~> 1 add2) ; ok
> (~> 1 (lambda (x) (+ x 2))) ; ng
> (~> 1 (curry + 2)) ; ng
> 
> (define adder%
>   (class object%
> (super-new)
> (init-field x)
> (define/public (incr) (lambda (y) (+ x y)
> 
> (define adder (new adder% [x 2]))
> (send adder incr) ; ok
> (~> 1 (send adder incr)) ; ng
> 
> Thanks,
> Haruo

-- 
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: Understanding 'curry'

2018-03-31 Thread 若草春男
Curry is from functional languages(Haskell, OCaml, F#, ...).
Curry is the one of abbreviation of labmda.

But, curry is NOT usable for racket's threading macros.

#lang racket
(require threading)
(require 2htdp/image)

(~> (star-polygon 20 20 3 "solid" "navy")
(overlay/align/offset "right" "bottom"
  (circle 30 "solid" "cornflowerblue")
  -10 -10 _)
(overlay/align/offset "right" "top"
  (circle 30 "solid" "orchid")
  0 10 _)
(overlay/align/offset "left" "bottom"
  (circle 30 "solid" "khaki")
  10 0 _)
(overlay/align/offset "left" "top"
  (circle 30 "solid" "green yellow")
  0 0 _))

-- 
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: Implementation of threading macros

2018-03-31 Thread 若草春男
I want to be close this issue but I cannot close by my response. Please 
post any message.

-- 
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: Implementation of threading macros

2018-03-31 Thread 若草春男
I see. I understand that racket's threading macros are NOT SIMPLE 
IMPLEMENTATIONS.
Racket's threading macros can reduce lambda object creations.

#lang racket
(require threading)

(define (add2 x) (+ x 2))
(~> 1 add2) ; ok
(~> 1 ((lambda (x) (+ x 2)) _)) ; ng -> ok
(~> 1 ((curry + 2) _)) ; ng -> ok

(define adder%
  (class object%
(super-new)
(init-field x)
(define/public (incr) (lambda (y) (+ x y)

(define adder (new adder% [x 2]))
(send adder incr) ; ok
(~> 1 ((send adder incr) _)) ; ng -> ok

-- 
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] Implementation of threading macros

2018-03-31 Thread 若草春男
Hi, everyone.

I think that racket threading macros can mix with expressions(lambda, 
curry, class, ...), but not in fact.

#lang racket
(require threading)

(define (add2 x) (+ x 2))
(~> 1 add2) ; ok
(~> 1 (lambda (x) (+ x 2))) ; ng
(~> 1 (curry + 2)) ; ng

(define adder%
  (class object%
(super-new)
(init-field x)
(define/public (incr) (lambda (y) (+ x y)

(define adder (new adder% [x 2]))
(send adder incr) ; ok
(~> 1 (send adder incr)) ; ng

Thanks,
Haruo

-- 
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: Understanding 'curry'

2018-03-31 Thread 若草春男
I'm sorry for my mistake.

[Wrong] Thread Macro
[Right] Threading Macro

Threading macros are provided by Racket Package System
and its documentation is included in Racket Document.

-- 
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: Understanding 'curry'

2018-03-31 Thread 若草春男
It's very very easy. The "curry" is from functional languages(Haskell, 
OCaml, F#, ...).

The concept of curry is powerful when the following function form:
(function-name option-argument input-argument)

For example, we think about 2htdp/image.

#lang racket
(require 2htdp/image)

(overlay/align/offset
  "left" "top"
  (circle 30 "solid" "green yellow")
  0 0
  (overlay/align/offset
"left" "bottom"
(circle 30 "solid" "khaki")
10 0
(overlay/align/offset
  "right" "top"
  (circle 30 "solid" "orchid")
  0 10
  (overlay/align/offset
"right" "bottom"
(circle 30 "solid" "cornflowerblue")
-10 -10
(star-polygon 20 20 3 "solid" "navy")

In Lisp Programming, it prefer to indent radically. Therefore, we introduce 
the "thread macro".

; thread macro (function)
(define (~> init . procs)
  (foldl (lambda (proc arg) (proc arg))
 init
 procs))

(~> (star-polygon 20 20 3 "solid" "navy")
(lambda (image)
  (overlay/align/offset "right" "bottom"
(circle 30 "solid" "cornflowerblue")
-10 -10
image))
(lambda (image)
  (overlay/align/offset "right" "top"
(circle 30 "solid" "orchid")
0 10
image))
(lambda (image)
  (overlay/align/offset "left" "bottom"
(circle 30 "solid" "khaki")
10 0
image))
(lambda (image)
  (overlay/align/offset "left" "top"
(circle 30 "solid" "green yellow")
0 0
image)))

For more simple discription, we use curry instead of lambda.

(~> (star-polygon 20 20 3 "solid" "navy")
(curry overlay/align/offset "right" "bottom"
(circle 30 "solid" "cornflowerblue")
-10 -10)
(curry overlay/align/offset "right" "top"
(circle 30 "solid" "orchid")
0 10)
(curry overlay/align/offset "left" "bottom"
(circle 30 "solid" "khaki")
10 0)
(curry overlay/align/offset "left" "top"
(circle 30 "solid" "green yellow")
0 0))

Thanks,
Haruo

-- 
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] Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread Matthew Flatt
At Sat, 31 Mar 2018 06:45:29 -0400, Philip McGrath wrote:
> My current approach is to put a file containing "/Applications/Racket
> v6.12/bin" in /etc/paths.d, which adds it to the default PATH for all users.

I recommend that approach, because it's simple, reliable, and easy to
adjust when you're ready to switch to a new version. Note that you
don't have to perform any quoting in the content of the file in
"/etc/paths.d".

We've experimented with an installer package that creates
"/etc/paths.d/racket" as it installs Racket into "/Applications/Racket
vX". But since the installer's only benefit is creating "/etc/paths.d",
and since the installer takes away a user's ability to choose where
Racket is installed, we've never switched the main distribution to that
mode.

FWIW, Racket used to be called "PLT Scheme", with a space in its name
--- so there was no question back then whether the folder in
"Applications" should have a space in its name when following Mac
conventions. And we kept following the numbering style for "Racket"
folders, because it still looks right to have a space.

-- 
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] bookmarks?

2018-03-31 Thread Geoffrey Knauth
Thank you Laurent, I'll definitely check it out!  --Geoff

On Saturday, March 31, 2018 at 8:19:45 AM UTC-4, Laurent Orseau wrote:
>
> The quickscript-extra package (a DrRacket plugin) provides such a facility 
> (the 'bookmarks' script), among many other things:
> https://pkgs.racket-lang.org/package/quickscript-extra
>
> It's not perfect but should still be helpful. In case it doesn't suit you 
> needs, quickscript should allow you to easily write and test what you want.
>
> Any feedback is more than welcome of course.
>
> On Sat, Mar 31, 2018 at 11:31 AM, Geoffrey Knauth  > wrote:
>
>> This happens to me enough in DrRacket I thought I should ask.  I'm 
>> looking at some code.  I want to scroll around or search in the file for 
>> something to check, but later I want to come back to where I was.  In Emacs 
>> I'd set a mark and jump back to it.  Was the subject of bookmarks ever 
>> considered for DrRacket?
>>
>> -- 
>> 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: Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread Geoffrey Knauth
Very interesting, good to know when I'm writing my own scripts, vs. using 
things others have written.  Thanks.

On Saturday, March 31, 2018 at 6:58:04 AM UTC-4, HiPhish wrote:
>
> BTW, on the topic of writing robust shell scripts, I always have a linter 
> run over my scripts when I save them. I run Shellcheck automatically in 
> Neovim using the Neomake plugin. The linter catches among other things 
> missing quotations.
>
> https://www.shellcheck.net/
> https://github.com/neomake/neomake/
>
> You can run Shellcheck manually over the CLI if you cannot set up your 
> editor to do it automatically.
>

-- 
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: Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread Geoffrey Knauth
I understand the argument that strengthening our own CLI and shell-script 
practice to guard against spaces in filenames is both learned and good 
defense, as in, "don't go into battle without some armor protection."  I do 
that when I'm really worried, and if you want to see how big shell scripts 
can get dealing with this, just look at the lengths to which many GNU 
scripts go to work safely in the jungle of filesystems and user preferences.

What I've found though, unless I'm actually using those greatly fortified 
GNU scripts and tools, is that sometimes ordinary pipelines on the CLI can 
get tripped up by spaces.  So my approach has been to disarm the shooter, 
take the gun way, i.e., remove the space and replace it with a hyphen.

I apologize, my beloved Racket, I don't mean to suggest in any way that you 
are a shooter, you most certainly are not, you are most benevolent, even as 
you are powerful.  I'm only talking about the space.

-- 
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] bookmarks?

2018-03-31 Thread Laurent
The quickscript-extra package (a DrRacket plugin) provides such a facility
(the 'bookmarks' script), among many other things:
https://pkgs.racket-lang.org/package/quickscript-extra

It's not perfect but should still be helpful. In case it doesn't suit you
needs, quickscript should allow you to easily write and test what you want.

Any feedback is more than welcome of course.

On Sat, Mar 31, 2018 at 11:31 AM, Geoffrey Knauth  wrote:

> This happens to me enough in DrRacket I thought I should ask.  I'm looking
> at some code.  I want to scroll around or search in the file for something
> to check, but later I want to come back to where I was.  In Emacs I'd set a
> mark and jump back to it.  Was the subject of bookmarks ever considered for
> DrRacket?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[racket-users] Re: Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread HiPhish
BTW, on the topic of writing robust shell scripts, I always have a linter 
run over my scripts when I save them. I run Shellcheck automatically in 
Neovim using the Neomake plugin. The linter catches among other things 
missing quotations.

https://www.shellcheck.net/
https://github.com/neomake/neomake/

You can run Shellcheck manually over the CLI if you cannot set up your 
editor to do it automatically.

-- 
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] Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread Philip McGrath
My current approach is to put a file containing "/Applications/Racket
v6.12/bin" in /etc/paths.d, which adds it to the default PATH for all users.

Personally, I'm command-line-oriented enough that I try to avoid spaces and
special characters in file names I'm likely to work with from the command
line, but:

   1. I believe Apple has some guideline encouraging file names to use
   spaces, capital letters, etc. rather than underscores and other workarounds.
   2. If you are writing a shell script, there are so many special
   characters that can cause problems that you really do have to properly
   quote your paths (or write the script in Racket instead, which is happy to
   deal with arbitrary characters in paths).


-Philip

On Sat, Mar 31, 2018 at 6:22 AM, Geoffrey Knauth  wrote:

> Every time I download a new version of Racket, I put it in:
> /Applications/Racket/
> The first thing I do is replace the space in the name with a hyphen.
> On the more comand-liney side of things, I put
> /usr/local/racket/latest/bin in my PATH.
> Currently I have:
>
> $ which racket
> /usr/local/racket/latest/bin/racket
> $ ls -l /usr/local/racket
> lrwxr-xr-x ... Jan 27 09:08 Racket-v6.12@ -> /Applications/Racket/Racket-
> v6.12
> lrwxr-xr-x ... Jan 27 09:08 Racket-v6.12.0.3@ ->
> /Applications/Racket/Racket-v6.12.0.3
> lrwxr-xr-x ... Mar 27 10:58 Racket-v6.90.0.23@ ->
> /Applications/Racket/Racket-v6.90.0.23
> lrwxr-xr-x ... Mar 27 10:55 latest@ -> Racket-v6.90.0.23
>
>
> On Thursday, March 29, 2018 at 4:20:02 PM UTC-4, David K. Storrs wrote:
>>
>> Second the desire for this not to be the case.  Personally, my
>> solution is just to rename the folder after installing it.  I am
>> currently working with binaries from
>> /Applications/Racket_v6.11/bin/...
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[racket-users] bookmarks?

2018-03-31 Thread Geoffrey Knauth
This happens to me enough in DrRacket I thought I should ask.  I'm looking 
at some code.  I want to scroll around or search in the file for something 
to check, but later I want to come back to where I was.  In Emacs I'd set a 
mark and jump back to it.  Was the subject of bookmarks ever considered for 
DrRacket?

-- 
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] Why is there a space in the path to the Racket application on MacOSX?

2018-03-31 Thread Geoffrey Knauth
Every time I download a new version of Racket, I put it in:  
/Applications/Racket/
The first thing I do is replace the space in the name with a hyphen.
On the more comand-liney side of things, I put /usr/local/racket/latest/bin 
in my PATH.
Currently I have:

$ which racket
/usr/local/racket/latest/bin/racket
$ ls -l /usr/local/racket
lrwxr-xr-x ... Jan 27 09:08 Racket-v6.12@ -> 
/Applications/Racket/Racket-v6.12
lrwxr-xr-x ... Jan 27 09:08 Racket-v6.12.0.3@ -> 
/Applications/Racket/Racket-v6.12.0.3
lrwxr-xr-x ... Mar 27 10:58 Racket-v6.90.0.23@ -> 
/Applications/Racket/Racket-v6.90.0.23
lrwxr-xr-x ... Mar 27 10:55 latest@ -> Racket-v6.90.0.23


On Thursday, March 29, 2018 at 4:20:02 PM UTC-4, David K. Storrs wrote:
>
> Second the desire for this not to be the case.  Personally, my 
> solution is just to rename the folder after installing it.  I am 
> currently working with binaries from 
> /Applications/Racket_v6.11/bin/... 
>

-- 
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: (eighth RacketCon) is St. Louis in September 2018

2018-03-31 Thread Geoffrey Knauth
Now that's a powerhouse combination of events!  Last year I skipped Strange 
Loop because I wanted to go to RacketCon more.  (I always learn something 
interesting from every RacketCon talk, and the community is the best.)  Now 
you've given them back my likely attendance and added ICFP.  Thanks for the 
heads-up.

On Wednesday, March 28, 2018 at 8:19:53 PM UTC-4, Jay McCarthy wrote:
>
> Prepare yourselves! 
>
> (eighth RacketCon) is St. Louis in September 2018! 
>
> http://con.racket-lang.org 
>
> co-located with ICFP and Strange Loop! 
>
> -- 
>
> At this point, you can book your hotel room (get them fast!) and let 
> me know what you plan on presenting! 
>
> Jay 
>
> -- 
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=- 
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=- 
> -=[ Moses 1:33: And worlds without number have I created; ]=- 
>

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