Re: [racket-users] Transforming data for plot / discreet-histogram

2016-06-07 Thread Ben Greenman
For now, you can use sequence-map to turn the hashtable into a sequence of
vectors.

#lang racket

(require math)

(require plot)

(discrete-histogram (sequence-map vector (in-hash (samples->hash '(1 2 3 4
4)


But it would be nicer if discrete-histogram took a hash as input.

On Tue, Jun 7, 2016 at 10:44 AM, Sean Kemplay 
wrote:

> Hello,
>
> Something like the following would be ideal to build a histogram from a
> sequence of values read in via CSV
>
> #lang racket
> (require math)
> (require plot)
>
> (discrete-histogram (samples->hash '(1 2 3 4 4)))
>
> However discreet histogram takes a list of vectors. Is there a way to
> achieve something like the above without managing a list of vectors for
> 500,000+ rows of data?
>
> Reading the docs, I thought discrete-histogram would also take a list of
> lists and that I could do something like (discrete-histogram (hash->list
> (samples->hash '(1 2 3 4 4 but it looks like hash->list returns a list
> of dotted pairs.
>
> Sorry, I dip in and out of Racket so I may be missing something obvious.
> Maybe run through hash-map?
>
> Kind regards,
> Sean
>
> --
> 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] Learning by doing Typed Racket

2016-06-12 Thread Ben Greenman
On Sun, Jun 12, 2016 at 9:53 PM, Daniel Prager 
wrote:

> It seems that math libraries are a sweet-spot for TR. What else?
>
>
The math library has to deal with all the same growing pains (inst, assert).
I think part of the reason it looks so good is that it sparked improvements
in TR along the way.

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


Re: [racket-users] Learning by doing Typed Racket

2016-06-12 Thread Ben Greenman
Yeah I agree `inst` needs more documentation.
And as someone (Matthew B.?) suggested before, we could really use a
systematic way of documenting the type variables on each polymorphic
function.


On Sun, Jun 12, 2016 at 5:23 PM, Daniel Prager <daniel.a.pra...@gmail.com>
wrote:

> Cc:ing the list ...
>
> On Sun, Jun 12, 2016 at 4:56 PM, Ben Greenman <benjaminlgreen...@gmail.com
> > wrote:
>
>> Yep, use `inst` to instantiate the polymorphic variables to sort.
>>
>> #lang typed/racket
>>
>> ((inst sort (List Symbol Integer) Integer)
>>  '((a 45) (b 13) (c 12) (d 16) (e 9) (f 5)) < #:key second)
>>
>>
>> [[ I usually start with `(inst f)` and use the error message to figure
>> out what types / how many `f` needs. ]]
>>
>
> Thanks Ben, this is very helpful.
>
> I had read about inst in the Racket Reference, but the penny hadn't
> dropped. Perhaps expanding the worked example (or adding a section to The
> TR Guide) would be helpful to novices.
>
> For example:
>
> > (foldl cons null (list 1 2 3 4))
>
> Type Checker: Polymorphic function `foldl' could not be applied to
> arguments [etc.]
>
> Both foldl and cons are polymorphic: foldl in a b c d, cons in a b.
>
> > foldl
> - : (All (a b c d)
>   (case->
>(-> (-> a b b) b (Listof a) b)
>(-> (-> a b c c) c (Listof a) (Listof b) c)
>(-> (-> a b c d d) d (Listof a) (Listof b) (Listof c) d)))
> #
>
> > cons
> - : (All (a b)
>   (case-> (-> a (Listof a) (Listof a))
>   (-> a b (Pairof a b
> #
>
> The type-checker needs the programmer's help -- either by inst-antiating
> foldl or cons -- to resolve this ambiguity. [Why?]:
>
> > ((inst foldl Integer (Listof Integer) Null Null)
>cons null (list 1 2 3 4))
> - : (Listof Integer)
> '(4 3 2 1)
>
> > (foldl (inst cons Integer Integer) null (list 1 2 3 4))
> - : (Listof Integer)
> '(4 3 2 1)
>
> In this case inst-ing cons is more concise than inst-ing foldl (in which
> the Nulls are placeholders since c & d are ignored), so preferable.
>
> * * *
>
> Also, perhaps discoverability would be improved if the error message
> suggested that an inst could resolve the problem.
>
> Dan
>
>
>> On 6/11/16, Daniel Prager <daniel.a.pra...@gmail.com> wrote:
>> > Next example.
>> >
>> > In Racket:
>> >
>> >> (sort '((a 45) (b 13) (c 12) (d 16) (e 9) (f 5)) < #:key second)
>> >
>> > '((f 5) (e 9) (c 12) (b 13) (d 16) (a 45))
>> >
>> >
>> > In Typed Racket I couldn't get a version using #:key to type-check.
>> Pulling
>> > second into a comparison function works:
>> >
>> >> (sort '((a 45) (b 13) (c 12) (d 16) (e 9) (f 5))
>> >   (λ ([a : (List Symbol Natural)]
>> >   [b : (List Symbol Natural)])
>> > (< (second a) (second b
>> >
>> > Is there a solution using #:key in Typed Racket?
>> >
>> >
>> > Dan
>> >
>> > --
>> > 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.
>> >
>>
>>
>> --
>> @ Northeastern University
>
>

-- 
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] Learning by doing Typed Racket

2016-06-11 Thread Ben Greenman
On Sat, Jun 11, 2016 at 12:46 AM, Daniel Prager 
wrote:

> Do you have an alternative recommendation in mind?


I guess you already solved this one, but for later it might help to avoid
macros.

-- 
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] Learning by doing Typed Racket

2016-06-11 Thread Ben Greenman
Ah, okay. Well maybe try the Haskell or OCaml versions of the 99 problems?

https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems
https://ocaml.org/learn/tutorials/99problems.html


On Sat, Jun 11, 2016 at 3:28 AM, Daniel Prager <daniel.a.pra...@gmail.com>
wrote:

> Hi Ben
>
> I wrote:
>
>> Do you have an alternative recommendation in mind?
>
>
> At that point I was asking whether Sam (or others) recommended another set
> of problems more conducive to learning Typed Racket than the 99 Lisp
> Problems which Sam said were a tricky place to start.
>
> I can see that staying clear of macros avoids an additional layer of
> sophistication.
>
> Dan
>
>
> On Sat, Jun 11, 2016 at 5:13 PM, Ben Greenman <benjaminlgreen...@gmail.com
> > wrote:
>
>>
>> On Sat, Jun 11, 2016 at 12:46 AM, Daniel Prager <
>> daniel.a.pra...@gmail.com> wrote:
>>
>>> Do you have an alternative recommendation in mind?
>>
>>
>> I guess you already solved this one, but for later it might help to avoid
>> macros.
>>
>
>
>
> --
> *Daniel Prager*
> Agile/Lean Coaching, Innovation, and Leadership
> Profile: skillfire.co/dan
> Startups: youpatch.com <http://www.youpatch.com>, skillfire.co
> Twitter: @agilejitsu <https://twitter.com/agilejitsu>
> Blog: agile-jitsu.blogspot.com
> Linkedin: au.linkedin.com/in/danielaprager
>

-- 
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] Proper handling for a custom current-read-interaction?

2016-06-08 Thread Ben Greenman
>
> I believe that ocaml has a special ;; character in the language specially
> for
> handling situations like that.
>

Yep, similar to how Python looks for 2 consecutive newlines to end a block.


(OCaml's ;; is sometimes useful in files, but those cases are very rare.

https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Usingandomittingand
)

-- 
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: Success! coloured text in a scribble document!

2016-05-26 Thread Ben Greenman
Yes, that's from scribble/manual. It's Racket's version number. Changing
the first two lines of code to:

#lang scribble/base
@(require scribble/core)

Removes the version number.

-- 
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] WurstfagottCon

2016-06-22 Thread Ben Greenman
At first I thought these were torture instruments.


On Wed, Jun 22, 2016 at 3:32 PM, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> So… I name some of my machines after medieval instruments. Crumhorn,
> sackbut. Time for a new one. List of medieval instruments? Sure, here’s
> one. Oh, look! There’s one called the Rackett! Let’s see.
>
> Hmm… turns out the Rackett represents the pinnacle of medieval ingenuity,
> and sounds approximately like someone blowing through a comb. It’s also
> nicknamed the Sausage Basoon, or “Wurstfagott”.
>
> Can we rename our conference to WurstfagottCon?
>
> John
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> 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] interested in TR internal error?

2016-06-27 Thread Ben Greenman
Just got the same error in a different file, here's a small example.
(If I call local-expand on a (cast ...) expression, seems I can't use that
expression anymore -- but I can still use the expanded version)


#lang typed/racket

(require (for-syntax racket/base syntax/parse))


(define-syntax (f stx)

  (syntax-parse stx

   [(_ a)

(void (local-expand #'a 'expression '()))

#'a]))

(f (cast 1 Integer))

The error message was also not very helpful

Internal Typechecker Error: contract-def-property: thunk called too early

  This should only be called after the type-checking pass has finished.

while typechecking:

  here

originally:

  here

Can we say more than "here"?

-- 
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] new user, simple question: cannot run simple example: (cons 1 2)

2016-05-23 Thread Ben Greenman
You are probably using a student language instead of #lang racket

To fix put "#lang racket" at the top of your program
or click the language button at the bottom-left of your Dr.Racket window
and pick a non-teaching language.


On Mon, May 23, 2016 at 1:47 PM, 'Leo Rokon' via Racket Users <
racket-users@googlegroups.com> wrote:

> I just downloaded DrRacket, and it mostly works for me.
>
> However, I tried an example:
>
> (cons 1 2)
>
> And get this error message:
>
> cons: second argument must be a list, but received 1 and 2
>
> 
>
> The example here:
>
>
> http://download.racket-lang.org/releases/6.5/doc/guide/Pairs__Lists__and_Racket_Syntax.html?q=cons
>
> says that (cons 1 2) is OK.
>
> What is the problem?
>
> --
> 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] trying to get pregenerated html into scribble

2016-05-22 Thread Ben Greenman
Try `include-template` from `web-server/templates`
http://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._include-template%29%29

(Maybe combined with `@literal` from `scribble/html`)
Example:

;; static.html
static content


;; main.scrbl
#lang scribble/html
@require[web-server/templates]

@html{
  @head{
@title{webpage}
  }
  @body{
@h2{content from scribble}
@literal{@include-template{static.html}}
  }
}



$ racket main.scrbl
webpage
content from scribble
static content

-- 
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: Puzzling success at getting pregenerated html into scribble

2016-05-22 Thread Ben Greenman
Whoops, I thought it would be easy to put raw HTML in a normal scribble
document using @include-template[]. But I can't figure out how to do it.
The trick I use for LaTeX is:

  @(make-element (make-style "relax" '(exact-chars)) "any$\tau$hing")

and 'exact-chars doesn't work for HTML. Sorry for the misleading advice
from above, hopefully someone else knows how to insert raw 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: Puzzling success at getting pregenerated html into scribble

2016-05-22 Thread Ben Greenman
That error confused me too. But I guess scribble/text and scribble/html are
only preprocessor languages. They aren't really part of "scribble".
http://docs.racket-lang.org/scribble-pp/index.html

[[
 I'd only used scribble/html to give a quick example of how
@include-template would work.
 But if you want to keep using scribble/html, here's a Makefile that I use
to turn .rkt files into static .html pages:
 https://github.com/nuprl/gtp/blob/gh-pages/Makefile
]]

On Sun, May 22, 2016 at 4:42 PM, Hendrik Boom <hend...@topoi.pooq.com>
wrote:

> On Sun, May 22, 2016 at 02:02:53PM -0400, Ben Greenman wrote:
>
> I copy-pasted your example and tried it twice.  The first time it
> failed, the second time it succeeded.
>
> It succeeded when I used your command
> : racket main.scrbl
>
> but failed when I called
> : scribble --html main.scrbl
> complaining that
>
> : dynamic-require: name is not provided
> :   name: 'doc
> :   module:
> : #<resolved-module-path:"/home/hendrik/write/tryscribble/main.scrbl">
> :   context...:
> :/usr/share/racket/pkgs/scribble-lib/scribble/run.rkt: [running body]
>
> What's going on here?  Doesn't racket invoke scribble when given
> : #lang scribble/html
>
>
> > Try `include-template` from `web-server/templates`
> >
> http://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._include-template%29%29
> >
> > (Maybe combined with `@literal` from `scribble/html`)
> > Example:
> >
> > ;; static.html
> > static content
> >
> >
> > ;; main.scrbl
> > #lang scribble/html
> > @require[web-server/templates]
> >
> > @html{
> >   @head{
> > @title{webpage}
> >   }
> >   @body{
> > @h2{content from scribble}
> > @literal{@include-template{static.html}}
> >   }
> > }
> >
> >
> >
> > $ racket main.scrbl
> > webpage
> > content from scribble
> > static content
>

-- 
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 on contracts -- check equal length of args

2016-07-15 Thread Ben Greenman
On Fri, Jul 15, 2016 at 12:31 PM, Matthias Felleisen 
wrote:

> > On a separate question:  How do I contribute to the docs?
>
> git pull requests on github are highly welcome.


The easiest way to make a docs pull request is to:

1. Go to github.com, find the file you want to edit (e.g
https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/guide/contracts/first-extended-example.scrbl
)
2. Open the file, click the "Edit this file" pencil-shaped button
3. Scroll to the bottom of the file's page, commit the changes to a new
branch.

-- 
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] sequence-append*

2016-07-18 Thread Ben Greenman
Hi, does anyone have an efficient `sequence-append*` function that takes a
sequence of sequences and returns the sequence that has all elements from
each, in order?

Here is my version. It works, but I'm wondering if there's a better way.

(require racket/generator)
;; (Sequenceof (Sequenceof A)) -> (Sequenceof A)
(define (sequence-append* seq-of-seq)
  (in-generator #:arity 1
(for* ([seq seq-of-seq]
   [elem seq])
  (yield elem

-- 
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] How to dynamically generate top-level procedures?

2016-08-09 Thread Ben Greenman
Here's something in the ballpark.

#lang racket

(define-namespace-anchor nsa)
(define ns (namespace-anchor->namespace nsa))

(let ((xyz 1))
  (for ((name '(x y z)))
(namespace-set-variable-value! name (lambda () (displayln (format "~a:
~a" name xyz)) (set! xyz (add1 xyz))) #f ns)))

(eval '(x) ns)

On Tue, Aug 9, 2016 at 5:20 PM, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

>
> > On Aug 9, 2016, at 4:46 PM, David Storrs  wrote:
> >
> > In Perl it's possible to generate main-namespace functions like so:
> >
> > perl -E 'my $z = 1; for (qw/foo bar baz/) {my $x = $_; *$_ = sub{ say
> "$x: ", $z++ }};  foo(); bar(); baz();'
> >
> > This outputs:
> > foo: 1
> > bar: 2
> > baz: 3
> >
> >
> > Note that it is generating top-level subroutines that can be called from
> elsewhere in the program (including other modules) and that those
> subroutines close over existing lexical variables.
> >
> >
> > I tried to do this in Racket and haven't been able to figure it out:
> >
> > First attempt, only partial solution:
> > $ racket
> > -> (for ((name '(x y z))) (define name (lambda () (displayln "foo"
> >
> > ; /Applications/Racket_v6.3/collects/racket/private/for.rkt:1487:62:
> begin
> > ;   (possibly implicit): no expression after a sequence of internal
> definitions
> > ;   in: (begin (define name (lambda () (displayln "foo"
> > ; [,bt for context]
> >
> >
> > I found 'eval', but that doesn't close over lexical variables (
> https://docs.racket-lang.org/guide/eval.html: "The eval function cannot
> see local bindings"):
> >
> > $ racket
> > Welcome to Racket v6.3.
> > -> (let ((xyz 1)) (for ((name '(x y z))) (eval `(define ,name (lambda ()
> (displayln (format "~a: ~a" ,name ,xyz) (set! xyz (add1 xyz
> >
> > -> (x)
> > (x)
> > ; xyz: undefined;
> > ;  cannot reference undefined identifier
> > ; [,bt for context]
> >
> >
> > What have I not found?
>
> Racket is essentially a lexically scoped language. That is: it should be
> possible to look at a piece of code and figure out where the binding for a
> given variable is. It does have a dynamic binding mechanism, but the names
> that are bound dynamically … can be determined lexically.
>
> This might seem to prevent the kind of code that you’re talking about, but
> Racket compensates for this with an extraordinarily flexible macro system,
> and a very permissive notion of what exactly constitutes “compile-time.”
> It’s certainly possible to dynamically generate a piece of code using
> macros. Once generated, though, this piece of code is going to behave
> dependably.
>
> How does this affect your particular example? Well, it’s extremely easy to
> write a macro that does what you describe:
>
> #lang racket
>
> (define-syntax makefuns
>   (syntax-rules ()
> [(_ name ...)
>  (begin (define name (lambda () (displayln "foo")))
> ...)]))
>
> (makefuns x y z)
>
> (x)
>
> (y)
>
> (z)
>
>
>
> Does this solve your problem? If not, why not? It’s going to depend a lot
> on what exactly you want to do.
>
>
> Hope this helps, apologies for telling you anything that you already knew.
>
> John
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> 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] syntax -> normalized-arity

2016-08-09 Thread Ben Greenman
Does anyone have code for statically approximating the arity (and keywords)
of a function?

Examples of my dream function static-procedure-arity:

> (static-procedure-arity #'(lambda (x) x))
1
> (static-procedure-arity #'(lambda (x #:y y . z) x))
(arity-at-least 1)
> (static-procedure-arity #'(define (f x y) x))
2

-- 
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] Stickers!

2017-01-24 Thread Ben Greenman
Hi Racket Users,

I ordered a bunch of Racket stickers to celebrate the 6.8 release. Here's
proof:
http://www.ccs.neu.edu/home/types/resources/stickers.jpg

If you send me your address, I will mail you some stickers. For free!*

I'm thinking 4 stickers per request (2 rectangles, 2 circles), but if you
live outside the US and promise to serve as a "volunteer regional sticker
distributor" then I'll send more.**

Peace, Love, and Racket,
Ben


* While supplies last. And if you want un-free stickers, you can make your
own on stickermule.com or send a donation to RacketCon 2017.

** While supplies last, and subject to the internal dimensions of the
cheapest padded envelope at my local US post office.

-- 
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] Stickers!

2017-01-27 Thread Ben Greenman
In my unprofessional opinion:
- don't modify the logo (change colors, stretch, add unrelated text)
- don't use the logo for personal profit
- don't use the logo in politics
and you should be fine.

On Fri, Jan 27, 2017 at 3:39 AM, Daniel Brunner <dan...@dbrunner.de> wrote:

> Hi,
>
> that's a great idea. I'd like to order some at a local supplier for
> distributing them in Germany/Europe.
>
> Are there any legal issues to consider? (I did not find anything in the
> documentation.)
>
> Kind regards,
> Daniel
>
> Am 24.01.2017 um 22:15 schrieb Ben Greenman:
> > Hi Racket Users,
> >
> > I ordered a bunch of Racket stickers to celebrate the 6.8 release.
> > Here's proof:
> > http://www.ccs.neu.edu/home/types/resources/stickers.jpg
> >
> > If you send me your address, I will mail you some stickers. For free!*
> >
> > I'm thinking 4 stickers per request (2 rectangles, 2 circles), but if
> > you live outside the US and promise to serve as a "volunteer regional
> > sticker distributor" then I'll send more.**
> >
> > Peace, Love, and Racket,
> > Ben
> >
> >
> > * While supplies last. And if you want un-free stickers, you can make
> > your own on stickermule.com <http://stickermule.com> or send a donation
> > to RacketCon 2017.
> >
> > ** While supplies last, and subject to the internal dimensions of the
> > cheapest padded envelope at my local US post office.
> >
> > --
> > 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
> > <mailto: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.
>

-- 
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] Confused about syntax properties

2017-01-29 Thread Ben Greenman
The third result is #f because in the third example, stx is `(annotate
(annotate 4 2))`. So the first pattern matches and `val` is the syntax
`(annotate 4 2)`.

You can get a "strict" evaluation order by using `local-expand` inside the
`annotate` macro. For example:

#lang racket

(define-syntax (annotate stx)
  (syntax-case stx ()
   [(_ val) ; read
   (or (syntax-property (local-expand #'val 'expression #f) 'annotation)
#'#f)]
   [(_ val ann) ; write
   (syntax-property #'val 'annotation #'ann #t)]))

(annotate 4) ;; ==> #f
(annotate 1 6) ;; ==> 1
(annotate (annotate 4 2)) ;; ==> 2


On Sun, Jan 29, 2017 at 1:06 PM, Matias Eyzaguirre 
wrote:

> Hullo all,
>
> I'm messing around with syntax properties to try to get a feel for them,
> but in one of my tests they aren't behaving the way I would expect them to.
>
> In my example the output is #f 1 #f, when I would have thought it would be
> #f 1 2. Why is the third result #f and not 2?
>
>
> #lang racket
>
> (define-syntax (annotate stx)
>   (syntax-case stx ()
> [(_ val) ; read
>  (or (syntax-property #'val 'annotation) #'#f)]
> [(_ val ann) ; write
>  (syntax-property #'val 'annotation #'ann #t)]))
>
> (annotate 4) ; -> #f
>
> (annotate 1 6) ; -> 1
>
> (annotate (annotate 4 2)) ; -> 2
>
> --
> 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] The Little Schemer, misprint?

2017-02-25 Thread Ben Greenman
The printed explanation is giving the meaning of the whole line (in the
context of the call to member) --- not just the meaning of the application
(null? lat)

Hope this helps


On Sat, Feb 25, 2017 at 11:17 AM, Kieron Hardy 
wrote:

> I'm going through The Little Schemer (Fourth Edition). On page 23 the
> first question posed asks:
>
> What is the meaning of the line
>
> ((null? lat) #f)
>
> where
> lat is (mashed potatoes and meat gravy)
> The printed explanation seems to be a misprint as it appears to be the
> answer to a different question:
>
> (null? lat) asks if lat is the null list. If it is, the value is #f, since
> the atom meat was not found in lat. If not, we ask the next question. In
> this case, it is not null, so we ask the next question .
> Is the printed answer wrong, or am I missing something?
>
> Cheers,
>
> Kieron
>
> --
> 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] Best way to ensure threads finish in GUI application?

2017-02-22 Thread Ben Greenman
Yep that's a typo.

I've pushed a fix; thanks for reporting!
https://github.com/racket/racket/commit/591d57b5bc11784b4d34860b26840ffe874bfb91

On Wed, Feb 22, 2017 at 10:36 PM, Vladimir Gajic 
wrote:

> Is "(make-plumber) → pluber?" a typo in 14.11 Plumbers documentation?
>
> See https://docs.racket-lang.org/reference/plumbers.html?q=
> plumbers#%28def._%28%28quote._~23~25kernel%29._make-plumber%29%29
>
> --Vlad
>
>
> On Tuesday, January 31, 2017 at 8:33:11 AM UTC-5, Matthew Flatt wrote:
> > I think you probably want `plumber-add-flush-handle!`:
> >
> >   http://docs.racket-lang.org/reference/plumbers.html
> >
> > At Tue, 31 Jan 2017 13:23:03 +, Erich Rast wrote:
> > > Hi,
> > >
> > > I was wondering what's the best way to ensure that threads end
> > > when a gui application is shut down, which synchronization mechanism I
> > > should use and which kind of program terminations would be handled
> > > gracefully  by this.
> > >
> > > I'm planning on delaying certain sqlite transactions in threads,
> > > since doing them immediately when the user interacts with the GUI does
> > > not work well. AFAIK, sqlite is ACID-compliant, so db consistency
> > > should not be a concern, but I still need to figure out which mechanism
> > > to use for ensuring that the main thread waits for the remaining
> > > threads to finish, and under which conditions it will fail. I've read
> > > about custodians and application-quit-handler. Should I use the latter?
> > > Which timeout is "safe" on which platform? (E.g. Windows waits for
> > > applications to finish before it shuts down, but not indefinitely, and
> > > how about Linux and OSX?)
> > >
> > > Related to that, does application-quit-handler capture signals on
> > > Linux, and if so, which ones, and/or is there a way to install signal
> > > handlers in Racket?
> > >
> > > Sorry for posing so many questions at once. I just wonder what the
> > > practice is for this common scenario. Thanks in advance for any
> replies!
> > >
> > > Best,
> > >
> > > Erich
> > >
> > > --
> > > 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.
>

-- 
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 doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Ben Greenman
Here's a version of your code that runs in the Intermediate Student
language ("local" isn't part of Beginning Student):

 (define (maxval lst)
   (local ((define (aux lst max)
 (cond [(null? lst)  max]
   [(> (car lst) max) (aux (cdr lst) (car lst))]
   [#t (aux (cdr lst) max)])))
 (aux lst 0)))

And here's the full grammar for ISL programs:
http://docs.racket-lang.org/htdp-langs/intermediate.html

Thanks for pointing out that the error message raised by `define` could be
improved.

On Mon, Feb 13, 2017 at 3:48 PM, Matthias Felleisen 
wrote:

>
> You may wish to read up on the design recipe and the necessity of ‘local’
> definitions in HtDP2e:
>
>   http://www.ccs.neu.edu/home/matthias/HtDP2e/
>
>
>
>
> > On Feb 13, 2017, at 3:46 PM, Angus Comber  wrote:
> >
> > But it has to have the signature maxval lst - it is a homework problem.
> >
> > So I thought I would need max in the helper function.  Basically to keep
> an internal max saved value.  Is there another way?
> >
> > On 13 February 2017 at 20:38, Matthias Felleisen 
> wrote:
> >
> > Just lift aux out.
> >
> >
> > > On Feb 13, 2017, at 3:18 PM, Angus Comber 
> wrote:
> > >
> > > If I change the code to:
> > >
> > >  (define (maxval lst)
> > >(define (aux lst max)
> > >  (cond [(null? lst)  max]
> > >[(> (car lst) max) (aux (cdr lst) (car lst))]
> > >[#t (aux (cdr lst) max)]))
> > >(aux lst 0))
> > >
> > > and comment out #lang racket at the top of the file and select
> Beginning Student as the language then I get error:
> > >
> > > define: expected only one expression for the function body, but found
> 1 extra part
> > >
> > > Is this because there is a 2nd define in the function?  Or do I need
> some syntax to indicate to run aux at the end of the definition.
> > >
> > > On 12 February 2017 at 21:34, Matthias Felleisen 
> wrote:
> > >
> > > > On Feb 12, 2017, at 3:00 PM, Angus  wrote:
> > > >
> > > > I am a beginner Racket developer by the way.
> > > >
> > > > Here is my maxval function which is supposed to take a list and
> return the largest integer in the list.
> > > >
> > > > (define (maxval lst)
> > > >   (define (aux lst max)
> > > > (cond [(null? lst)  max]
> > > >   [(car lst) > max (aux (cdr lst) (car lst))]
> > > >   [#t (aux (cdr lst) max)]))
> > > >   (aux lst 0))
> > > >
> > > >
> > > > Using the function always returns the last value in the list
> > > >
> > > >> (maxval (list 1 2 3 5 6 1))
> > > > 1
> > > >
> > > > The code looks correct to me, but I must be missing something.  What
> have I done wrong?
> > >
> > >
> > > Your code is 100% correct, conceptually. Sadly, it’s suffering from a
> mistake that I saw many many times in the 90s and before. And that’s
> precisely why we get beginners started on Beginning Student Language in
> DrRacket instead of plain Racket. Try it out for your next few exercises or
> even this one, to see whether the error message would have helped.
> > >
> > > — Matthias
> > >
> > >
> >
> >
>
>
>
> --
> 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] Serializing macro transformer procedures

2017-01-20 Thread Ben Greenman
I can do this in the normal Racket repl:

(define (f x)

  (define-syntax-rule (rev-apply x g)

(g x))

  (rev-apply x add1))

(f 3)
;; ==> 4


I'd like to put a `(debug-repl)` inside the definition of `f` and call
`rev-apply` in that debug repl too.

On Fri, Jan 20, 2017 at 6:52 AM, Philip McGrath 
wrote:

> How would you intend to use the macro transformer functions in the
> debug-repl? Do you intend to call them as functions on syntax objects? I'm
> not sure I understand what you're trying to achieve.
>
> -Philip
>
> On Fri, Jan 20, 2017 at 3:40 AM, Alex Knauth  wrote:
>
>>
>> On Jan 19, 2017, at 8:44 PM, Philip McGrath 
>> wrote:
>>
>> It might help if you could explain in more detail what you're trying to
>> do: I'm not sure I understand what you mean by "bring macro transformer
>> procedures down to run-time".
>>
>>
>> My goal is to have a debug-repl that includes everything in it's scope.
>> Debug-repl can use syntax-local-value access to the macro transformers in
>> it's scope, but they are compile-time objects; if I just embed them in the
>> expanded code it won't compile.  However, I these things at run-time to
>> attach them to the namespace.
>>
>> If I could serialize the lambda in
>> (define-syntax m
>>   (lambda (stx) ))
>> I could recover it at run-time and add it to the debug-repl namespace.
>>
>> (define (f x)
>>   (define-syntax m
>> (serial-lambda (stx) ; syntax-local-lift-provide: not expanding in a
>> module run-time body
>>   (syntax-case stx () [(_ e) #'e])))
>>   (debug-repl))
>>
>> Alex Knauth
>>
>> -Philip
>>
>> On Wed, Jan 18, 2017 at 6:24 PM, Alex Knauth 
>> wrote:
>>
>>> I'm trying to use serial-lambda in macro transformer procedures so that
>>> I can serialize them and bring them down to run-time. However,
>>> serial-lambda isn't working within a define-syntax. It says:
>>>
>>> syntax-local-lift-provide: not expanding in a module run-time body
>>>
>>> This seems to be a lie; it works fine in a begin-for-syntax (as long as
>>> you don't try to deserialize). What's the real reason it doesn't work in a
>>> define-syntax? Is there another way to bring macro transformer procedures
>>> down to run-time?
>>>
>>> Alex Knauth
>>
>>
> --
> 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] testing for timeout in Rackunit?

2016-08-18 Thread Ben Greenman
Also try `call-with-limits` from racket/sandbox
http://docs.racket-lang.org/reference/Sandboxed_Evaluation.html#%28def._%28%28lib._racket%2Fsandbox..rkt%29._call-with-limits%29%29

On Thu, Aug 18, 2016 at 6:37 PM, Matthias Felleisen 
wrote:

>
> Do you mean something like this:
>
>
> (define time-limit .1)
>
> (define-syntax-rule
>   (check-termination e)
>   (check-false (false? (sync/timeout time-limit (thread (λ () (list
> e)))
>
> (check-termination (+ 1 1))
> (check-termination #f)
> (check-termination (let loop () (loop)))
>
>
> — Matthias
>
>
> > On Aug 18, 2016, at 5:59 PM, Mitchell Wand  wrote:
> >
> > Of course you can't test for non-termination, but is there a relatively
> simple way to write something like
> >
> > (check-doesnt-terminate-quickly  )
> >
> > which would fail if the thunk terminates within the time limit, and
> succeeds otherwise?
> >
> > This would be useful in testing expressions that are claimed not to
> terminate.
> >
> > For this use case, it doesn't matter if the time limit is only
> approximate.
> >
> > --Mitch
> >
> > --
> > 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.
>

-- 
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 -script running other Racket scripts

2016-08-21 Thread Ben Greenman
I would use `system*` or `process*` with `(find-exe)` [1] as the first
argument.

You might also like `find-console-bin-dir` [2].

[1]
http://docs.racket-lang.org/raco/exe.html#%28def._%28%28lib._compiler%2Ffind-exe..rkt%29._find-exe%29%29
[2]
http://docs.racket-lang.org/raco/dirs.html#%28def._%28%28lib._setup%2Fdirs..rkt%29._find-console-bin-dir%29%29

On Sun, Aug 21, 2016 at 6:00 AM, Pekka Niiranen 
wrote:

> Hello users,
>
> I am trying to eradicate *.bat files running Racket scripts.
>
> What is the idiom to make Racket script to start itself recursively
> (system, process, subprocess) when main script is started from shell
> and all outputs are printed to console?
>
> "racket mscript.rkt args" => (system *.bat) => "racket *.rkt args"
>
> -pekka-
>
> --
> 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] TR warning with pict3d-canvas% (in pict3d)

2016-09-08 Thread Ben Greenman
On Wed, Sep 7, 2016 at 10:35 AM, Tim Brown  wrote:

> ffi-types.rkt:19 is:
>  ..
>  17  (require/typed
>  18   ffi/unsafe
> *19   [#:opaque CPointer cpointer?]  ; includes Bytes and other things
> that can be used as cpointers
>  20   [#:opaque CType ctype?]
>  21   )
>  ..
> which seems perfectly innocuous to me :-/
>

You're right, it's innocuous. So we can use `unsafe-require/typed`:

#lang typed/racket/base
(require (only-in typed/racket/unsafe unsafe-require/typed))

(unsafe-require/typed ffi/unsafe
  [#:opaque CPointer cpointer?]
  [#:opaque CType ctype?]
)
(require/typed ffi/unsafe
  [malloc (-> Fixnum CPointer)]
)

(malloc 4) ;; no warnings


---

Here's the discussion behind the warning messages:
https://github.com/racket/typed-racket/pull/396

Basically, the trouble is that `cpointer?` might be an evil untyped
function:

(define (cpointer? x)
  (when (box? x)
(set-box! x 'EVIL))
  #t)


Typed Racket can't be sure, so it tries to protect all arguments to
`cpointer?`.
But when you call `(cpointer? v)` where `v` is a `#`, Typed
Racket warns you that it doesn't know how to protect `#` values.

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


Re: [racket-users] Re: Why is 3d3 a number?

2016-09-20 Thread Ben Greenman
Whew, fantastic! Thank you.
(Should I tell the Fundamentals I students about R6RS?)


On Tue, Sep 20, 2016 at 11:32 AM, Asumu Takikawa <as...@simplyrobot.org>
wrote:

> On 2016-09-20 11:27:07 -0400, Ben Greenman wrote:
> >Oh! Just found that common lisp used these for types:
> >- s = short
> >- f = single
> >- d = double
> >- l = long
>
> I think it's more specifically an R6RS thing. Quoth the standard:
>
>   In systems with inexact number objects of varying precisions, it may be
> useful
>   to specify the precision of a constant. For this purpose,
> representations of
>   number objects may be written with an exponent marker that indicates the
>   desired precision of the inexact representation. The letters s, f, d,
> and l
>   specify the use of short, single, double, and long precision,
> respectively.
>   (When fewer than four internal inexact representations exist, the four
> size
>   specifications are mapped onto those available. For example, an
> implementation
>   with two internal representations may map short and single together and
> long
>   and double together.) In addition, the exponent marker e specifies the
> default
>   precision for the implementation. The default precision has at least as
> much
>   precision as double, but implementations may wish to allow this default
> to be
>   set by the user.
>
>   http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-7.html#node_sec_4.2.8
>
> Cheers,
> Asumu
>

-- 
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] Why is 3d3 a number?

2016-09-20 Thread Ben Greenman
Just confused, is there any reason that 'd' 'e' 'f' 's' 'l' are all
accepted as exp-mark s?
http://docs.racket-lang.org/reference/reader.html%20numbers#%28part._parse-number%29


Before I came here I asked Wolfram Alpha. It says:
- 3d3 is probably "3 dice with 3 sides each" and prints a histogram of
probabilities
- 3e3 is 3000. (Phew)
- 3f3 is probably "3 degrees farenheit, cubed". No histogram.
- 3s3 is probably "3 seconds cubed". But it also offers to find roots for
"y = 3f3".
- 3l3 is "fruit fly gene".

-- 
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 3d3 a number?

2016-09-20 Thread Ben Greenman
Oh! Just found that common lisp used these for types:
- s = short
- f = single
- d = double
- l = long

http://www.gigamonkeys.com/book/numbers-characters-and-strings.html

Is this still true for Racket?

On Tue, Sep 20, 2016 at 11:25 AM, Ben Greenman <benjaminlgreen...@gmail.com>
wrote:

> Just confused, is there any reason that 'd' 'e' 'f' 's' 'l' are all
> accepted as exp-mark s?
> http://docs.racket-lang.org/reference/reader.html%
> 20numbers#%28part._parse-number%29
>
>
> Before I came here I asked Wolfram Alpha. It says:
> - 3d3 is probably "3 dice with 3 sides each" and prints a histogram of
> probabilities
> - 3e3 is 3000. (Phew)
> - 3f3 is probably "3 degrees farenheit, cubed". No histogram.
> - 3s3 is probably "3 seconds cubed". But it also offers to find roots for
> "y = 3f3".
> - 3l3 is "fruit fly gene".
>
>

-- 
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] optional hyphen in scibble

2016-10-02 Thread Ben Greenman
Maybe:
https://pkgn.racket-lang.org/package/hyphenate

On Sun, Oct 2, 2016 at 3:30 PM, Jos Koot  wrote:

> Hi to all of this nice list,
>
> IIRC I have seen a tool to put optional hyphens in running text in order
> to allow scribble to break words at the end of a line.
>
> However, I no longer can't find it (I know, I am a bad browser)
> A pointer to the related docs will be appreciated very much.
>
> Thanks,
> Jos
>
> --
> 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] Contract violation where number expected - can't understand why

2016-10-01 Thread Ben Greenman
Maybe this will help:

(struct interval (small big guesses))

creates 5 new functions

   1. interval, for making intervals. For example (interval 5 10 0) creates
   an interval from 5 to 10 that has 0 guesses
   2. interval?, for testing if a value is an interval. For example
   (interval? 1) is #false and (interval? (interval 0 0 0)) is #true
   3. interval-small, to get the value of the "small" field out of an
   interval. For example, (interval-small (interval 8 9 10)) is 8
   4. interval-big, to get the value of the "big" field
   5. interval-guesses, to get the value of the "guesses" field

This is all described in the Racket docs for struct
http://docs.racket-lang.org/reference/define-struct.html


The value of (+ (interval-guesses w) 1) is a number 1 greater than the
value of the "guesses" field in the interval w.
Notice that you give this value as the 3rd argument to a call to (interval
)

-- 
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] Creating a list of random things

2016-10-25 Thread Ben Greenman
Or:

(build-list n (lambda (dont-care) (make-random-string)))

On Tue, Oct 25, 2016 at 10:42 PM, Robby Findler  wrote:

> I would probably write that function like this:
>
> #lang racket
>
> (provide
>  (contract-out
>   [make-a-string (-> non-empty-string? string?)]))
>
> (define (make-a-string candidates)
>   (apply
>string
>(for/list ([i (in-range (random 100))])
>  (string-ref candidates (random (string-length candidates))
>
> (module+ test
>   (require rackunit)
>   (check-true (string? (make-a-string "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123
> 456789"
>
>
> hth,
> Robby
>
>
> On Tue, Oct 25, 2016 at 9:39 PM,   wrote:
> > Hi,
> >
> > I want to create a list of random strings.
> > For that I have created a function, which returns a string
> > of random length and random contents.
> >
> > Then I used
> > make-list n (make-random-string)
> >
> > to create that listand get back a list filled with n
> > identical strings.
> >
> > h...
> >
> > make-list calls make-random-string ones and the rest
> > is repetition.
> >
> > If I think to have understood correctly for-loops and such are
> > somehow of "imperative, non-functional old-school programming style"
> > and map/apply and friends are the tools of the real racket programmer
> > ;) this lead to a more general "problem" ("problem" only for a newbie
> > like me may be)...:
> >
> > Since make-list calls its list-argument only once, the above does not
> > work in the sense it is wanted, so make-list creates only lists of
> > the same thing.
> >
> > Therefore to prevent "for" and friends, I have to call make-list
> > with the empty list as list-argument and then map the
> > make-random-string to each of them, which ensures that
> > make-random-string is not called once.
> > That feels ugly.
> >
> > What is a good "racket-ish" of "racket-y" way (nothing negative
> > meant...just a play with words by someone, who is no native
> > speaker...;) to do something n times without old-school
> > for-and-friends-loops.
> >
> > Here is the code:
> >
> > #lang racket
> > (require racket/random)
> > (require racket/string)
> >
> > (define charseq "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
> > (define minchars  7)
> > (define maxchars 15)
> > (define numlists 6)
> >
> > (define (make-random-string seq min max)
> >   ( let ((lenstr (random min max)))
> > ( apply string (random-sample seq lenstr
> >
> > (define (make-list-of-random-strings cnt seq min max )
> >   (make-list cnt (make-random-string seq min max )))
> >
> > (define (make-list-of-lists numsublists)
> >   ( make-list numsublists (make-list-of-random-strings numlists charseq
> minchars maxchars)))
> >
> > ( define (main)
> >  (make-list-of-lists 20))
> >
> > (main)
> >
> > Any improvement is welcome!
> >
> > Cheers,
> > Meino
> >
> >
> >
> > --
> > 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.
>

-- 
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] Problem displaying a struct returned by a function in a cond statement

2016-10-26 Thread Ben Greenman
Can you show us findSense?

The error message is saying there's an extra pair of parentheses somewhere,
for example:
> (1)
> (define-struct foo () #:transparent)
> ((foo))

On Wed, Oct 26, 2016 at 1:16 PM, Ken MacKenzie  wrote:

> New to racket and playing with a little something.  Here is my code:
>
> #lang racket/base
>
> (require racket/list)
>
> (require "Findsense.rkt")
>
> (provide handleWords)
>
> (define (handleWords wlist)
>   (cond
> [(null? wlist) #f]
> [else (display (findSense (first wlist)))
>   (handleWords (rest wlist))]))
>
> (handleWords (list "art" "bear"))
>
> And here is the error I receive running it.
>
> application: not a procedure;
>  expected a procedure that can be applied to arguments
>   given: (sense '("art" "1:04:00::") '("00935235" "2" "15"))
>   arguments...: [none]
>   context...:
>/home/superfly/dev/racket/SParse/Words.rkt: [running body]
>
> Details on the Findwords.rkt file, that is where the Findsense function
> and sense structure are provided from.  The structure is marked
> #:transparent
>
> I have tried different variations of using write, display, and even print
> and just can't seem to get past this error on returning a struct from the
> function.
>
> Note, this is called from another piece of code.  I added the last line
> with art and bear as a means of isolating it for testing.
>
> Ken
>
> --
> 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] POST requests never bound?

2016-11-08 Thread Ben Greenman
Here!
https://github.com/racket/web-server/blob/master/web-server-doc/web-server/scribblings/dispatch.scrbl

(If you install `raco-find-collection`, then running `raco fc web-server`
should bring you close to the right place.)

On Tue, Nov 8, 2016 at 4:38 PM, Luke  wrote:

> I'd be happy to do do it.
>
> I've spent a little time digging around for the appropriate place, but
> nothing seems obvious. Would you (or someone else?) mind giving me a
> pointer to help me see where such an update most likely belongs?
>
> --
> 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] Of editors and mere mortals

2016-11-05 Thread Ben Greenman
Do you have racket-mode installed?
https://github.com/greghendershott/racket-mode

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


Re: [racket-users] Re: FUSE filesystem package

2016-10-12 Thread Ben Greenman
>
>
> Any connection to Jesse's affine contracts?
>
> http://planet.racket-lang.org/package-source/tov/affine-
> contracts.plt/2/2/planet-docs/manual/index.html


Whoa, I didn't know those existed. Cool!

-- 
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] opinions on YAML as communication tool

2016-10-21 Thread Ben Greenman
I vote that you stick with Excel & change the version control protocol.

Maybe:
http://stackoverflow.com/a/17106035/5237018

On Fri, Oct 21, 2016 at 9:22 AM, Matthias Felleisen 
wrote:

>
> See Claire’s paper on cKanren. Scheduling is one of her examples (though
> small scale).
>
>
>
> > On Oct 21, 2016, at 7:18 AM, Robby Findler 
> wrote:
> >
> > Wh? You're not going to design your own language and implement a
> > syntax colorer in DrRacket for it so they can tell immediately when
> > something goes wrong?  ;)
> >
> > Robby
> >
> >
> > On Fri, Oct 21, 2016 at 12:21 AM, 'John Clements' via Racket Users
> >  wrote:
> >> Yet another totally off-topic question for you extremely smart people.
> Well, it’s a language design question, so it’s not *too* off-topic.
> >>
> >> I’m temporarily serving as my department’s scheduler (don’t ask).
> Currently, the planning for the future schedule is done using an Excel
> spreadsheet. I try not to hate Microsoft products for knee-jerk reasons,
> but the simple fact is that this format is completely not git-versionable.
> >>
> >> This file has to be shared with non-programmers, though it doesn’t
> necessarily have to be *edited* by non-programmers, just read.
> >>
> >> I’m currently thinking that the best compromise may be YAML. E.G.
> >>
> >> # 2017-2018 schedule:
> >> alincoln : {fall: [304, 428], winter: [409, special], spring: []} #
> maybe theater?
> >> gwashington: {fall: [224, 287, 110], winter: sabbatical, spring: [789]}
> >> # might be able to hire stuffy?
> >> stuffy: {fall: [234,234,234], winter: [235, 235, 235]}
> >> …
> >>
> >> It looks like a fairly dense format, it’s a text file so it’s
> versionable in a sane way, and you could be fairly flexible in your parsing.
> >>
> >> To be fair, sexprs also look pretty good:
> >>
> >> ;; 2017-2018 schedule
> >> ((alincoln ((fall (304 428)) (winter (409 special)) (spring ( ;;
> maybe theater?
> >> (gwashington ((fall (224 287 110)) (winter sabbatical) (spring (789
> >> ;; might be able to hire stuffy?
> >> (stuffy ((fall (234 234 234)) (winter 235 235 235
> >>
> >> Also note that there’s no need for this file to contain any information
> about times and rooms, just a mapping from instructor/quarter
> >> to classes taught, with room for comments.
> >>
> >> I thought hard about scribble and JSON (and xml, yecch), but I think
> that YAML and sexps are the two viable candidates, and I’m guessing that if
> non-programmers have to edit it, they’ll be less likely to botch the YAML
> one.
> >>
> >> Any opinions?
> >>
> >> John
> >>
> >>
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> 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.
>
> --
> 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] raco pkg install failing inside Virtualbox. OpenSSL issue?

2016-10-19 Thread Ben Greenman
You can disable El Capitan's "system integrity protection".
http://stackoverflow.com/questions/30768087/restricted-folder-files-in-os-x-el-capitan


On Wed, Oct 19, 2016 at 1:09 PM, David Storrs 
wrote:

> I have it on OSX running on metal. My understanding (possibly wrong) is
> that it's an issue with the libcrypto and libssl 0.9 versions that were
> shipped with OSX 11 (El Capitan), and apparently with your version of
> Ubuntu. If you replace the libraries with 1.0+ versions I would expect it
> to resolve the issue. Do your own due diligence though -- I'd hate to give
> you bad advice and hose your machine. I tried to do it on my box but El
> Capitan does not allow any user, including root, to modify system
> directories.
>
> I'm really sorry I "upgraded" from Snow Leopard (10.6) which had neither
> of these problems and a nicer interface.
>
>
>
> On Wednesday, October 19, 2016, phil jones  wrote:
>
>> If I read correctly then it seems it's an incompatibility between the
>> openssl on Ubuntu and the server which raco is trying to pull from.
>>
>> When you say you have this on MacOS  do you mean on MacOS directly? Or
>> on Virtualbox running Ubuntu on a Mac?
>>
>> I wonder if this is something that I can fix by changing the Ubuntu
>> version in my box. Or whether it's actually something that the people
>> providing the racket package repository need to address on their
>> server?
>>
>> cheers
>>
>> Phil
>>
>>
>> On 19 October 2016 at 13:01, David Storrs  wrote:
>> > Hi Phil,
>> >
>> > Apparently this is an issue with OpenSSL:
>> > https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/861137  I've
>> had the
>> > same issues on OSX.
>> >
>> > Dave
>>
>> >
>> > On Wed, Oct 19, 2016 at 9:36 AM, phil jones 
>> wrote:
>> >>
>> >> Hi,
>> >>
>> >> I'm trying to get my development environments across different machines
>> >> more consistent by running a standard Ubuntu image inside a Vagrant /
>> >> Virtualbox Box.
>> >>
>> >> I'm trying to set up racket inside this environment (on Windows 10),
>> but
>> >> I'm getting the following error trying to install libraries with raco.
>> >>
>> >> ssl-connect: connect failed (error:14077438:SSL
>> >> routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error)
>> >>
>> >> context...:
>> >>  /usr/share/racket/collects/openssl/mzssl.rkt:1207:8: loop
>> >>  ... rest of stack trace.
>> >>
>> >> I'm guessing that this is because of some configuration either of the
>> >> Virtual Machine itself or of my new Ubuntu environment.
>> >>
>> >> Anyone got 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.
>

-- 
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] ANN: with-cache

2016-11-22 Thread Ben Greenman
with-cache is a small package for saving the results of an expression to
the filesystem

#lang racket/base
(require pict with-cache)

(define (get-fish)
  (with-cache (cachefile "stdfish.rktd")
(λ () (standard-fish 100 50

(get-fish) ;; Builds a fish
(get-fish) ;; Reads a fish from "./compiled/with-cache/stdfish.rktd"



Run the above with `racket -W info@with-cache file.rkt` to see when cache
files get written and read.

By default, cached data is serialized, written in fasl format, and
invalidated if read by a different version of the with-cache library. You
can override all these options; the docs should explain how.

Docs (latest update is yet to sync on the package server):
http://docs.racket-lang.org/with-cache/index.html

Code:
https://github.com/bennn/with-cache

History:
I started writing this code while working on a Scribble document with lots
of picts in it. (Most of the picts were made by plot. Tweaking plot
parameters led to the *current-cache-keys* parameter.)
William Bowman encouraged me to put an early version of this code on the
package server.
Leif Andersen pointed out LOTS of places where the original code needed to
improve.

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


Re: [racket-users] Re: ANN: with-cache

2016-11-23 Thread Ben Greenman
By default, only values that can be serialized can be cached.
Can you call `(serialize )` on one of these structs?

If that is the problem, one fix is to add the `prop:serializable` property
to the struct definition.
http://docs.racket-lang.org/reference/serialization.html?q=prop%3Aserializable#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29

Either way, another fix is to define functions that convert instances of
the struct to s-expressions & use the #:read and #:write options for
with-cache

(define (frame->sexp f) )

(define (sexp->frame s) )

(with-cache "data.rktd"

  #:write frame->sexp

  #:read sexp->frame

  (lambda () ))


On Wed, Nov 23, 2016 at 5:46 AM, Alex Harsanyi <alexharsa...@gmail.com>
wrote:

> Hi Ben,
>
> What types of values can be cached by with-cache?
>
> I tried to use it with a data-frame object I use in my application (wanted
> to check if it is faster to retrieve it from the filesystem than the
> database), but unfortunately it failed with:
>
> ; with-cache: Internal error: failed to make writable value from result
> '#(struct:object:data-frame% ...)'
>
> The object itself is essentially a collection of large (about 1 items)
> vectors (about 30 of them) plus some metadata.
>
> Thanks,
> Alex.
>
> On Wednesday, November 23, 2016 at 1:11:27 PM UTC+8, Ben Greenman wrote:
> > with-cache is a small package for saving the results of an expression to
> the filesystem
> >
> >
> >
> > #lang racket/base
> > (require pict with-cache)
> >
> >
> > (define (get-fish)
> >   (with-cache (cachefile "stdfish.rktd")
> > (λ () (standard-fish 100 50
> >
> >
> > (get-fish) ;; Builds a fish
> > (get-fish) ;; Reads a fish from "./compiled/with-cache/stdfish.rktd"
> >
> >
> >
> > Run the above with `racket -W info@with-cache file.rkt` to see when
> cache files get written and read.
> >
> >
> > By default, cached data is serialized, written in fasl format, and
> invalidated if read by a different version of the with-cache library. You
> can override all these options; the docs should explain how.
> >
> >
> >
> > Docs (latest update is yet to sync on the package server):
> > http://docs.racket-lang.org/with-cache/index.html
> >
> >
> >
> > Code:
> > https://github.com/bennn/with-cache
> >
> >
> >
> > History:
> > I started writing this code while working on a Scribble document with
> lots of picts in it. (Most of the picts were made by plot. Tweaking plot
> parameters led to the *current-cache-keys* parameter.)
> > William Bowman encouraged me to put an early version of this code on the
> package server.
> > Leif Andersen pointed out LOTS of places where the original code needed
> to improve.
>
> --
> 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] If a thunk is a proc of zero arguments, what is a proc of one argument?

2016-11-15 Thread Ben Greenman
On Tue, Nov 15, 2016 at 11:57 AM, David Storrs 
wrote:

> I did not, but that's a very nice feature.  Unfortunately, I'm an Emacs
> guy.  :/


Then you have no excuse for not making a λ 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] syntax-class that is just a set of literals

2016-11-18 Thread Ben Greenman
Typo: I meant "the `define-literal-syntax-class` macro", from here:
https://groups.google.com/d/msg/racket-users/9e_oNlLODeY/MUqGM_r6BwAJ

On Fri, Nov 18, 2016 at 7:03 PM, Ben Greenman <benjaminlgreen...@gmail.com>
wrote:

>
> On Wed, Nov 16, 2016 at 6:05 PM, Dan Liebgold <dan_liebg...@naughtydog.com
> > wrote:
>
>> First, I'm trying to define a syntax-class that is just a set of
>> literals, and I'm wondering if there is a slightly better way that this:
>>
>>  * http://pasterack.org/pastes/86722
>>
>> I'd just prefer to not repeat all the literal definitions.
>>
>
> Here's an idea, inspired by the `define-literal-set` macro Vincent posted
> in the other thread.
> http://pasterack.org/pastes/22325
>

-- 
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] syntax-class that is just a set of literals

2016-11-18 Thread Ben Greenman
On Wed, Nov 16, 2016 at 6:05 PM, Dan Liebgold 
wrote:

> First, I'm trying to define a syntax-class that is just a set of literals,
> and I'm wondering if there is a slightly better way that this:
>
>  * http://pasterack.org/pastes/86722
>
> I'd just prefer to not repeat all the literal definitions.
>

Here's an idea, inspired by the `define-literal-set` macro Vincent posted
in the other thread.
http://pasterack.org/pastes/22325

-- 
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] docs for string-trim

2016-11-01 Thread Ben Greenman
The trick is that 'whitespace' isn't just #\space. It's any sequence of
whitespace characters, like "\r\r\r" or " \r\n\t"

On Wed, Nov 2, 2016 at 12:12 AM,  wrote:

> Hi,
>
> when using the search function for the Racket-docs
> with string-trim I found:
>
> -
> Trims the input str by removing prefix and suffix sep, which defaults to
> whitespace. A string sep is matched literally (as opposed to being used as
> a regular expression).
>
> Use #:left? #f or #:right? #f to suppress trimming the corresponding side.
> When repeat? is #f (the default), only one match is removed from each side;
> when repeat? is true, all initial or trailing matches are trimmed (which is
> an alternative to using a regular expression sep that contains +).
>
> Examples:
>
> > (string-trim "  foo bar  baz \r\n\t")
> "foo bar  baz"
> > (string-trim "  foo bar  baz \r\n\t" " " #:repeat? #t)
> "foo bar  baz \r\n\t"
> > (string-trim "aaaxaayaa" "aa")
> "axaay"
> -
>
> It says, that #:repeat is false if not given (the default).
> It looks like, that the first example has a little bug: Both
> #\space characters are removed from in front of "foo" - identical
> to the second example, where #:repeat is given (#t).
>
> ...or I need more coffee or more sleep... ;)
>
> Cheers
> Meino
>
>
>
>
> --
> 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] 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] How to edit the htdp package from a release?

2016-10-12 Thread Ben Greenman
I've installed Racket 6.6 from download.racket-lang.org and I'd like to
submit a change to the HTDP repo.

(This question is not really specific to HTDP, anyway)

Before I submit the edit, I want to test the change on my machine, so I
figure I'll make a clone of the htdp package:

$ raco pkg update --clone htdp

But this gives me an error:

Inferred package name from given `--clone' path
  package: htdp
  given path: htdp
Inferred package scope: installation
raco pkg update: package is not currently installed from a repository
  package: htdp
  current installation: (catalog htdp)

Is it possible for my install of Racket 6.6 to use a cloned version of htdp?

-- 
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] Unable to utilize parse-command-line to build command line application

2016-10-12 Thread Ben Greenman
Alright, here's something that I think does what you want.

#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) (displayln "Using "))
 ("Use input file as the input file.")]))
 ;; finish-proc
 (lambda (flag-accum file) file)
 ;; arg-help-strs
 '("Input file.")
 ;; help-proc
 (lambda (flag) (raise-user-error "com_line -i | --input-file input file")))

;; $ ./com_line --input-file "hacking.rkt"
;; Using 
;; "hacking.rkt"

;; $ ./com_line --help
;; com_line -i | --input-file input file


The code in your last message expects 1 flag, 1 argument to the flag
 (`in`), and 1 `file` argument.

On Wed, Oct 12, 2016 at 7:15 AM, Ian Thomas <i.tho...@me.com> wrote:

> On Wednesday, October 12, 2016 at 6:54:45 AM UTC-4, Ian Thomas wrote:
> > On Tuesday, October 11, 2016 at 9:50:12 PM UTC-4, Ben Greenman wrote:
> > > 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 <i.th...@me.com> 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...@googlegroups.com.
> > >
> > > For more options, visit https://groups.google.com/d/optout.
> >
> > I'd like to handle usage - help-proc - and unknown flags - unknown-proc
> - and the documentation states you need to use parse-command-line and not
> command-line to achieve this.
>
> I've re-read the documentation and added some more arguments to the
> parse-command-line function, and now I think I'm almost there. Error
> messages immediately below: updated code follows.
>
> $ ./com_line --input-file hacking.rkt
> Using 
> com_line: expects 1  on the command line, gi

Re: [racket-users] How to edit the htdp package from a release?

2016-10-12 Thread Ben Greenman
yes yes yes
Thank you!

On Wed, Oct 12, 2016 at 12:01 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> At Wed, 12 Oct 2016 11:34:06 -0400, Ben Greenman wrote:
> > I've installed Racket 6.6 from download.racket-lang.org and I'd like to
> > submit a change to the HTDP repo.
> >
> > (This question is not really specific to HTDP, anyway)
> >
> > Before I submit the edit, I want to test the change on my machine, so I
> > figure I'll make a clone of the htdp package:
> >
> > $ raco pkg update --clone htdp
> >
> > But this gives me an error:
> >
> > Inferred package name from given `--clone' path
> >   package: htdp
> >   given path: htdp
> > Inferred package scope: installation
> > raco pkg update: package is not currently installed from a repository
> >   package: htdp
> >   current installation: (catalog htdp)
> >
> > Is it possible for my install of Racket 6.6 to use a cloned version of
> htdp?
>
> Yes, but since "htdp" starts out installed from a catalog that provides
> a built "htdp" package instead of the Git package source, you have to
> also specify the Git source.
>
> Although you can do that with
>
>  $ raco pkg update --clone htdp "https://github.com/racket/
> htdp.git?path=htdp"
>
> I bet you actually want to modify "htdp-lib" or "htdp-doc"... and then
> I see that you're going to get to a dependency mismatch with
> "string-constants".
>
>
> In this case, things will work better if you use
>
>  $ bin/raco pkg update --catalog https://pkgs.racket-lang.org htdp
>
> to switch to the development version of the package, so you get needed
> updates for other packages (also from the catalog). The catalog
> provides a Git path, so then
>
>  $ raco pkg update --clone htdp
>
> will do what you expected.
>
> Really, I guess you want to use a catalog that has Git paths but also
> checksums at the time of the v6.6 release, as opposed to using the
> post-6.6 development branch. I don't think we currently have catalogs
> like that, though.
>
> --
> 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] ->i applies contract projections multiple times?

2016-12-15 Thread Ben Greenman
There are 3 parties that could be blamed:
1. the context that calls `foo`
2. the function `foo`
3. the contract on `foo`

On Thu, Dec 15, 2016 at 5:05 PM, Alexis King  wrote:

> Many thanks to both of you for the explanation and examples. I admit
> I’ve seen that paper before, but I haven’t really taken the time
> to understand it. I haven’t spent the effort to understand all the
> notation being used, so much of the paper is pretty opaque to me.
> Maybe once I get some time I’ll sift through it more carefully, but
> in the meantime, Scott’s example helps a lot to demonstrate what
> indy dependent contracts actually do.
>
> However, from a practical implementation perspective, I’m still a
> little confused about why the contract needs to be applied twice.
> Given that Racket uses the +indy semantics, it seems like the blame
> provided is identical for both cases, so it seems like the contracts
> should only need to be applied once. For Scott’s example, the
> contract for the y argument needs to be applied such that if it is
> misused within the function body, then it blames foo, and if it is
> misused within the contract itself, it also blames foo.
>
> If ->i used the indy or -indy semantics (though admittedly I don’t
> get why the -indy semantics would ever be useful), I would understand
> why the contract would need to be applied twice, since the blame
> would be different. Given the way Racket handles things, though, I
> don’t really understand what I’m missing.
>
> --
> 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] Good Data Structures Book?

2016-12-13 Thread Ben Greenman
"Purely Functional Data Structures"
https://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504

On Tue, Dec 13, 2016 at 1:22 PM, Lawrence Bottorff 
wrote:

> Can someone suggest a good text for data structures that would compatible
> with Racket? All I see are treatments using C/C++, Java, Python, i.e., the
> usual suspects. Or, how do you people at Racket-friendly/based universities
> teach undergrad data structures?
>
> --
> 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] Syntax for hash contracts

2016-12-02 Thread Ben Greenman
On Thu, Dec 1, 2016 at 7:29 PM, David Storrs  wrote:

> I'm having trouble understanding the docs on hash contracts (
> https://docs.racket-lang.org/reference/data-structure-
> contracts.html#%28def._%28%28lib._racket%2Fcontract%
> 2Fprivate%2Fhash..rkt%29._hash%2Fc%29%29)
>
> What I'm trying to express is:
>
> - This function returns #t because it is a simple test function intended
> to get the hang of hash contracts...
> - This function takes one argument...
> - Which is a hash...
> - Which has keys 'success, 'file-id, 'scratchdir-path, and 'chunk-hash...
> - All of which are symbols...
> - The values will be, respectively:
> success boolean?
>

1. Like Alexis says, `hash/dc` lets you specify a relationship between keys
and values **but** the same relationship needs to hold for every key/value
pair. Here's an example:

#lang racket
(require rackunit)

(define my-hash/c
  (hash/dc [k char?] [v (k) (=/c (char->integer k))]))

(contract my-hash/c (make-hash '((#\A . 65) (#\B . 66))) '+ '-)
;; good hash

(contract my-hash/c (make-hash '((#\A . 66))) 'pos 'neg)
;; bad hash


2. And here's a funny way to check the property you care about

(define special-list/c
  (list/c (cons/c 'chunk-hash string?)
  (cons/c 'file-id (or/c #f exact-positive-integer?))
  (cons/c 'scratchdir-path path-string?)
  (cons/c 'success boolean?)))

(define (special-hash/c h)
  (special-list/c (sort (hash->list h) symbolhttps://groups.google.com/d/optout.


Re: [racket-users] sxml pkg install

2017-01-03 Thread Ben Greenman
Run `raco pkg install sxml` and use `(require sxml)`.

On Tue, Jan 3, 2017 at 1:54 PM, Robert Kirkpatrick <
robert.kirkpatrick...@gmail.com> wrote:

> Newbie question:
> I can't find a way to install a sxml pkg (require (planet sxml))
> TIA,
> Robert.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> 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] Dynamically generated keywords -- are they possible?

2017-01-09 Thread Ben Greenman
You can use it with keyword-apply

(define (foo #:x x) (+ x 3))
(keyword-apply foo (list (string->keyword "x")) (list 8) '())
;; ==> 11

http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29

On Mon, Jan 9, 2017 at 12:47 PM, David Storrs 
wrote:

> What should string->keyword be used for?  I was expecting this to work
> but it does not:
>
> (define (foo #:x x) (+ x 3))
>
> (foo (string->keyword "x") 8)
>
> ; foo: arity mismatch;
> ;  the expected number of arguments does not match the given number
> ;   expected: 0 plus an argument with keyword #:x
> ;   given: 2
> ; [,bt for context]
>
>
> I know I can do this with a macro, but I was hoping it could happen
> more straightforwardly at runtime.
>
> --
> 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] Re: Stickers!

2017-03-28 Thread Ben Greenman
Sure. What's your mailing address?

On Tue, Mar 28, 2017 at 4:55 AM, Adeoluwa Adejumo <adejumoadeol...@gmail.com
> wrote:

> On Tuesday, 24 January 2017 22:15:59 UTC+1, Ben Greenman  wrote:
> > Hi Racket Users,
> >
> >
> > I ordered a bunch of Racket stickers to celebrate the 6.8 release.
> Here's proof:
> > http://www.ccs.neu.edu/home/types/resources/stickers.jpg
> >
> >
> >
> > If you send me your address, I will mail you some stickers. For free!*
> >
> >
> > I'm thinking 4 stickers per request (2 rectangles, 2 circles), but if
> you live outside the US and promise to serve as a "volunteer regional
> sticker distributor" then I'll send more.**
> >
> >
> >
> > Peace, Love, and Racket,
> > Ben
> >
> >
> >
> >
> > * While supplies last. And if you want un-free stickers, you can make
> your own on stickermule.com or send a donation to RacketCon 2017.
> >
> >
> > ** While supplies last, and subject to the internal dimensions of the
> cheapest padded envelope at my local US post office.
>
> hello, are the free stickers still available?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> 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] change 'random' contract to allow zero in first position?

2017-03-03 Thread Ben Greenman
https://github.com/racket/racket/pull/1626

-- 
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 t-shirts and stickers on DevSwag

2017-03-08 Thread Ben Greenman
Racket stickers and t-shirts are now on devswag.com

- https://devswag.com/products/racket
- https://devswag.com/products/racket-t-shirt

Looking for a last-minute St Patrick's Day gift?
Or a Fathers' Day gift for the Racketeer that has it all?
Then LOOK NO FURTHER!

(Half the proceeds from stickers and t-shirts go back to Racket.)

-- 
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] defstruct* fails for a (long long long) long struct name

2017-03-11 Thread Ben Greenman
Adding a field also fixes the problem:

#lang scribble/manual

@require[@for-label[racket]]

@defstruct*[(abcdefghijklmnopqrstuvwxyzABCDEEFGHIJKLMNOPQRSTUVWX-Z ABCD)
([hi integer?])]{}



and the problem has to do with how `defstruct*` renders the first line of a
struct declaration. If the struct name and first field's name are short
enough, it renders both on the same line. When they're* too long, it
renders the first field name on a new line --- and assumes the struct has
at least one field.

This is a bug. Once it's fixed, you'll be able to document the long names
correctly.

* "They" = the struct's name + the first field's name (if present) + some
padding

On Sat, Mar 11, 2017 at 5:36 PM, Carlos Lopez  wrote:

> Hi,
>
> While writing some documentation in scribble, I've discovered that using
> defstruct with really long names gives an error:
>
> the following code fails:
>
> #lang scribble/manual
>
> @require[@for-label[racket]]
>
> @defstruct*[(abcdefghijklmnopqrstuvwxyzABCDEEFGHIJKLMNOPQRSTUVWX-Z ABCD)
> ()]{}
>
>
> yet removing a character in either the long string or in ABCD makes it
> work.
>
> Dr. Racket provides a stacktrace but I'm unable to understand what the
> issue is.
>
> I'd like to understand what kind of limit is being broken.
>
> best,
> carlos
>
> --
> 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] Typed Racket: Polymorphic function `dynamic-wind' could not be applied to arguments

2017-03-06 Thread Ben Greenman
On Mon, Mar 6, 2017 at 1:18 AM, kay  wrote:

> Looks like it might be worth mentioning somewhere in the documentation


Good idea, what do you think of this change:
https://github.com/racket/typed-racket/pull/508

-- 
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] range with small or zero step doesn't return

2017-04-17 Thread Ben Greenman
Maybe, just add a note to the docs?

On Mon, Apr 17, 2017 at 4:56 PM, Vincent St-Amour <
stamo...@eecs.northwestern.edu> wrote:

> The latter is easy to fix; I've submitted a pull request.
>
> The former is trickier. The problem is not so much due to the step size
> itself, but rather to a combination of the step size and of a particular
> iteration state.
>
> (For people following along, the issue is that there exists a value `x`
> such that `(= (+ x 1e-17) x)`, and that the iteration reaches that `x`
> as its state at some point, then loops.)
>
> Guarding against that would require an additional check at each
> iteration, which may introduce overhead.
>
> I did some very, very crude benchmarking, and here's what I got:
>
> Without extra check:
> > (time (for ([i (in-range 100)]) i))
> cpu time: 19478 real time: 19469 gc time: 0
> > (time (for ([i (in-range 100)]) i))
> cpu time: 20171 real time: 20179 gc time: 0
> > (time (for ([i (in-range 100)]) i))
> cpu time: 20049 real time: 20043 gc time: 0
>
> With extra check:
> > (time (for ([i (in-range 100)]) i))
> cpu time: 22100 real time: 22210 gc time: 0
> > (time (for ([i (in-range 100)]) i))
> cpu time: 7 real time: 22265 gc time: 0
> > (time (for ([i (in-range 100)]) i))
> cpu time: 21934 real time: 22016 gc time: 0
>
> The difference is non-insignificant. Admittedly, this is the worst
> possible case, though.
>
> Vincent
>
>
>
> On Mon, 17 Apr 2017 09:17:32 -0500,
> Tim Jervis wrote:
> >
> > Dear Racket Users,
> >
> > I’ve noticed the following procedure calls don’t return (on my 64 bit
> Mac hardware):
> >
> > 1 (range (- 1 1e-16) 1.0 1e-17)
> > 2 (range 0 1 0)
> >
> > While (2) is obvious, (1) tripped me up (as I hadn’t noticed my step
> size had fallen to effectively zero).
> >
> > A small tweak to for.rkt in the racket distribution could trap the
> condition of an actually or effectively zero step. for.rkt already traps
> the condition where step is not real.
> >
> > If this makes sense, could one of the authors consider adding the tweak?
> Or is there a reason for leaving it alone?
> >
> > Kind regards,
> >
> > Tim
> >
> > Tim Jervis
> >
> > http://timjervis.com/
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > 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.
>

-- 
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] Running a program in multiple languages at once

2017-08-13 Thread Ben Greenman
One idea:
- write your program just like that, `1 + 2` with no #lang line,
- run your program with a raco command that runs the program once for each
language

Something like `raco mystery-lang -L lang1 -L lang2 -L lang3 file.txt`


In case you need an example raco-command:
https://github.com/AlexKnauth/syntax-sloc/blob/master/syntax-sloc/info.rkt

On Sat, Aug 12, 2017 at 7:45 PM, Sam Waxman  wrote:

> Hello,
>
> Let's say I have a program the user entered that just looks like
>
>
> 1 + 2
>
>
> and I have three different #langs, all with different parsers and
> different notions of addition, for which this is a valid program. I'm
> looking to make it so that this program outputs the following:
>
> "Output for language 1:
>  
>
> Output for language 2:
>  
>
> Output for language 3:
>  
> "
>
> Is there any simple way to do this?
>
> --
> 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] ?

2017-07-16 Thread Ben Greenman
Maybe related:
https://groups.google.com/forum/#!topic/racket-users/6fKGky4tud8

On Sun, Jul 16, 2017 at 8:26 AM, Philip McGrath 
wrote:

> Could you share the code that is producing the error? The following, for
> example, defines a struct with two fields:
>
> (struct point (x y))
>
> -Philip
>
> On Sun, Jul 16, 2017 at 7:23 AM, Masto Fine 
> wrote:
>
>> i have a problem , i want to define a structure white many fields in the
>> definition screen and the computer say me : "excpected nothing after the
>> field name but found one extra part",cannot i program a function whit more
>> than one part?
>> bonjour , j'ai un probleme avec la creation de definitions , j'essaye de
>> probgramme une strucure a plusieur champs ( une serie de lignes ) et le
>> logiciel me repond toujours expected nothing after the field name but found
>> one extra part , quel est le probleme ?
>>
>> --
>> 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.
>

-- 
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] Scribble: tables and figures with captions and numbering?

2017-07-06 Thread Ben Greenman
You can assign numbered captions to figures with `figure` from
`scriblib/figure` (and reference them with `figure-ref`).
http://docs.racket-lang.org/scriblib/figure.html

I don't know how to caption tables or number equations in Scribble.

On Thu, Jul 6, 2017 at 7:50 AM, Dmitry Pavlov  wrote:

> Hello,
>
> I have zero experience with Scribble, and today I have been considering
> using it to document a program.
> Previously, I have been using LaTeX, Markdown, and Word.
>
> One of the first questions that comes to mind is: can I assign captions to
> tables (rendered above the table) and figures (rendered below the figure)?
> Can I attach numbers to them, like "Table 1.  caption>" and reference that table by number in the text?
>
> I understand that since Scribble is programmable, I can work out my own
> procedures for rendering and numbering, but I am looking for a more
> "Scribble-native" way so that the connection between an object and its
> caption will not be lost after conversion to Markdown or LaTeX.
>
> Also, can I number the scribble-math equations with a number rendered to
> the right from the equation, and reference them, too?
>
> Best regards,
>
> Dmitry
>
> P.S. If I am wanting something that is counter-Racket
> counter-literate-programming old-fashioned boring bureaucracy, please feel
> free to let me know.
>
> --
> 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] Scribble PDF output breaks when using include-section with scribble/lp2

2017-07-14 Thread Ben Greenman
>
> Especially oddly, running scribble with --latex and then manually making
> the PDF works, except that the table of contents is blank.
>

Check if it works when you make the PDF twice.

This sounds like it's trouble resolving cross references.
Maybe there's a bad character in a label [1], maybe you need to make sure
hyperref is not loaded before certain packages, maybe something else.

[1]
https://tex.stackexchange.com/questions/18311/what-are-the-valid-names-as-labels

-- 
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] Example of file i/o?

2017-07-18 Thread Ben Greenman
(with-input-from-file "file.txt"
  (lambda ()
(for ((line (in-lines)))
  )))

On Tue, Jul 18, 2017 at 12:46 PM, Leith  wrote:

> Basic question, but I can't seem to find a good answer.  What is an
> example of "idiomatic" file I/O using racket?  Like, for example, open a
> file for reading and do something with every line in the file?
>
> The example here: https://docs.racket-lang.org/guide/io-patterns.html
> says "If you want to process individual lines of a file" but then it
> doesn't open a file at all.  It uses open-input-string.  I'm guessing it
> would be sufficient to use open-input-file instead?  Also, what is the
> right way to read a line at a time until EOF?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Ben Greenman
3 hints:
- `type-check` can call any helper functions defined with
`define-for-syntax`
- Turnstile uses `local-expand` to expand any macros in subterms (in your
case, any macros in `x` and `y`)
- start using `syntax-parse` :)

On Tue, Jul 18, 2017 at 6:11 PM, Matthias Felleisen 
wrote:

>
> Take a look at the Turnstile package, its documentation, and the paper
> that comes with it (http://www.ccs.neu.edu/racket/pubs/#popl17-ckg).
>
>
> > On Jul 18, 2017, at 5:37 PM, Sam Waxman  wrote:
> >
> > Hello,
> >
> > Suppose I'd like a type-checking macro that looks something like this:
> >
> > (define-syntax (type-check stx)
> >  (syntax-case stx ()
> >[(_ (+ x y))  (if (and (number? (type-check #'x))
> >   (number? (type-check #'y)))
> >  #'Number #'(error "bad types!"))]
> >[*cases for other expressions]))
> >
> > The macro will examine the syntax it's given and determine the type that
> will be produced at runtime.
> >
> > The key here is that type-check needs to call itself, but that's not
> possible. Type-check is defined to be used in phase 0, but the recursive
> call to type-check takes place in phase 1. If the recursive call to
> type-check makes a recursive-call, then this second call would be running
> in phase 2 and so on. The compiler won't allow me to use this macro in a
> phase it's not defined for, so this code is no good.
> >
> > So, first question: How can I get a macro to call itself recursively
> such as in this case? I can't wrap the entire if in a syntax object,
> because I want to throw that error in phase 1, so the condition of the if
> statement needs to be evaluated inside this macro.
> >
> > Second, even if I get type-check to work in all phases, if I call
> type-check with (+ 1 2), the recursive call to (type-check #'x) will get
> #'x as its "argument" instead of 1, no?
> >
> > It almost feels like I should be doing this with a regular old function
> that takes in syntax, and produces a type, but to my knowledge, I can't use
> ... in runtime expressions such as the following
> >
> > (define (type-check stx)
> >  (syntax-case stx ()
> >[(body) *dummy-value*]
> >[(body ...) (begin (type-check #'body) ...)]))
> >
> > This will result in a syntax-error telling me that ... can't be used as
> an expression like this, which makes it impossible to deal with ... forms.
> >
> > Any advice?
> >
> > Thanks in advance.
> >
> > --
> > 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.
>

-- 
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] A bug in the Typed Racket system?

2017-07-21 Thread Ben Greenman
Type inference is failing you again.

If you instantiate `foo/s`, you get the type you expect:

#lang typed/racket

(struct (a) Foo ([val : (-> a a)]))

(: foo/s (All (a b)
  (-> (-> a b)
  (-> (Foo a)
  (Foo b)
  (Foo b)
(define (foo/s f)
  (λ ([f1 : (Foo a)]
  [f2 : (Foo b)])
f2))


(define r1 (#{foo/s @ Integer String} (λ ([x : Integer]) (format "~a" x
;> r1
;- : (-> (Foo Integer) (Foo String) (Foo String))


I wouldn't call this a bug, but it's definitely a program that a better
type inferencer should accept.

On Fri, Jul 21, 2017 at 5:19 AM, Sourav Datta  wrote:

> Consider this program,
>
> #lang typed/racket
>
> (struct (a) Foo ([val : (-> a)]))
>
> (: foo/s (All (a b)
>   (-> (-> a b)
>   (-> (Foo a)
>   (Foo b)
>   (Foo b)
> (define (foo/s f)
>   (λ ([f1 : (Foo a)]
>   [f2 : (Foo b)])
> f2))
>
>
> (define r1 (foo/s (λ ([x : Integer]) (format "~a" x
>
> The type of r1 is correctly deduced as:
>
> - : (-> (Foo Integer) (Foo String) (Foo String))
> #
>
> However, if I slightly change the struct Foo and do the same, like this:
>
> #lang typed/racket
>
> (struct (a) Foo ([val : (-> a a)]))
>
> (: foo/s (All (a b)
>   (-> (-> a b)
>   (-> (Foo a)
>   (Foo b)
>   (Foo b)
> (define (foo/s f)
>   (λ ([f1 : (Foo a)]
>   [f2 : (Foo b)])
> f2))
>
>
> (define r1 (foo/s (λ ([x : Integer]) (format "~a" x
>
> Now, r1 has this type:
>
> - : (-> (Foo Nothing) (Foo String) (Foo String))
> #
>
> Surprisingly (Foo Integer) has changed to (Foo Nothing)! Is this a
> possible bug in the type system? Or, may be I'm missing something?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Racket7 Conceit

2017-07-19 Thread Ben Greenman
mflatt answered some "why"s on the racket-dev list:
https://groups.google.com/d/msg/racket-dev/2BV3ElyfF8Y/4RSd3XbECAAJ

On Thu, Jul 20, 2017 at 12:34 AM, Lehi Toskin  wrote:

> I've read through a few README's in the racket7 repo and I can't find
> anything specifically about *why* Racket is being implemented on top of
> Chez Scheme, so I suppose I'll be asking here:
>
> Why the rewrite in the first place? Is it because C is ugly and yucky and
> poopy? Why Chez Scheme and not, say, Chicken Scheme or GNU Guile?
>
> --
> 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] Proper non-tail recursion?

2017-04-28 Thread Ben Greenman
On Fri, Apr 28, 2017 at 11:08 AM, Daniel Bastos  wrote:

> interview done with Guido van Rossum


http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html


Related:

lexical scope is interesting *theoretically*, but its inefficient to
> implement; dynamic scope is the fast choice


 http://www.paulgraham.com/thist.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.


Re: [racket-users] Proper non-tail recursion?

2017-04-28 Thread Ben Greenman
Right ... it's about "growable stack languages" or "infinite stack
languages" or "heapful languages" or something like that.

On Fri, Apr 28, 2017 at 11:29 AM, Matthias Felleisen <matth...@ccs.neu.edu>
wrote:

>
> > On Apr 28, 2017, at 11:12 AM, Ben Greenman <benjaminlgreen...@gmail.com>
> wrote:
> >
> >
> > On Fri, Apr 28, 2017 at 11:08 AM, Daniel Bastos <dbas...@toledo.com>
> wrote:
> > interview done with Guido van Rossum
> >
> > http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html
>
>
> Guys, this conversation is really not about PITCH per se.

-- 
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] ANN: syntax-parse-example 0.0

2017-05-17 Thread Ben Greenman
The syntax-parse-example package is a showcase of useful macros written
using syntax-parse.
https://pkgs.racket-lang.org/package/syntax-parse-example

At the moment, the showcase is nearly empty ... but it's easy to contribute!

0. Design a beautiful macro, give it a name e.g. BOB
1. Run `raco pkg install --clone syntax-parse-example; cd
syntax-parse-example`
2. Run `raco syntax-parse-example --new BOB`. This generates a directory
and 3 files:
  - `BOB/BOB.rkt` : the macro goes here
  - `BOB/BOB-test.rkt` : for unit tests
  - `BOB/BOB.scrbl` : for documentation
3. Fill in the blanks in the new files, add `BOB` to the top-level file
`index.scrbl`.


Then, if you run `raco setup syntax-parse-example` it will render your
documentation on the page for the `syntax-parse-example` module.

- - -

Example doc:
http://docs.racket-lang.org/syntax-parse-example/index.html?q=syntax-parse-example#%28part._first-class-or%29

The doc's source:
https://github.com/bennn/syntax-parse-example/blob/master/first-class-or/first-class-or.scrbl

-- 
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] Is it possible with Scrible's @hyperlink, to open the linked document in a new webpage?

2017-06-21 Thread Ben Greenman
#lang scribble/manual
@require[
  (only-in scribble/core style)
  (only-in scribble/html-properties attributes)]

@(define new-window-style
   (style #f (list (attributes '((target . "_blank"))

@hyperlink[#:style new-window-style "https://www.racket-lang.org"]{Racket}


On Tue, Jun 20, 2017 at 7:27 PM, E. Cómer  wrote:

> Hi friends:
>
> Could someone share a way to use @hyperlink of the Scribble/manual
> language, in order to open the linked document in a new webpage or window
> (instead of using the current scribble document page)?
>
> Thank you very much in advance, and congratulations for constantly
> improving the environment and functionality of the Racket language.
>
> Sincerely,
> E. Cómer
>
> --
> 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] immutable hash table performance

2017-05-25 Thread Ben Greenman
Is the y-axis on the first plot labeled correctly? It's reporting fractions
of a millisecond, but the text talks about 7 vs. 40 seconds.

Also the timings links aren't working for me:
https://www.brinckerhoff.org/img/hash-table-timings.rkt
https://www.brinckerhoff.org/img/hash-table-lookup-timings.rkt

On Thu, May 25, 2017 at 6:16 PM, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> Following up on a discussion I had with another teacher here, I decided to
> briefly investigate the running time of insertion and deletion on mutable
> vs immutable hash tables. I was a bit disappointed to find that it turns
> out that insertion really doesn’t look very constant-time for insertion… or
> for lookup, actually. I drew some pictures: tell me what you think!
>
> https://www.brinckerhoff.org/blog/2017/05/25/hash-table-timings/
>
> John
>
> (praise and adulation, as always, to Messrs. Butterick and Hendershott for
> pollen & frog, respectively)
>
> --
> 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] How to discard an unknown number of (values) return?

2017-05-16 Thread Ben Greenman
Try `(call-with-values func void)`

http://docs.racket-lang.org/reference/values.html#%28def._%28%28quote._~23~25kernel%29._call-with-values%29%29

On Tue, May 16, 2017 at 5:56 PM, David Storrs 
wrote:

> I have a macro that wraps a function call in some debugging information.
> I would like to discard the results of the function call so that they don't
> end up printed.  This usually works:
>
>   (void (func))
>
> ...but it fails if func uses (values) to return multiple values, since
> void is variadic but not multiple-return tolerant.  I have solved the
> problem with (the equivalent of) wrapping it in a thunk:  ((thunk (func)
> (void)) but that's clumsy.
>
> This is a specific example of the more general question "how could I
> capture the result of a function call without knowing how many values will
> come back or if it's normal return / multiple return?"
>
> I've been through the docs on multiple return and I don't see a way to
> handle this.  Is there one?
>
> --
> 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] Re: Stickers!

2017-06-08 Thread Ben Greenman
Sure, two options:

1. if you send me your address, I will send a few stickers

2. you can now get stickers and t-shirts through devswag.com:
https://devswag.com/products/racket
https://devswag.com/products/racket-t-shirt


On Thu, Jun 8, 2017 at 5:07 AM, Alexandre Kahn <alexandrekahn...@gmail.com>
wrote:

> On Tuesday, January 24, 2017 at 10:15:59 PM UTC+1, Ben Greenman wrote:
> > Hi Racket Users,
> >
> >
> > I ordered a bunch of Racket stickers to celebrate the 6.8 release.
> Here's proof:
> > http://www.ccs.neu.edu/home/types/resources/stickers.jpg
> >
> >
> >
> > If you send me your address, I will mail you some stickers. For free!*
> >
> >
> > I'm thinking 4 stickers per request (2 rectangles, 2 circles), but if
> you live outside the US and promise to serve as a "volunteer regional
> sticker distributor" then I'll send more.**
> >
> >
> >
> > Peace, Love, and Racket,
> > Ben
> >
> >
> >
> >
> > * While supplies last. And if you want un-free stickers, you can make
> your own on stickermule.com or send a donation to RacketCon 2017.
> >
> >
> > ** While supplies last, and subject to the internal dimensions of the
> cheapest padded envelope at my local US post office.
>
> Hi Ben.
>
> At our University (VUB) we learn to code in racket, if you still have some
> stickers it would be very cool!
> Thanks a lot,
> Alexandre Kahn
>
> --
> 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] Help needed to fix type error

2017-06-05 Thread Ben Greenman
Maybe the issue is line 52 of math/private/distributions/utils (it seems
like a typo to me)

(define-type type-name (struct-name Real Flonum))


I think this means that the type Discrete-Uniform-Dist is really
(discrete-uniform-dist-struct Real Flonum).

Anyway, if I change the return typed of discrete-uniform to
(discrete-uniform-dist-struct Real Integer) then your code type-checks.

-- 
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] Wanted: Easier way to contribute docs

2017-06-13 Thread Ben Greenman
>
> This is a nice idea, though possibly complicated to implement (AFAICT it
> would require annotating the HTML of a given part of the documentation with
> a reference to the source code that originally generated it, and in a way
> that can be generalized to every Racket project, not just the ones in the
> main `racket` repo.)


I think the way to generalize is to add an `info.rkt` field for the
project's source. Could be GitHub, could be another website.

-- 
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] Function contract that cares only about the return value?

2017-06-13 Thread Ben Greenman
unconstrained-domain->

http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._unconstrained-domain-~3e%29%29


On Tue, Jun 13, 2017 at 11:24 AM, David Storrs 
wrote:

> Suppose the following trivial function:
>
> (define/contract (foo func)
>   (-> (-> any/c ... any/c) #t)
>   #t)
>
> This is trying (and failing) to express the idea "foo takes a processor
> function.  I don't care what arguments the processor requires (that's the
> caller's job) but the processor must return a singular result."
>
> What would be the correct contract for foo?  I've been through the section
> on function contracts; the above was my first guess but this fails:
>
> (foo identity)
> ; foo: contract violation
> ;   expected: a procedure that accepts 0 non-keyword arguments and
> arbitrarily
> ; many more
> ;   given: #
> ;   identity accepts: 1 argument
> ;   in: the 1st argument of
> ;   (-> (-> any/c ... any/c) #t)
> ;   contract from: (function foo)
> ;   blaming: top-level
> ;(assuming the contract is correct)
> ;   at: readline-input:8.18
> ; [,bt for context]
> ->
>
>
> I also tried this, which apparently isn't even legal syntax:
>
> (define/contract (foo func)
>   (-> (-> any any/c) #t)
>   #t)
> ; readline-input:10:33: any: use of 'any' outside the range of an arrow
> ;   contract
> ;   in: any
> ; [,bt for context]
>
>
>
> --
> 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] Self evaluating Racket Interpreter

2017-05-01 Thread Ben Greenman
'(1 2 3) is short for (list 1 2 3)
which is short for (cons 1 (cons 2 (cons 3 null))
which is different from (mcons 1 (mcons 2 (mcons 3 null)))

I hope this helps


On Mon, May 1, 2017 at 1:03 PM,  wrote:

> I posted this question on stackoverflow but have not found an answer yet.
> https://stackoverflow.com/questions/43476080/self-
> evaluting-racket-interpreter
>
> I've been trying to write a Racket interpreter that can interpret itself.
>
> interpreter.rkt contains the code for the interpreter. It is pretty
> standard. Then, in interpreter-self-evaluate.rkt, I
> 1. import interpreter.rkt,
> 2. copy paste the code from interpreter.rkt and
> 3. evaluate the code using the eeval function defined in
> interpreter.rkt.
>
> However, this returns an error "; mcdr: contract violation". I suspect
> that the problem is in interpreter-self-evaluate.rkt and that it might have
> something to do with how quote works. I might be completely off base
> though. Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+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] Apropos contracts: simple predicates and switching on and off

2017-05-02 Thread Ben Greenman
On Tue, May 2, 2017 at 11:43 PM, Daniel Prager 
wrote:

> I kind of expected that it would be possible to do what I wanted with
> "indy" contracts, but struggled with the heavy use of combinators in the
> examples.


Two offhand thoughts:

1. To practice with dependent contracts, I made a "full" spec for the
JavaScript left-pad function.
https://www.npmjs.com/package/left-pad

The exercise was fun, I learned a lot, and I think my solution is "as
readable as possible" :) .
https://github.com/bennn/racket-left-pad


2. "Oh Lord, Don't Let Contracts be Misunderstood" implements a little DSL
on top of ->i contracts: http://www.ccs.neu.edu/racket/pubs/icfp16-dnff.pdf

-- 
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] Apropos contracts: simple predicates and switching on and off

2017-05-04 Thread Ben Greenman
On Thu, May 4, 2017 at 8:23 PM, Dupéron Georges  wrote:

> In these cases, instead of turning off the contract checks altogether, it
> would be nice to have a way to disable the define/contract and turn it into
> a contract-out, using a single parameter (perhaps a per-file syntax
> parameter?).
>
> I'm not sure what would be the best syntax and implementation strategy for
> this, though.
>

With a `define/contract-out` macro?

But I'd rather not have a macro like this in the contract library.
I prefer reading code with all the "provide" statements at the top of the
file.

-- 
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] Built-in way to list all children of a directory?

2017-06-27 Thread Ben Greenman
The predicate can be any function.

All files: `(find-files (lambda (x) #true) start-path)`
All pdf files: `(find-files (lambda (x) (equal? #".pdf" (path-get-extension
x))) some-path)`

There's also the `file/glob` module.
All pdf files: `(glob (build-path some-path "**" "*.pdf"))`
Iterator for all files: `(in-glob (build-path some-path "**"))`

On Tue, Jun 27, 2017 at 10:17 PM, Glenn Hoetker  wrote:

> Struggling as a newbie with the documentation for find-files. In
> particular, the "predicate" part of
>
> (find-files
> predicate
>  [  start-path]
> #:skip-filtered-directory? skip-filtered-directory?
> #:follow-links? follow-links?)
>
> Can anyone offer a working example?  All file, all pdfs. Doesn't really
> matter. Just something concrete to get me started. Many thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [racket-users] Re: code reflection

2017-10-16 Thread Ben Greenman
> Greg, if you're reading this...any chance you might expand FoM?

In the meantime, the "Syntax Parse Examples" package is always
accepting contributions:
http://docs.racket-lang.org/syntax-parse-example/index.html#%28part._.The_.Examples%29

-- 
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] European Racketeers and conferences

2017-10-17 Thread Ben Greenman
Here's a map to some cities where some Racket users are located:

https://drive.google.com/open?id=1i3zN11e_6te5ytduAiv1cidrIi4=sharing

-- 
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] Redex v6.4 "broke" LambdaJS

2017-09-06 Thread Ben Greenman
I think it'll work if you delete the underscores, e.g. change "e_1" to "e1".

On Wed, Sep 6, 2017 at 2:22 PM,  wrote:

> (For some reason the mail I sent to usersracket-lang.org last week
> never made it to the Google Group, so I'm posting directly...)
>
> Hello,
>
> I'm a 2nd year PhD student working with Shriram Krishnamurthi on improving
> Redex's testing/checking performance and capabilities.
>
> I was looking to use LambdaJS (http://cs.brown.edu/research/
> plt/dl/jssem/v1/) as a case study, but unfortunately jscore.ss does not
> compile under the latest version of Redex.
>
> The shortcut used in the eval reduction relation
> ...
> with
>[(--> (σ (in-hole E e_1)) (σ (in-hole E e_2)))
> (==> e_1 e_2)]))
> now throws an error "reduction-relation: shortcut name may not be a
> non-terminal in: e_1."
>
> I believe this was caused by the following change (
> https://github.com/racket/redex/blob/master/redex-lib/redex/HISTORY.txt)
> in Redex v6.4:
>
> changed shortcuts in --> so that non-terminals are no
> longer allowed for the names in the shortcut "parameters"
> These shortcut names were never constrained to actually be
> non-terminals, so this change is intended entirely to be
> able to give a helpful error message in an attempt to avoid
> confusion
>
> As a Redex novice, I'm failing to avoid confusion in this case. Any advice
> on a simple way to change the shortcut / reduction relation to respect this
> change in Redex is greatly appreciated.
>
> Thanks for the help!
>
> --
> 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] repeated code in interactions of scribble

2017-09-23 Thread Ben Greenman
You can re-use helper functions by running the different example blocks
with the same evaluator (example below).

I don't know how to hyperlink one interaction to another.

- - -

#lang scribble/manual
@require[scribble/example]

@(define my-eval (make-base-eval))

Beginning.

@examples[#:eval my-eval
  (define (plus2 n)
(+ 2 n))
  (plus2 0)
  (plus2 1)
]

Intermission.

@examples[#:eval my-eval
  (define (plus4 n)
(plus2 (plus2 n)))
  (plus4 0)
]

Conclusion.

-- 
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] document as fn from strings to HTML/text

2017-09-28 Thread Ben Greenman
Yes, you can use scribble/html to define functions from lists to documents.

For example, this scribble file calls a function to build an ` ... `
page:
https://github.com/nuprl/gtp/blob/gh-pages/about.rkt

and here's the function:
https://github.com/nuprl/gtp/blob/gh-pages/templates.rkt#L124

-- 
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] scribble newbie, myfunctionname undefined

2017-09-28 Thread Ben Greenman
Try adding `#:eval foo-eval` to `interaction`. (I'm guessing that would
work.)


I'm more sure this will work:

  #lang scribble/manual
  @(require scribble/example "../main.rkt")
  ...
  @(define foo-eval (make-base-eval '(require "../main.rkt")))
  @examples[#:eval foo-eval #:label #f
  (magic)
  ]

-- 
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 documentation formats

2017-09-29 Thread Ben Greenman
You can download PDFs for most of the documentation here:
http://download.racket-lang.org/all-versions.html

And if your device has Racket installed, you can run `raco docs` to view a
local copy of the 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.


Re: [racket-users] Fwd: Racket Con

2017-10-05 Thread Ben Greenman
I have 1 mug (unused) that still needs a home.

On Thu, Oct 5, 2017 at 3:18 PM, 'John Clements' via users-redirect <
us...@plt-scheme.org> wrote:

> Forwarded without comment… :)
>
> Begin forwarded message:
>
> *From: *Jasmine Harihar Patel 
> *Subject: **Racket Con*
> *Date: *October 5, 2017 at 11:54:02 AM PDT
> *To: *"John B. Clements" 
>
> Dear Professor Clements,
>
>
> My name is Jasmine and I am a 2nd year CSC student. I heard that you were
> going to Racket Con tomorrow and was wondering if there is any way I could
> get one of those cool heat sensitive mugs (only if it is no trouble).
>
>
> Thanks,
>
> Jasmine Patel
>
>
> --
> 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] European Racketeers and conferences

2017-10-17 Thread Ben Greenman
I just changed the map settings so anyone can edit it.

If you'd like to add your city to the map:

1. Look for "racketeers.csv" in the menu
2. Click the "vertical dots" to the right of "racketeers.csv". (If you
hover the mouse over these dots, it should say "Layer Options")
3. Click "Open Data Table"
4. Right-click any row, choose "Add Row"
5. Add yourself, hit enter

Here's the link again:
https://drive.google.com/open?id=1i3zN11e_6te5ytduAiv1cidrIi4=sharing

-- 
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] Include Documentation from a scribble/lp2 File: "identifier `doc' not included [...]" Error

2017-11-29 Thread Ben Greenman
Try changing the include-section to import the `doc` submodule:

@include-section[(submod "sub-scribble.rkt" doc)


I got this idea from the 2nd paragraph of the "scribble/lp2 language" docs:
http://docs.racket-lang.org/scribble/lp.html#%28mod-path._scribble%2Flp2%29


On Wed, Nov 29, 2017 at 7:15 AM, Christian <7enderh...@gmail.com> wrote:
> overview.scrbl:
> #lang scribble/base
> @include-section["sub-scribble.rkt"]
>
> sub-scribble.rkt:
> #lang scribble/lp2
> @title{Sub Scribble!}
> Oh yeah.
> @chunk[<*>]
>
> gives:
> only-in: identifier `doc' not included in nested require spec in:
> "sub-scribble.rkt"
>
> * What to do to include the documentation part from a scribble/lp2 file?
>
> Thanks,
> Christian
>
> --
> 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] Plot - Choosing the number of mesh lines independently from the number of samples

2017-11-29 Thread Ben Greenman
I don't think this is currently possible.

To implement this, I think the `for-2d-sample` loop here needs to change:
https://github.com/racket/plot/blob/master/plot-lib/plot/private/plot3d/surface.rkt#L28

(I guess there should be 2 loops, one to draw the surface and one to
draw the lines)

On Wed, Nov 29, 2017 at 8:30 AM, Marduk Bolaños  wrote:
> Dear all,
>
> Recently, I made a 3D plot with surface3d, but had to increase the
> number of samples from the default value in order to obtain a
> smooth surface. Unfortunately, this change also increased the
> number of mesh lines, which resulted in a very dark surface. The
> appearance improved by painting the lines with a lighter color,
> but what I would really like to do is to choose the number of
> mesh lines that are drawn on the high-sample smooth surface.
>
> Is it currently possible? And if not, what would you suggest in
> order to implement it?
>
> Thanks in advance.
>
> Best,
> Marduk
>
> --
> 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] or/c, parametric->/c, and contract-first-order-passes?

2017-11-28 Thread Ben Greenman
The other day, I wanted to write a contract for a function that takes
any kind of vector and does something depending on whether the vector
is mutable. The contract was basically the one below:

```
#lang racket

(define/contract (f v)
  (parametric->/c [A]
(-> (or/c (vectorof A #:immutable #true)
  (vectorof A #:immutable #false))
any))
  (void))
```

When I try to call this function, I get an error "none of the branches
of the or/c matched".

It looks like this error is because `contract-first-order-passes?`
returns #false if the vector I pass to `f` has any elements.

Two questions:

1. Could `(contract-first-order-passes? ctc val)` return `#true` if
`ctc` is from a `parametric->/c` ? (I feel like it shouldn't but I
don't know why not)

2. If not, would `or/c` be better off using a
`contract-first-order-fails?` predicate?

-- 
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] Include Documentation from a scribble/lp2 File: "identifier `doc' not included [...]" Error

2017-11-29 Thread Ben Greenman
> * Would have never been able to deduce this from the info you referenced...

Good point. Here's a pull request for changing the docs:
https://github.com/racket/scribble/pull/154

-- 
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] misterious empty line

2017-11-26 Thread Ben Greenman
My guess is that "(define" does something special to figure out where to
insert newlines in the rendered document.

On Thu, Nov 23, 2017 at 9:13 AM, Jos Koot  wrote:

> My code:
>
> #lang scribble/manual
>
> @(require
>   scribble/core
>   scribble/eval
>   racket
>   (for-label racket)
>   (for-syntax racket))
>
> @elemtag["rearrangement" "Not important."]
> @interaction[
> (require racket)
> (code:comment #,(list "Procedure " (racket in-permutations)
>  " produces a sequence of " @elemref["rearrangement" "rearrangements"]
> "."))
> (define (a)
>  (code:comment #,(list "Procedure " (racket in-permutations)
>  " produces a sequence of " @elemref["rearrangement" "rearrangements"]
> "."))
>  (in-permutations '(1 2 3)))
> (a)]
>
> Produces the attached HTML.
>
> Why is there a blank line following the comment within the definition?
> The blank line does not appear after the comment preceding the definition.
>
> Windows 7 Home Premium,
> DrRacket, version 6.11.0.2--2017-11-12(b54ea8c5b1/a) [3m].
> Language: scribble/manual [custom]; memory limit: 4000 MB.
>
> Thanks, Jos
>
>
> --
> 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] Advantage of ->d over ->i

2017-12-01 Thread Ben Greenman
Let me make sure I understand:

1. A converter is like a two-way function, lets say (A . <-> . B)
2. If someone composes two incompatible converters, like (integer? .
<-> . symbol?) and (string? . <-> . boolean?) then they should get an
error that points to the place where they tried to do the composing.

It looks like the code above is using the contract on
`compose-converters` to meet goal #2.
Is that all right?


Anyway, I think the contract for `compose-converters` should ONLY try
to make sure `compose-converters` is doing the right thing. Something
like:

```
(define/contract (compose-converters g f)
  (parametric->/c [A B C]
(-> (B . <-> . C)
(A . <-> . B)
(A . <-> . C)))
  )
```

Then the `...` should try to meet goal #2 by putting a stronger
contract on one of the converters (using something like
`define/contract`).


I don't think ->d is a good answer because I don't think a dependent
contract on "compose" is a good answer -- it's doing too many things
at once.

[[ Now I'm thinking the docs should make ->d even harder to find ...
every time I ever thought that I wanted ->d, I was better off making a
new contract combinator and using it with -> or something. ]]

-- 
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] Raising arbitrary errors in Typed Racket

2017-12-01 Thread Ben Greenman
The error is because type signature of `raise` doesn't allow
"non-flat" values like functions and mutable vectors.

It might not be safe to allow `(raise (vector 1 2 3))` in Typed Racket
... I'm not sure.

For now I think you should make a new exception type. Example:

```
#lang typed/racket/base

(define-type Packable (U Byte (Vectorof Packable)))

(struct exn:fail:rpc exn ((val : Packable)))

(with-handlers ((exn:fail:rpc? exn:fail:rpc-val))
  (raise (exn:fail:rpc "oops" (current-continuation-marks) (vector 1 2 3
```

On Fri, Dec 1, 2017 at 9:05 AM, HiPhish  wrote:
> Hello Racketeers,
>
> I have been trying to port a module over to Typed Racket, and I have almost
> succeeded except for one issue: raising an arbitrary object as an error.
> Compare the following code:
>
> ;; Works fine
> (raise 3)
>
> ;; Does not work
> (raise (vector 1 2 3))
>
> The error I get is
> ; nvim-client/client.rkt:244:55: Type Checker: No function domains
> matched in
> ;   function application:
> ; Domains: (U (Rec flat (U (Pairof flat flat) Boolean Char Complex
> Keyword Null
> ;   String Symbol)) exn) Any
> ;  (U (Rec flat (U (Pairof flat flat) Boolean Char Complex
> Keyword Null
> ;String Symbol)) exn)
> ; Arguments: (U (Immutable-HashTable Packable Packable)
> (Mutable-HashTable
> ;   Packable Packable) (Pairof Packable (Listof Packable))
> (Weak-HashTable
> ;   Packable Packable) Boolean Bytes Ext Message-Args Null Real String)
> ;   in: (raise error)
> ; [,bt for context]
>
> So I looked up the signature of `raise` and I get this:
>
> > raise
> - : (->* ((U (Rec
>   flat
>   (U (Pairof flat flat)
>  Boolean
>  Char
>  Complex
>  Keyword
>  Null
>  String
>  Symbol))
>  exn))
>  (Any)
>  (Nothing : (Bot | Bot)))
> #
>
> So what does this mean and what should I do? I am porting a module from my
> Neovim client which uses the MessagePack-RPC protocol, and part of the
> protocol
> is that any object that can be packed can be raised as an error.
> https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md#error
>
> Raising any object as an error would have allowed someone making an RPC
> request
> to just do something like this:
>
> (with-handlers ([packable? (λ (exn) (display exn))])
>   (rpc-request "foo" '#(bar)))
>
> What should I do instead? Create a new error type like `exn:fail:rpc`? Or am
> I
> missing something here?
>
> --
> 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] Raising arbitrary errors in Typed Racket

2017-12-01 Thread Ben Greenman
That name sounds good to me.

-- 
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] Interaction of Typed Racket with define/match?

2017-11-17 Thread Ben Greenman
> Others: Does define/match do anything that would make Typed Racket see it
> differently from define + match*? It seems like define/match expands to
> define + match*/derived anyway. The only thing that's different is which
> define it's expanding to. So is expanding to Racket's define instead of TR's
> causing the problem?

I think so. It seems like Typed Racket is ignoring the type annotation
and trying to infer a type for the function body.

Here's a github issue for this:
https://github.com/racket/typed-racket/issues/653

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


  1   2   3   >