Re: [racket-users] Unable to utilize parse-command-line to build command line application

2016-10-11 Thread Ben Greenman
Indirect answer: could you use `command-line` instead?

#lang racket/base
(require racket/cmdline)

(define input-from (make-parameter #f))

(command-line
  #:program "sample"
  #:once-each
  [("-i" "--input-file")
   i
   "Use  as the input file."
   (input-from i)]
  #:args (file)
  (printf "my argument is: ~a\n" file)
  ;; do things with `file` and `input-from` here
)

On Tue, Oct 11, 2016 at 9:24 PM, Ian Thomas  wrote:

> I'm trying to add a simple command line interface to a program and receive
> the following error:
>
> parse-command-line: expected argument of type  flag-list/procedure pairs (spec-line help list strings must match procedure
> arguments)>; given: '((once-each (("-i" "--input\
> -file") # ("Use  as the
> input file."
>   context...:
>
> The command should take a single flag and an input file as arguments. Code
> below. Any help would be much appreciated.
>
> #lang racket
>
> (require racket/base
>  racket/cmdline)
>
> (parse-command-line "com_line"
> ;; argv
> (current-command-line-arguments)
> ;; table
> `((once-each
>[("-i" "--input-file")
> ,(lambda (flag in) (displayln "Using "))
> ("Use  as the input file.")]))
> ;; finish-proc
> (lambda (flag-accum file) file)
> ;; help-proc
> (lambda () (displayln "com_line -i | --input-file
> input file"))
> ;; unknown-proc
> (lambda (unknown_flag) (displayln "Unknown flag:
> ")))
>
> --
> You received this message because you are 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] Unable to utilize parse-command-line to build command line application

2016-10-11 Thread Ian Thomas
I'm trying to add a simple command line interface to a program and receive the 
following error:

parse-command-line: expected argument of type ; given: '((once-each (("-i" "--input\
-file") # ("Use  as the input 
file."  

  context...: 

The command should take a single flag and an input file as arguments. Code 
below. Any help would be much appreciated.

#lang racket

(require racket/base
 racket/cmdline)

(parse-command-line "com_line"
;; argv 

   
(current-command-line-arguments)
;; table

   
`((once-each
   [("-i" "--input-file")
,(lambda (flag in) (displayln "Using "))
("Use  as the input file.")]))
;; finish-proc  

   
(lambda (flag-accum file) file)
;; help-proc

   
(lambda () (displayln "com_line -i | --input-file input 
file"))
;; unknown-proc 

   
(lambda (unknown_flag) (displayln "Unknown flag: 
")))

-- 
You received this message because you are 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] When to use functions vs macros

2016-10-11 Thread David Storrs
On Tue, Oct 11, 2016 at 2:16 PM, Philip McGrath 
wrote:

> This doesn't address functions vs macros, but have you considered
> call-with-transaction
> 
> ?
>

*headdesk*

Yes, I have absolutely considered that.  In no way did I read through the
docs, note that function, think "oh, that's handy", and then promptly
forget its existence.  I chose not to use it because...reasons?


>
> On Tue, Oct 11, 2016 at 1:10 PM Greg Hendershott <
> greghendersh...@gmail.com> wrote:
>
>> 1. "Both" is sometimes a good answer: Write the function. Then maybe
>> write a macro to do only what only a macro can do -- here, the
>> "de-lambda" sugar, and just call the function to do the real work.
>>
>
So, basically, the macro just wraps the 'thunk' around whatever statements
are provided and then passes the thunk to the function.  That makes sense,
thanks.


>
>> 2. Maybe `with-handlers` would work better?
>>
>>
Work better to pass state between body and after-function?  Or work better
than dynamic-wind?  I thought the advantage of dynamic-wind is that you can
guarantee the after-function will be called regardless of use of
continuations or anything else?


> --
>> You received this message because you are 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] When to use functions vs macros

2016-10-11 Thread Philip McGrath
This doesn't address functions vs macros, but have you considered
call-with-transaction

?

On Tue, Oct 11, 2016 at 1:10 PM Greg Hendershott 
wrote:

> 1. "Both" is sometimes a good answer: Write the function. Then maybe
> write a macro to do only what only a macro can do -- here, the
> "de-lambda" sugar, and just call the function to do the real work.
>
> 2. Maybe `with-handlers` would work better?
>
> --
> You received this message because you are 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] When to use functions vs macros

2016-10-11 Thread Greg Hendershott
1. "Both" is sometimes a good answer: Write the function. Then maybe
write a macro to do only what only a macro can do -- here, the
"de-lambda" sugar, and just call the function to do the real work.

2. Maybe `with-handlers` would work better?

-- 
You received this message because you are 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] FUSE filesystem package

2016-10-11 Thread Scott Moore
Hi all,

I'm announcing a new package: fuse (
https://github.com/thinkmoore/racket-fuse).

fuse is a racket library for implementing filesystems in userspace using
the FUSE API available on many *nix platforms and OS X (currently, I've
only tested using recent releases of FUSE on Linux).

People have used FUSE to implement a wide variety of neat stuff, like
distributed filesystems, providing a filesystem API for accessing a music
library by various search criteria, or mounting gmail as a storage system.
Now you can write your own filesystem in Racket!

The package implements communication routines for interfacing with the FUSE
kernel driver. Client programs can implement a userspace filesystem by
providing a collection of functions that implement filesystem
operations. Currently,
the package depends on the libfuse C library to mount a FUSE filesystem.
However, the communication protocol with the kernel and filesystem API does
not reuse libfuse functionality, and this dependency will be removed in a
future release.

The FUSE API is huge and I've only done very limited testing, so there are
likely bugs. If you encounter some, please file an issue!

Cheers,
Scott

-- 
You received this message because you are 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] Handin Issues

2016-10-11 Thread mattsap
On Tuesday, October 11, 2016 at 12:42:44 PM UTC-4, Eli Barzilay wrote:
> On Tue, Oct 11, 2016 at 9:35 AM,   wrote:
> > Thanks for your detailed response!
Thanks! If I get any progress, I'll try to update later.

> >
> > I do have the following additions at the top of the file:
> > (add-header-line! (get-submission-timestamp))
> > (add-report-line! (get-submission-timestamp))
> >
> > So would this mean there isn't an issue with back-end but rather my
> > checker.rkt file?
> 
> Yeah: you cannot add header lines when the submissions are not converted
> to text, because there's no functionality to modify the rich media file.
> But it would be better if the checker would complain about an invalid
> configuration instead of failing when the text file is not there --
> which is the change that I suggested.  This way you'd get a readable
> error message telling you what's wrong instead of tracking the problem
> youself.
> 
> 
> > Would it be possible to link some example handin servers on a
> > github/bitbucket/or even the racket website (particularly a
> > checker.rkt file)?  I think my main issue is there are alot of
> > configurations that require particular details and I may miss some
> > important documentation. I could help contribute a checker.rkt for my
> > purposes after I get it fully working... [...]
> 
> (Unfortunately, most of your *real* issues are more high level problems
> with how to handle submissions with images, how to test them, etc -- and
> that's something that personally I have no experience with...)
> 
> -- 
>((x=>x(x))(x=>x(x)))  Eli Barzilay:
>http://barzilay.org/  Maze is Life!

-- 
You received this message because you are 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] Handin Issues

2016-10-11 Thread Eli Barzilay
On Tue, Oct 11, 2016 at 9:35 AM,   wrote:
> Thanks for your detailed response!
>
> I do have the following additions at the top of the file:
> (add-header-line! (get-submission-timestamp))
> (add-report-line! (get-submission-timestamp))
>
> So would this mean there isn't an issue with back-end but rather my
> checker.rkt file?

Yeah: you cannot add header lines when the submissions are not converted
to text, because there's no functionality to modify the rich media file.
But it would be better if the checker would complain about an invalid
configuration instead of failing when the text file is not there --
which is the change that I suggested.  This way you'd get a readable
error message telling you what's wrong instead of tracking the problem
youself.


> Would it be possible to link some example handin servers on a
> github/bitbucket/or even the racket website (particularly a
> checker.rkt file)?  I think my main issue is there are alot of
> configurations that require particular details and I may miss some
> important documentation. I could help contribute a checker.rkt for my
> purposes after I get it fully working... [...]

(Unfortunately, most of your *real* issues are more high level problems
with how to handle submissions with images, how to test them, etc -- and
that's something that personally I have no experience with...)

-- 
   ((x=>x(x))(x=>x(x)))  Eli Barzilay:
   http://barzilay.org/  Maze is Life!

-- 
You received this message because you are 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] [off-topic] any thoughts on gradescope?

2016-10-11 Thread Eli Barzilay
On Tue, Oct 11, 2016 at 9:06 AM, Jay McCarthy  wrote:
> It looks neat. I've done similar things to Eli many times as well.
>
> https://github.com/jeapostrophe/grade-ninja -- Had the whole "give a
> free-form comment" or click a button to give the same feedback again

Yeah, I do have a GUI-kind-of thing too, hacked in Emacs...  The idea is
that I choose from a number of pre-made comment+grade entries, and it's
easy to switch them as I go from one question to the next.


> https://github.com/jeapostrophe/grade-samurai --- Expanded that with a
> Web UI for students and gave more explicit rubrics plus a self-grading
> step followed by a professor review
>
> Now I'm going to make a new one similar to the previous two where the
> students host their work on their own Git repos.

My main problem is getting a text file with the comments embedded in,
following a specific format.  If you get something generic enough it
would be cute.

But the main thing is that just doing the grading electronically is
pushing things in the right direction...

-- 
   ((x=>x(x))(x=>x(x)))  Eli Barzilay:
   http://barzilay.org/  Maze is Life!

-- 
You received this message because you are 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] When to use functions vs macros

2016-10-11 Thread David Storrs
The general question is "when should I prefer functions versus macros?" but
a specific example would be this:

I'm doing some database programming and I wanted a thing that would handle
transactions for me.  Doing it as a function would look something like this:

(define (in-transaction dbh body)
  (define success #f)
  (dynamic-wind
 (thunk (query-exec dbh "BEGIN TRANSACTION"))
 (thunk
 (let ((result (body)))
(set! success #t) ;; we didn't throw, so we succeeded
result))
 (thunk (query-exec dbh (if success "END TRANSACTION" "ROLLBACK")

And then I could call it like so:

(in-transaction (thunk (query-exec dbh "...sql goes here...")))

Doing it as a macro would eliminate the need for the 'thunk' when calling
it, but writing macros is a bit more complicated than writing functions and
arguably harder for debugging.  How would you all handle this if you were
writing it?

Secondarily, is there a better way to pass success/fail state between the
body and the post thunk in a dynamic-wind?

-- 
You received this message because you are 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] Handin Issues

2016-10-11 Thread mattsap
Thanks for your detailed response!

I do have the following additions at the top of the file:
(add-header-line! (get-submission-timestamp))
(add-report-line! (get-submission-timestamp))

So would this mean there isn't an issue with back-end but rather my checker.rkt 
file?

Would it be possible to link some example handin servers on a 
github/bitbucket/or even the racket website (particularly a checker.rkt file)?  
I think my main issue is there are alot of configurations that require 
particular details and I may miss some important documentation. I could help 
contribute a checker.rkt for my purposes after I get it fully working...

Particularly, after getting the server up and running, I'm having issues with 
comparing students that submit functions that return images. Primarily, I've 
ran a test such as the following that fails:

(@test "pinwheel case 1"
  "Incorrect pinwheel function"
   (above  (rectangle 10 30 "solid" "blue") (rectangle 10 30 "solid" 
"blue"))
   (above  (rectangle 10 30 "solid" "blue") (rectangle 10 30 "solid" 
"blue"))
 1)

A brilliant Professor suggested that instead of comparing the images, I should 
convert the images to a list of colors and compare those. Is there a better 
solution to this? I think if there were more examples, this is one of the 
things that would help make this setting up handin much easier.

Thanks for your help! I really appreciate this!






On Tuesday, October 11, 2016 at 1:45:26 AM UTC-4, Eli Barzilay wrote:
> On Thu, Oct 6, 2016 at 10:08 AM,   wrote:
> > So, I've been playing around with the handin server these days.
> >
> > My purposes of the handin require students to submit images using the
> > htdp image and universe libraries.
> >
> > First, I would like to note that for the images, you must turn off
> > textualization/create-text in your checker:
> >
> > (check:
> >; Get timestamp of the submission and add it to header and report
> 
> ([*] Is there some code that does the addition described here?)
> 
> 
> >:language 'racket
> >:requires '(bsl-plus-image)
> >:create-text? #f
> >:textualize? #f
> >
> > My issues follow:
> >
> > 1) Initially, there is a conflict with one of the image functions and
> >[...])
> 
> (I don't know about these issues...)
> 
> 
> > 2) Afterwards, there is a permission denied error:
> > [2|2016-10-06T09:49:28] ERROR: Error in your code --
> > [2|2016-10-06T09:49:28] file-exists?: `exists' access denied for 
> > libobj.dylib
> > [...]
> > As of now, I expose my path. I'm not sure how to create a better
> > solution than the one mentioned stating to add the following lines at
> > the top of your checker.rkt
> 
> The "/" in the additional setting is a path, and the `read` allows
> reading any file under that path.  So instead of "/", just use a path
> that includes only stuff that should be OK to read, including the
> "libobj.dylib" file.  (I don't use OSX so I don't know where it is.)
> 
> 
> > 3) Finally, I found a very serious issue in the collection's handin
> >server code. students are not able to submit because of the server
> >was trying to write to a grading/text.rkt even though I specified
> >not to! I've traced the issue to the collection's handin server.
> >
> > From (collection-path "handin-server"),
> >
> > /Library/Racket/6.6/pkgs/handin/handin-server/checker.rkt:
> >
> > Starting around line 467 the below code is the culprit!
> > Essentially, at the bottom of the below segment, regardless if you
> > checked if you were creating a text file in your checker.rkt, it will
> > attempt to write the text with the below code:
> >  (when (thread-cell-ref added-lines) (write-text))
> >
> > Essentially, to fix this issue, you may replace it with
> >  (when (and (thread-cell-ref added-lines) create-text?) (write-text))
> 
> That does look like a bug, but I think that a proper solution would make
> `add-header-line!` throw an error if there is no textualization
> happenning, except that getting the textualization flag there might be
> tricky, so a bit hackier solution is to make the code that you're
> talking about throw an error, so instead of
> 
> (when (thread-cell-ref added-lines) (write-text))
> 
> it would be something like (untested):
> 
> (when (thread-cell-ref added-lines)
>   (unless create-text?
> (error* "bad checker: no text created, but header lines added"))
>   (write-text))
> 
> This is better than what you're suggesting, which would silently ignore
> the added lines.
> 
> If you do have some code that adds header lines (my [*] question at the
> top) then that's the problem, and the error should be a configuration
> error.  (The thing is that additional headers are written to a generated
> text file -- there's no code that edits the student's media-format
> submission file.)
> 
> -- 
>((x=>x(x))(x=>x(x)))  Eli Barzilay:
>http://barzilay.org/

Re: [racket-users] [off-topic] any thoughts on gradescope?

2016-10-11 Thread Jay McCarthy
It looks neat. I've done similar things to Eli many times as well.

https://github.com/jeapostrophe/grade-ninja -- Had the whole "give a
free-form comment" or click a button to give the same feedback again

https://github.com/jeapostrophe/grade-samurai --- Expanded that with a Web
UI for students and gave more explicit rubrics plus a self-grading step
followed by a professor review

Now I'm going to make a new one similar to the previous two where the
students host their work on their own Git repos.

Jay

On Tue, Oct 11, 2016 at 2:11 AM, Eli Barzilay  wrote:

> On Mon, Oct 10, 2016 at 11:14 PM, 'John Clements' via Racket Users
>  wrote:
> > Sorry, this is totally off-topic; this is the second time I’ve heard
> > of gradescope.com, and it looks like it might actually be
> > useful/interesting. It might also be a sleazy scam site that I wind up
> > hating. Most of the educators whose opinions I respect most are going
> > to get this message; do any of you have opinions on gradescope?
>
> Sorry but this is a bit more off-topic...  I haven't used this thing,
> but it makes a lot of sense to use something similar -- which I've been
> doing manually for ever: the idea is to have a fixed format for comments
> that include grades (or grade penalties), and that makes it natural to
> keep a file in a separate window with some pre-made comments and their
> grade (or penalty), and after a short while you have such comments for
> most cases.  The missing feature is being able to update a number and
> have it reflect in all files, but if the format is fixed and comments
> are copy-pasted, then it's easy enough to change grades with a quick
> grep.  It makes sense enough that many of my graders quickly pick it up.
>
> So it makes sense to me to automate this, but I wonder if they have a
> good way to do that with consuming text files, adding comments, then
> getting the graded versions without sending students to a different
> site.  Also, in many cases I'll adjust penalties based on the number of
> other problems you have in the same question.
>
> --
>((x=>x(x))(x=>x(x)))  Eli Barzilay:
>http://barzilay.org/  Maze is Life!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 64:33

-- 
You received this message because you are 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-mode: OK to require Racket 6.0+?

2016-10-11 Thread Konrad Hinsen

On 10/10/16 21:42, Tim Jervis wrote:

Here here!


+1



Tim Jervis
+44 7801 337 078


On 10 Oct 2016, at 19:56, Dmitry Igrishin  wrote:

Hi Greg,

Yes, please! Racket mode for Emacs is great. Thank you for you 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [off-topic] any thoughts on gradescope?

2016-10-11 Thread Eli Barzilay
On Mon, Oct 10, 2016 at 11:14 PM, 'John Clements' via Racket Users
 wrote:
> Sorry, this is totally off-topic; this is the second time I’ve heard
> of gradescope.com, and it looks like it might actually be
> useful/interesting. It might also be a sleazy scam site that I wind up
> hating. Most of the educators whose opinions I respect most are going
> to get this message; do any of you have opinions on gradescope?

Sorry but this is a bit more off-topic...  I haven't used this thing,
but it makes a lot of sense to use something similar -- which I've been
doing manually for ever: the idea is to have a fixed format for comments
that include grades (or grade penalties), and that makes it natural to
keep a file in a separate window with some pre-made comments and their
grade (or penalty), and after a short while you have such comments for
most cases.  The missing feature is being able to update a number and
have it reflect in all files, but if the format is fixed and comments
are copy-pasted, then it's easy enough to change grades with a quick
grep.  It makes sense enough that many of my graders quickly pick it up.

So it makes sense to me to automate this, but I wonder if they have a
good way to do that with consuming text files, adding comments, then
getting the graded versions without sending students to a different
site.  Also, in many cases I'll adjust penalties based on the number of
other problems you have in the same question.

-- 
   ((x=>x(x))(x=>x(x)))  Eli Barzilay:
   http://barzilay.org/  Maze is Life!

-- 
You received this message because you are 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.