[racket-users] Re: Racket 6.4 very slow

2016-03-23 Thread vkelmenson via Racket Users
On Tuesday, March 1, 2016 at 8:51:58 PM UTC-7, vkelm...@aol.com wrote:
> I recently downloaded Racket version 6.4. I have previously been using 
> version 6.1. It is much slower than version 6.1. Several short functions run 
> approx 20 times slower on 6.4 than 6.1. These were run at the same time on 
> the sam matine in succession.
> I am using Mac osX version 10.8.5
>  Has anyone else noticed this?

Thanks everyone for your interest and suggestions. I have been away from a 
computer for a while. The problem is as Matthias says the debugging. In 
DrRacket 6.4 debugging is on by default. In my installation of 6.1 it is off by 
default. With debugging off on version 6.4 the difference between the 2 
installations on the same computer is approx. 1/10 of a second. Victor Kelmenson

-- 
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] Documentation or examples for handin-server?

2016-03-23 Thread 'William J. Bowman' via Racket Users
Once upon a time, I used the handin server for a course.
All the files I used are online.
It is not particularly well-documented, but may serve as reference code:
https://github.com/search?q=@wilbowma+cs2500=Repositories=searchresults

--
William J. Bowman

On Wed, Mar 23, 2016 at 02:07:42PM -0700, mauero...@gmail.com wrote:
> I am trying to set up handin-server with the Grading Utilities.
> 
> I have read the official documentation, but I must be missing several points 
> because even when I just copy the checker.rkt function from the documentation 
> it does not work. ("submit error: checker: undefined; cannot reference an 
> identifier before its definition ...")
> 
> I see from old posts on the Racket mailing list that there are ways to change 
> the language to BSL, but I can't find further information about it.
> 
> I am looking for more elaborate examples, or a pointer to further reading 
> that I have missed. 
> 
> Thanks.
> 
> Andrew Mauer-Oats
> Whitney Young Magnet High School
> 
> -- 
> 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.


pgpti8ZLaX0jd.pgp
Description: PGP signature


[racket-users] Documentation or examples for handin-server?

2016-03-23 Thread maueroats
I am trying to set up handin-server with the Grading Utilities.

I have read the official documentation, but I must be missing several points 
because even when I just copy the checker.rkt function from the documentation 
it does not work. ("submit error: checker: undefined; cannot reference an 
identifier before its definition ...")

I see from old posts on the Racket mailing list that there are ways to change 
the language to BSL, but I can't find further information about it.

I am looking for more elaborate examples, or a pointer to further reading that 
I have missed. 

Thanks.

Andrew Mauer-Oats
Whitney Young Magnet High School

-- 
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] Fwd: Us congress hearing of maan alsaan Money laundry قضية الكونغجرس لغسيل الأموال للمليادير معن الصانع

2016-03-23 Thread jami onn
YouTube videos of



 U.S. Congress money laundering hearing


of

Saudi Billionaire  " Maan  Al sanea"

 with *bank of America*


and  The  owner of Saad Hospital and  Schools

 in the Eastern Province in *Saudi Arabia*



and the Chairman of the Board of Directors of Awal Bank  in *Bahrain*


With Arabic Subtitles





*موقع اليوتيوب الذي عرض جلسة استماع الكونجرس الأمريكي *

* لمتابعة نشاطات غسل الأموال ونشاطات*



*السعودي معن عبدالواحد الصانع*



*مالك مستشفى  وشركة سعد  ومدارس سعد بالمنطقة الشرقية بالسعودية   ورئيس مجلس
ادارة بنك اوال البحريني*



*مترجم باللغة العربية*



http://www.youtube.com/watch?v=mIBNnQvhU8s

-- 
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: IO in racket is painful

2016-03-23 Thread Ty Coghlan
> I use racket for hackerrank and coding contests all the time, and I find it's 
> read syntax really useful. For instance, I would parse this into a list of 
> lists by doing 
> (for/list ([i (in-range (read))])
>   (map (lambda (x) (if (list? x) (cadr x) x)) (read))).
> 
> Then, to print out results, I normally do 
> (define (main n)
>   (unless (= 0 n)
> (begin (printf "~a ... ~a\n", args...)
>   (main (sub1 n.
> 
> Another really useful helper is 
> (define (read->list n)
>   (if (= 0 n) '()
> (cons (read) (read->list (sub1 n. 
> 
> You can customize these by doing for/vector, for/fold, etc., and there hasn't 
> been a hackerrank contest I've run into that I haven't been able to do with 
> some technique like this.

Correction, not "read syntax". My PL professor would fail me for that. I'd say 
that there are very few hackerrank and other contests input format that can't 
be parsed as an s-expression in some way (unless they do weird things with 
parentheses, in which case you have to use read-line/char/byte). 

Just note that a value with a comma in front of it is parsed as a list where 
the first item in the list is the unquote, and the second item is the value 
itself. Regardless, it's fairly easy to use the common list functions to 
extract the data you want.

-- 
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: IO in racket is painful

2016-03-23 Thread Ty Coghlan
On Wednesday, March 23, 2016 at 12:35:26 PM UTC-4, rom cgb wrote:
> Thanks all for the interesting replies. 
> 
> About using an external package, there also the case like on 
> www.hackerrank.com where you have to run the code in their own environment 
> (eg: http://i.imgur.com/iSSPLGy.png).

I use racket for hackerrank and coding contests all the time, and I find it's 
read syntax really useful. For instance, I would parse this into a list of 
lists by doing 
(for/list ([i (in-range (read))])
  (map (lambda (x) (if (list? x) (cadr x) x)) (read))).

Then, to print out results, I normally do 
(define (main n)
  (unless (= 0 n)
(begin (printf "~a ... ~a\n", args...)
  (main (sub1 n.

Another really useful helper is 
(define (read->list n)
  (if (= 0 n) '()
(cons (read) (read->list (sub1 n. 

You can customize these by doing for/vector, for/fold, etc., and there hasn't 
been a hackerrank contest I've run into that I haven't been able to do with 
some technique like 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.


Re: [racket-users] How to manage a Racket package within a Git repo?

2016-03-23 Thread Benjamin Greenman
Ok, that would help


On Wed, Mar 23, 2016 at 2:21 PM, Matthew Flatt  wrote:

> Are there other places where you looked that could also use a note?
>

Only pkgs.racket-lang.org, but I think the note in "getting started" should
be enough.

-- 
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 manage a Racket package within a Git repo?

2016-03-23 Thread Jay McCarthy
The documentation for package sources is here:

http://docs.racket-lang.org/pkg/Package_Concepts.html#%28part._concept~3asource%29

You want the fifth bullet, on Git repos.

Jay

On Wed, Mar 23, 2016 at 2:13 PM, Benjamin Greenman
 wrote:
> Thank you!
>
> Is this documented / is there a good place to add a note in the docs?
> (Maybe the package server should have an FAQ link, besides just linking to
> docs.racket-lang.org ?)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



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

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

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


Re: [racket-users] How to manage a Racket package within a Git repo?

2016-03-23 Thread Matthew Flatt
Although it's documented, I can add a note to

 http://docs.racket-lang.org/pkg/getting-started.html#%28part._github-deploy%29

which currently mentions branches but not subdirectories.

Are there other places where you looked that could also use a note?

At Wed, 23 Mar 2016 14:16:13 -0400, Jay McCarthy wrote:
> The documentation for package sources is here:
> 
> http://docs.racket-lang.org/pkg/Package_Concepts.html#%28part._concept~3asource
> %29
> 
> You want the fifth bullet, on Git repos.
> 
> Jay
> 
> On Wed, Mar 23, 2016 at 2:13 PM, Benjamin Greenman
>  wrote:
> > Thank you!
> >
> > Is this documented / is there a good place to add a note in the docs?
> > (Maybe the package server should have an FAQ link, besides just linking to
> > docs.racket-lang.org ?)
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> -- 
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> 
>"Wherefore, be not weary in well-doing,
>   for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>   - D 64:33

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


Re: [racket-users] How to manage a Racket package within a Git repo?

2016-03-23 Thread Benjamin Greenman
Great, thank you

-- 
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 manage a Racket package within a Git repo?

2016-03-23 Thread Benjamin Greenman
Thank you!

Is this documented / is there a good place to add a note in the docs?
(Maybe the package server should have an FAQ link, besides just linking to
docs.racket-lang.org ?)

-- 
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 manage a Racket package within a Git repo?

2016-03-23 Thread Matthew Flatt
Use

   https://github.com/bennn/foo.git?path=pkg

The "path=pkg" part specifies "pkg" within the repo.

At Wed, 23 Mar 2016 13:55:06 -0400, Benjamin Greenman wrote:
> I have a git repo that contains a Racket package. The repo also contains
> other folders related to the package. How do I share the package on
> pkgs.racket-lang.org without sharing (or just compiling/installing) the
> other folders?
> 
> 
> Say I ("bennn") own a repo "foo" with 2 folders, "pkg" and "other". I want
> to put "pkg" on pkgs.racket-lang.org.
> 
> - First, I tried changing the Source field of the package to reference "
> github.com/bennn/foo/tree/master/pkg". Seems no different from "
> github.com/bennn/foo".
> 
> - I do not want to move "other" to a new repo.
> 
> - My current solution is to put an info.rkt file at the top of my repo with:
> 
> #lang info
> 
> (define collection 'multi)
> 
> (define setup-collects '("pkg"))
> 
> (define compile-omit-paths '("other"))
> 
> Both setup-collects and compile-omit-paths are necessary, for getting `raco
> setup` and `raco pkg` to do the right thing. Is there a better 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.

-- 
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 manage a Racket package within a Git repo?

2016-03-23 Thread Benjamin Greenman
I have a git repo that contains a Racket package. The repo also contains
other folders related to the package. How do I share the package on
pkgs.racket-lang.org without sharing (or just compiling/installing) the
other folders?


Say I ("bennn") own a repo "foo" with 2 folders, "pkg" and "other". I want
to put "pkg" on pkgs.racket-lang.org.

- First, I tried changing the Source field of the package to reference "
github.com/bennn/foo/tree/master/pkg". Seems no different from "
github.com/bennn/foo".

- I do not want to move "other" to a new repo.

- My current solution is to put an info.rkt file at the top of my repo with:

#lang info

(define collection 'multi)

(define setup-collects '("pkg"))

(define compile-omit-paths '("other"))

Both setup-collects and compile-omit-paths are necessary, for getting `raco
setup` and `raco pkg` to do the right thing. Is there a better 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] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Robby Findler
Just parametricity. It's not clear how important that is here, tho, in
a world with stateful a->a functions.

Robby


On Wed, Mar 23, 2016 at 12:44 PM, Sam Tobin-Hochstadt
 wrote:
> We could certainly implement that, but I don't think we need to to
> enforce the invariants we want. If we think of type variables as
> supporting something analogous to SML's polymorphic equality, with ''a
> in the variables, then `equal?` is a reasonable operation to perform
> on them.
>
> Are there invariants you're thinking of that we would lose if `equal?`
> worked on these wrappers?
>
> Sam
>
> On Wed, Mar 23, 2016 at 1:26 PM, Robby Findler
>  wrote:
>> I was thinking that "dynamic parametricity" would imply that
>> prop:equal+hash should be functions that raise errors. And then the
>> question is: what does this break in our codebase?
>>
>> Robby
>>
>>
>> On Wed, Mar 23, 2016 at 10:54 AM, Sam Tobin-Hochstadt
>>  wrote:
>>> I think the struct implementing `parameteric->/c` could implement
>>> `prop:equal+hash` appropriately. That wouldn't allow them to compare
>>> equal to the unwrapped value, but it would make this program work.
>>>
>>> Sam
>>>
>>> On Wed, Mar 23, 2016 at 11:43 AM, Phil Nguyen  
>>> wrote:
 In the following program, `(p? 1 1)` returns `#t` or `#f` depending on 
 `p?` being called from the same or different module:

 #lang racket

 (module m racket
   (provide
 (contract-out
   [p? (parametric->/c (a) (a a . -> . boolean?))]))
   (define p? equal?)
   (p? 1 1))

 (require 'm)
 (p? 1 1)

 Module `m` is wrong in the first place for comparing 2 sealed objects, but 
 here we don't get an error. Is it practical to make `equal?` aware of 
 parametric contracts?

 This bit me in practice when I used a hashtable (which had an implicit 
 `equal?`). The worse part was that tests passed because they were in the 
 same module, and I only got unexpected behavior from outside.

 --
 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] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Sam Tobin-Hochstadt
We could certainly implement that, but I don't think we need to to
enforce the invariants we want. If we think of type variables as
supporting something analogous to SML's polymorphic equality, with ''a
in the variables, then `equal?` is a reasonable operation to perform
on them.

Are there invariants you're thinking of that we would lose if `equal?`
worked on these wrappers?

Sam

On Wed, Mar 23, 2016 at 1:26 PM, Robby Findler
 wrote:
> I was thinking that "dynamic parametricity" would imply that
> prop:equal+hash should be functions that raise errors. And then the
> question is: what does this break in our codebase?
>
> Robby
>
>
> On Wed, Mar 23, 2016 at 10:54 AM, Sam Tobin-Hochstadt
>  wrote:
>> I think the struct implementing `parameteric->/c` could implement
>> `prop:equal+hash` appropriately. That wouldn't allow them to compare
>> equal to the unwrapped value, but it would make this program work.
>>
>> Sam
>>
>> On Wed, Mar 23, 2016 at 11:43 AM, Phil Nguyen  
>> wrote:
>>> In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
>>> being called from the same or different module:
>>>
>>> #lang racket
>>>
>>> (module m racket
>>>   (provide
>>> (contract-out
>>>   [p? (parametric->/c (a) (a a . -> . boolean?))]))
>>>   (define p? equal?)
>>>   (p? 1 1))
>>>
>>> (require 'm)
>>> (p? 1 1)
>>>
>>> Module `m` is wrong in the first place for comparing 2 sealed objects, but 
>>> here we don't get an error. Is it practical to make `equal?` aware of 
>>> parametric contracts?
>>>
>>> This bit me in practice when I used a hashtable (which had an implicit 
>>> `equal?`). The worse part was that tests passed because they were in the 
>>> same module, and I only got unexpected behavior from outside.
>>>
>>> --
>>> 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] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Robby Findler
I was thinking that "dynamic parametricity" would imply that
prop:equal+hash should be functions that raise errors. And then the
question is: what does this break in our codebase?

Robby


On Wed, Mar 23, 2016 at 10:54 AM, Sam Tobin-Hochstadt
 wrote:
> I think the struct implementing `parameteric->/c` could implement
> `prop:equal+hash` appropriately. That wouldn't allow them to compare
> equal to the unwrapped value, but it would make this program work.
>
> Sam
>
> On Wed, Mar 23, 2016 at 11:43 AM, Phil Nguyen  
> wrote:
>> In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
>> being called from the same or different module:
>>
>> #lang racket
>>
>> (module m racket
>>   (provide
>> (contract-out
>>   [p? (parametric->/c (a) (a a . -> . boolean?))]))
>>   (define p? equal?)
>>   (p? 1 1))
>>
>> (require 'm)
>> (p? 1 1)
>>
>> Module `m` is wrong in the first place for comparing 2 sealed objects, but 
>> here we don't get an error. Is it practical to make `equal?` aware of 
>> parametric contracts?
>>
>> This bit me in practice when I used a hashtable (which had an implicit 
>> `equal?`). The worse part was that tests passed because they were in the 
>> same module, and I only got unexpected behavior from outside.
>>
>> --
>> 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] TR exhaustive match?

2016-03-23 Thread Sam Tobin-Hochstadt
Unfortunately, the implementation of `match` works in such a way that
figuring that out is beyond the capability of TR. For this specific
case, TR could know when a local binding of a function is
unreferenced, and thus the body is unreachable, but for more
complicated cases the expansion of `match` will be hard to figure out.

Sam

On Wed, Mar 23, 2016 at 12:57 PM, 'John Clements' via Racket Users
 wrote:
>
>> On Mar 23, 2016, at 9:48 AM, Sam Tobin-Hochstadt  
>> wrote:
>>
>> On Wed, Mar 23, 2016 at 12:47 PM, 'John Clements' via Racket Users
>>  wrote:
>>> Is there a way in TR to ensure that a match is exhaustive at type-checking 
>>> time? It seems to me like the right design would be a special TR form that 
>>> goes in expression positions and always signals a type error.
>>
>> Indeed, see `typecheck-fail`:
>> http://docs.racket-lang.org/ts-reference/Utilities.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29
>
> Nice! … Okay, now I just need help with ‘match’; is there a way to get 
> ‘match’ (or, more specifically, TR + the expansion of match) to deduce that 
> the last clause is unreachable in the example I presented?
>
> 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] TR exhaustive match?

2016-03-23 Thread 'John Clements' via Racket Users

> On Mar 23, 2016, at 9:48 AM, Sam Tobin-Hochstadt  wrote:
> 
> On Wed, Mar 23, 2016 at 12:47 PM, 'John Clements' via Racket Users
>  wrote:
>> Is there a way in TR to ensure that a match is exhaustive at type-checking 
>> time? It seems to me like the right design would be a special TR form that 
>> goes in expression positions and always signals a type error.
> 
> Indeed, see `typecheck-fail`:
> http://docs.racket-lang.org/ts-reference/Utilities.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29

Nice! … Okay, now I just need help with ‘match’; is there a way to get ‘match’ 
(or, more specifically, TR + the expansion of match) to deduce that the last 
clause is unreachable in the example I presented?

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.


Re: [racket-users] TR exhaustive match?

2016-03-23 Thread Sam Tobin-Hochstadt
On Wed, Mar 23, 2016 at 12:47 PM, 'John Clements' via Racket Users
 wrote:
> Is there a way in TR to ensure that a match is exhaustive at type-checking 
> time? It seems to me like the right design would be a special TR form that 
> goes in expression positions and always signals a type error.

Indeed, see `typecheck-fail`:
http://docs.racket-lang.org/ts-reference/Utilities.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29

Sam

-- 
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] TR exhaustive match?

2016-03-23 Thread 'John Clements' via Racket Users
Is there a way in TR to ensure that a match is exhaustive at type-checking 
time? It seems to me like the right design would be a special TR form that goes 
in expression positions and always signals a type error. 

…

Actually, I did a bit of exploring, and it looks like I can almost "roll my 
own", but that the expansion of ‘match’ is stymieing (yikes, sp?) me.

Specifically, with a conditional (as shown below), TR can deduce that the 
‘else’ in the conditional is unreachable, and doesn’t signal a type error in 
the program below. However, if I swap in the definition that uses ‘match,’ then 
I get a type error. (I’m guessing that the expansion of match generates a 
predicate that TR can’t reason about.)

Is there a better way to do this?

Thanks, and apologies if my searching just wasn’t thorough enough to find an 
existing thread on this topic!

John

#lang typed/racket

(require typed/rackunit)

(struct NumC ([n : Number]) #:transparent)
(struct PlusC ([l : ExprC] [r : ExprC]) #:transparent)

(define-type ExprC (U NumC PlusC))

;; examples

(NumC 3)
(PlusC (NumC 3) (NumC 14))

;; TR can deduce that else is unreachable:
(: num-nums (ExprC -> Number))
(define (num-nums tree)
  (cond
[(NumC? tree) 1]
[(PlusC? tree) (+ (num-nums (PlusC-l tree)) (num-nums (PlusC-r tree)))]
[else (/ 3 "type error")]))


;; Here, TR *cannot* deduce that else is unreachable
#;(define (num-nums tree)
  (match tree
[(struct NumC (n)) 1]
[(struct PlusC (l r)) (+ (num-nums l)
 (num-nums r))]
[other 34]
[other (/ 3 "type error")]))



(check-equal? (num-nums (NumC 3)) 1)
(check-equal? (num-nums (PlusC (NumC 3)
   (PlusC (NumC 4)
  (NumC 5 3)



-- 
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: IO in racket is painful

2016-03-23 Thread rom cgb
Thanks all for the interesting replies. 

About using an external package, there also the case like on www.hackerrank.com 
where you have to run the code in their own environment (eg: 
http://i.imgur.com/iSSPLGy.png).

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


Re: [racket-users] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Sam Tobin-Hochstadt
I think the struct implementing `parameteric->/c` could implement
`prop:equal+hash` appropriately. That wouldn't allow them to compare
equal to the unwrapped value, but it would make this program work.

Sam

On Wed, Mar 23, 2016 at 11:43 AM, Phil Nguyen  wrote:
> In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
> being called from the same or different module:
>
> #lang racket
>
> (module m racket
>   (provide
> (contract-out
>   [p? (parametric->/c (a) (a a . -> . boolean?))]))
>   (define p? equal?)
>   (p? 1 1))
>
> (require 'm)
> (p? 1 1)
>
> Module `m` is wrong in the first place for comparing 2 sealed objects, but 
> here we don't get an error. Is it practical to make `equal?` aware of 
> parametric contracts?
>
> This bit me in practice when I used a hashtable (which had an implicit 
> `equal?`). The worse part was that tests passed because they were in the same 
> module, and I only got unexpected behavior from outside.
>
> --
> 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] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Robby Findler
Unfortunately, this is just a fact of life with the current strategy
we have for implementing parametric contracts. Without changing the
basic idea behind the way parametric contracts work it would, IMO, be
an improvement for the use of p? in the outside to raise an error
(since you tried to learn something about those "a" values that you
are not supposed to know), but I don't know how to do that without too
high of a runtime cost, which is why things like equal? just return #f
instead of raising errors.

But maybe in this specific case (equality and hashing), there could be
an error inserted without hurting the performance of unrelated parts
of the system. (Backwards compatibility seems like an issue, tho.)

If you're interested and want to try the experiment, I'd be curious
what turns up.

Robby


On Wed, Mar 23, 2016 at 10:43 AM, Phil Nguyen  wrote:
> In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
> being called from the same or different module:
>
> #lang racket
>
> (module m racket
>   (provide
> (contract-out
>   [p? (parametric->/c (a) (a a . -> . boolean?))]))
>   (define p? equal?)
>   (p? 1 1))
>
> (require 'm)
> (p? 1 1)
>
> Module `m` is wrong in the first place for comparing 2 sealed objects, but 
> here we don't get an error. Is it practical to make `equal?` aware of 
> parametric contracts?
>
> This bit me in practice when I used a hashtable (which had an implicit 
> `equal?`). The worse part was that tests passed because they were in the same 
> module, and I only got unexpected behavior from outside.
>
> --
> 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] `equal?`'s unintuitive behavior with parametric contracts

2016-03-23 Thread Phil Nguyen
In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
being called from the same or different module:

#lang racket

(module m racket
  (provide
(contract-out
  [p? (parametric->/c (a) (a a . -> . boolean?))]))
  (define p? equal?)
  (p? 1 1))
  
(require 'm)
(p? 1 1)

Module `m` is wrong in the first place for comparing 2 sealed objects, but here 
we don't get an error. Is it practical to make `equal?` aware of parametric 
contracts?

This bit me in practice when I used a hashtable (which had an implicit 
`equal?`). The worse part was that tests passed because they were in the same 
module, and I only got unexpected behavior from outside.

-- 
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 -> HTML+JavaScript using Urlang and Ractive

2016-03-23 Thread Jens Axel Søgaard
The goal for the core Urlang language is to be almost 1-to-1 with
JavaScript.
Therefore I haven't used any JavaScript libraries. As Dan's examples
shows (see urlang/urlang-examples) it is straightforward to use existing
JavaScript libraries.

There are a few predefined macros that one can optionally use:
cond, case, for etc which are Urlang macros that expand into
core Urlang (think JavaScript) constructs. The ability to extend JavaScript
with a sane macro system was what I wanted to achieve.

The source code for Space Invaders is a port of an HtDP-style program.
The attempt was to match the original HtDP-style and I think it turned out
pretty well.

It contains an ad-hoc implementation of structs in Urlang (JavaScript), so
when
you want to access the x-coordinate of a player p, you will see (player-x p)
in the code. If the program was written from scratch I would have used p.x
which is the standard JavaScript notation of access x in an object (or
array) p.

If anyone wonders why I chose (var [x 42] [y 43]) rather than adding
an internal define to Urlang - it is due to the scoping rules. The
var-form follows the scoping rules of JavaScript - which means it
has block-scope.

If normal local scope is needed one can use the the let-macro (or letrec*)
from urlang/extra.

/Jens Axel




2016-03-23 12:42 GMT+01:00 Daniel Prager :

> On Sun, Mar 20, 2016 at 9:44 AM, Matthew Butterick  wrote:
>
>> When you put it that way, subjectively it still sounds good. I'd use it.
>> But objectively I can't foresee that it would be a wise investment of
>> anyone's Racket time. Let's face it: any web framework is lucky to live 5
>> yrs before developers tire of it and move onto the next thing, or browser
>> changes make it obsolete.
>>
>
> The shifting of the underlying platform is inevitable -- perhaps
> eventually it will settle down -- and empirically your point about
> web-frameworks checks out, suggesting that it would be unwise to bake in
> reliance on any particular framework.
>
> That said, I reckon that there are gains to be made via making use of
> existing JavaScript frameworks and libraries.
>
> OTOH: Here's a new example from Jens that has zero dependencies on
> external JS - a simple Space Invaders game in Urlang:
> http://soegaard.github.io/urlang/space-invaders.html
>
> 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.
>



-- 
-- 
Jens Axel Søgaard

-- 
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 -> HTML+JavaScript using Urlang and Ractive

2016-03-23 Thread Daniel Prager
On Sun, Mar 20, 2016 at 9:44 AM, Matthew Butterick  wrote:

> When you put it that way, subjectively it still sounds good. I'd use it.
> But objectively I can't foresee that it would be a wise investment of
> anyone's Racket time. Let's face it: any web framework is lucky to live 5
> yrs before developers tire of it and move onto the next thing, or browser
> changes make it obsolete.
>

The shifting of the underlying platform is inevitable -- perhaps eventually
it will settle down -- and empirically your point about web-frameworks
checks out, suggesting that it would be unwise to bake in reliance on any
particular framework.

That said, I reckon that there are gains to be made via making use of
existing JavaScript frameworks and libraries.

OTOH: Here's a new example from Jens that has zero dependencies on external
JS - a simple Space Invaders game in Urlang:
http://soegaard.github.io/urlang/space-invaders.html

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.


[racket-users] Re: IO in racket is painful

2016-03-23 Thread George Neuner
On Tue, 22 Mar 2016 21:06:14 -0700, Alexis King
 wrote:

>Would anyone object to a scanf-like function in Racket itself? 

No.  

But the question is how to specify input patterns to make it really
useful.  Racket's native printf is pretty basic.  Should scanf mirror
the native printf?  Or should it mirror something like SRFI-48 format,
which has more functionality?  

Or should it work with predicates that mirror racket/format output
functions?  

Or, in general, should it accept any suitable predicate?  
[e.g., string->number]


>The
>obvious point of difficulty is how to handle errors, given that parsing
>can fail but printing cannot. Should it throw an exception, or should it
>return #f? I’m not sure there is great precedent set here, though
>throwing seems to be the Racket way in other places.

Printing can fail both for formatting and I/O errors.

C's scanf returns the count of patterns matched (in order from the
beginning of the string), but I don't recall offhand whether that
includes patterns that use '*' to suppress assignment to an argument.
C's scanf also allows to limit expected field widths.

And an I/O error does not lose matches that preceded the error.  Any
arguments that were bound to values before the error occurred retain
their values.

Not that a Racket scanf necessarily has to work anything like C's.


Returning multiple values presents a problem if there is a mistake in
the input unless you have a distinct *unbound* value for unmatched
patterns (which #f is not).  

I suppose # works for an unbound indicator, but parsing
functions are expected to fail due to mistakes in the input. Returning
(values ...) from such functions ranks rather high on my offense meter
because I see little value to expecting, e.g., 10 return values and
getting back 8 of them set to #.  And returning too few values
results in an program error.

Perhaps the best thing would be just to return a list of the
successful matches.  I would only throw I/O errors, not match failures
... similar to the way regex-match et al work.


George

-- 
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.