From jrslepak at ccs.neu.edu Mon Sep 1 11:03:57 2014 From: jrslepak at ccs.neu.edu (Justin R. Slepak) Date: Mon, 1 Sep 2014 11:03:57 -0400 (EDT) Subject: [racket] Package installation VERY SLOW In-Reply-To: Message-ID: <17851288.952211409583837453.JavaMail.root@zimbra> I've also had the 0% CPU hang when trying to build docs for a package I'm working on. Only `raco setup' hangs though. If I use the "Scribble HTML" button in DrRacket, the documentation builds. --- Justin Slepak PhD student, Computer Science dept. ----- Original Message ----- From: George Neuner To: users at racket-lang.org Sent: Sun, 31 Aug 2014 07:44:31 -0400 (EDT) Subject: Re: [racket] Package installation VERY SLOW Hi Matthew, On Sat, 30 Aug 2014 07:41:02 -0600, Matthew Flatt wrote: >At Mon, 25 Aug 2014 21:42:08 -0400, George Neuner wrote: >> Just upgraded to 6.0.1 from 5.3.4. I know it's a big leap and 6.1 is >> out already, but I tried 6.1 and quickly experienced several of those >> non-reproducible crashes I've been reading about in the lists. > >Do you mean Evgeny's report on August 1, or did you have something else >in mind? (I don't have the sense that there are widespread reports of >problems with v6.1, so I may be missing something.) I don't recall Evgeny's report offhand and I can't find it just now. I have seen a different reports of issues with 6.1 in different places. On Windows 7 I experienced hanging with 64-bit 6.1 - completely unresponsive, 0% CPU. This happened numerous times doing different things: running package manager, editing, even just adjusting preferences. It seemed to be a GUI issue as raco worked from the command line. I had so much trouble with it that I didn't try very much. I uninstalled/reinstalled with fresh downloads a couple of times before giving up. 32-bit 6.1 did not hang, but it took almost 40 minutes to install [more than twice as long as 64-bit] and was so slow doing anything that I was convinced it was broken. Again I tried uninstalling/reinstalling without anything changing significantly. Then I read about the internal changes and decided to fall back to 6.0.1 until everything shakes out. >If you have time to help and you can quickly provoke crashes --- even >if you're not sure what causes it --- that sounds promising for >debugging. I'll ask more about that off-list. I got your note. I'd like to help but right now I'm in the middle of something and don't have a lot of time to muck around with it. I do have VS2010 available, but Racket was hanging rather than crashing, so the debugger didn't activate. Unfortunately I didn't think to attach to the hung process and see what was happening before killing it. >> 6.0.1 is behaving itself, but installing new packages from PLaneT or >> migrating packages from the older version is taking HOURS ... >> virtually all of it spent processing .scrbl files. > >It's probably no surprise to hear that it worked ok on my machine >(about 1 minute) in a fresh v6.0.1 install. > >Can you say more about the ".scrbl" part? Is the process of installing >a Planet package rebuilding documentation for the entire installation? >Or is it getting stuck on just the documentation for the installed >packages plus the main page and search index? It's hard to tell exactly because I'm not very familiar with the package install process, but it does get stuck "--- building documentation ---" for long periods with no output from raco. It seems to spend an inordinate amount of time "processing" scrbl files that are included with the packages. I don't mean rendering them - raco shows that separately - but just "processing" them. It would be nice if raco could timestamp its output. I can try to capture a procmon trace of a simple install if that would be any help. Ususally I find traces have too much information 8-( George ____________________ Racket Users list: http://lists.racket-lang.org/users From dpavlov at ipa.nw.ru Mon Sep 1 11:12:44 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Mon, 01 Sep 2014 19:12:44 +0400 Subject: [racket] fl vs. unsafe-fl Message-ID: <54048CEC.20109@ipa.nw.ru> Hello, I was wondering whether operations with flonums and flvectors work slower than their unsafe- counterparts in intensive numerical tasks. Here is an example: res = a+b*c #lang racket (require racket/flonum racket/unsafe/ops) (define n 1000) (define k 100000) (define a (make-flvector n 1.0)) (define b (make-flvector n 2.0)) (define c (make-flvector n 3.0)) (define res (make-flvector n)) (define (test-perf) (for ((i (in-range k))) (for ((j (in-range n))) (flvector-set! res j (fl+ (flvector-ref a j) (fl* (flvector-ref b j) (flvector-ref c j))))))) (define (test-perf-unsafe-ops) (for ((i (in-range k))) (for ((j (in-range n))) (flvector-set! res j (unsafe-fl+ (flvector-ref a j) (unsafe-fl* (flvector-ref b j) (flvector-ref c j))))))) (define (test-perf-unsafe-flvec) (for ((i (in-range k))) (for ((j (in-range n))) (unsafe-flvector-set! res j (fl+ (unsafe-flvector-ref a j) (fl* (unsafe-flvector-ref b j) (unsafe-flvector-ref c j))))))) (define (test-perf-unsafe-all) (for ((i (in-range k))) (for ((j (in-range n))) (unsafe-flvector-set! res j (unsafe-fl+ (unsafe-flvector-ref a j) (unsafe-fl* (unsafe-flvector-ref b j) (unsafe-flvector-ref c j))))))) (time (test-perf)) (time (test-perf-unsafe-ops)) (time (test-perf-unsafe-flvec)) (time (test-perf-unsafe-all)) Result (Racket 6.1.0.2, Linux 64-bit): cpu time: 1704 real time: 1704 gc time: 0 cpu time: 1692 real time: 1692 gc time: 0 cpu time: 736 real time: 738 gc time: 0 cpu time: 684 real time: 682 gc time: 0 It turns out that replacing arithmetical operations on flonums with their unsafe- counterparts makes no difference, unless flvector access is unsafe- too; and even then, making flvector access unsafe makes a huge improvement, while acceleration from unsafe ops is about 7%. I can imagine that the Racket's JIT skips checking the types of arguments of fl+ and fl* because it figures that since they come from flvectors, they must be flonums. Am I correct? If I am correct, then are unsafe-fl arithmetical operations important at all? Because in numerical programs, nearly every flonum is either a constant, or a value taken from flvector, or a function argument that can be traced to the same. Regards, Dmitry From greghendershott at gmail.com Mon Sep 1 14:04:54 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Mon, 1 Sep 2014 14:04:54 -0400 Subject: [racket] fl vs. unsafe-fl In-Reply-To: <54048CEC.20109@ipa.nw.ru> References: <54048CEC.20109@ipa.nw.ru> Message-ID: In some applications a 7% speedup in numeric operations is welcome. I think the main issue with unsafe-fl ops is that they are unsafe. The best thing about Typed Racket is that you can delegate that problem. Not only do you not need to write unsafe-fl+, you don't even need to write fl+. You can write +. Typed Racket will determine if + can safely be replaced with unsafe-fl+. (Assuming you typed things as Float a.k.a. Flonum, FlVector, &c.) From mflatt at cs.utah.edu Mon Sep 1 15:40:49 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Mon, 1 Sep 2014 21:40:49 +0200 Subject: [racket] fl vs. unsafe-fl In-Reply-To: <54048CEC.20109@ipa.nw.ru> References: <54048CEC.20109@ipa.nw.ru> Message-ID: <20140901194053.0EBB26501E3@mail-svr1.cs.utah.edu> Yes, using `fl` operations can often provide much of the benefit of `unsafe-fl` operations. The JIT knows than a `fl` operation always produces a flonum, so no check or boxing is needed if the flonum is immediately consumed by another `fl` operation. (Boxing is a bigger effect than dynamic checks, and no boxing is needed within the loop for any of the examples below.) An `unsafe-flvector` operation avoids array-bounds checks in addition to fixnum and flonum checks on the second and third arguments. I think that's why there's a much bigger difference between the second and third examples below. At Mon, 01 Sep 2014 19:12:44 +0400, Dmitry Pavlov wrote: > Hello, > > I was wondering whether operations with flonums and flvectors work > slower than their unsafe- counterparts in intensive numerical tasks. > > Here is an example: res = a+b*c > > #lang racket > > (require racket/flonum > racket/unsafe/ops) > > (define n 1000) > (define k 100000) > > (define a (make-flvector n 1.0)) > (define b (make-flvector n 2.0)) > (define c (make-flvector n 3.0)) > (define res (make-flvector n)) > > (define (test-perf) > (for ((i (in-range k))) > (for ((j (in-range n))) > (flvector-set! > res j (fl+ (flvector-ref a j) > (fl* (flvector-ref b j) > (flvector-ref c j))))))) > > (define (test-perf-unsafe-ops) > (for ((i (in-range k))) > (for ((j (in-range n))) > (flvector-set! > res j (unsafe-fl+ (flvector-ref a j) > (unsafe-fl* (flvector-ref b j) > (flvector-ref c j))))))) > > (define (test-perf-unsafe-flvec) > (for ((i (in-range k))) > (for ((j (in-range n))) > (unsafe-flvector-set! > res j (fl+ (unsafe-flvector-ref a j) > (fl* (unsafe-flvector-ref b j) > (unsafe-flvector-ref c j))))))) > > (define (test-perf-unsafe-all) > (for ((i (in-range k))) > (for ((j (in-range n))) > (unsafe-flvector-set! > res j (unsafe-fl+ (unsafe-flvector-ref a j) > (unsafe-fl* (unsafe-flvector-ref b j) > (unsafe-flvector-ref c j))))))) > > (time (test-perf)) > (time (test-perf-unsafe-ops)) > (time (test-perf-unsafe-flvec)) > (time (test-perf-unsafe-all)) > > > Result (Racket 6.1.0.2, Linux 64-bit): > > cpu time: 1704 real time: 1704 gc time: 0 > cpu time: 1692 real time: 1692 gc time: 0 > cpu time: 736 real time: 738 gc time: 0 > cpu time: 684 real time: 682 gc time: 0 > > > It turns out that replacing arithmetical operations > on flonums with their unsafe- counterparts makes no difference, > unless flvector access is unsafe- too; and even then, making > flvector access unsafe makes a huge improvement, while acceleration > from unsafe ops is about 7%. > > I can imagine that the Racket's JIT skips checking the types of > arguments of fl+ and fl* because it figures that since they come > from flvectors, they must be flonums. Am I correct? > > If I am correct, then are unsafe-fl arithmetical operations important > at all? Because in numerical programs, nearly every flonum is either > a constant, or a value taken from flvector, or a function argument > that can be traced to the same. > > > Regards, > > Dmitry > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mb at mbtype.com Mon Sep 1 21:20:05 2014 From: mb at mbtype.com (Matthew Butterick) Date: Mon, 1 Sep 2014 18:20:05 -0700 Subject: [racket] How `scribble` resolves relative paths Message-ID: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> I am confused by this statement in the docs vs. the actual behavior: The docs for `image` say that "If path is a relative path, it is relative to the current directory, which is set by `raco setup` and `scribble` to the directory of the main document file." (I'm using `image` as an example but I've seen the same problem with CSS files.) Suppose I have a project set up like this: /project /scribblings main.scrbl sample.gif And "main.scrbl" contains this: #lang scribble/manual @image["sample.gif"] If I do this: > cd project > cd scribblings > scribble main.html The HTML will render fine. But if I do this: > cd project > scribble --dest-name doc scribblings/main.scrbl I'll get this error: open-input-file: cannot open input file path: /project/sample.gif Thus, the relative path "sample.gif" is being resolved relative to the directory where I invoke the `scribble` command, not the "directory of the main document file", which in both cases seems like it should be /project/scribblings (i.e., the directory containing "main.scrbl"). What am I misunderstanding? [1] http://docs.racket-lang.org/scribble/base.html?q=image#%28def._%28%28lib._scribble%2Fbase..rkt%29._image%29%29 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Tue Sep 2 00:59:02 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Tue, 2 Sep 2014 06:59:02 +0200 Subject: [racket] How `scribble` resolves relative paths In-Reply-To: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> References: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> Message-ID: <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> I think the docs are wrong. While `raco setup` does set the current directory, `scribble` does not. It's better to use `define-runtime-path` instead of relying on the current directory, since that composes better. At Mon, 1 Sep 2014 18:20:05 -0700, Matthew Butterick wrote: > I am confused by this statement in the docs vs. the actual behavior: > > The docs for `image` say that "If path is a relative path, it is relative to > the current directory, which is set by `raco setup` and `scribble` to the > directory of the main document file." (I'm using `image` as an example but I've > seen the same problem with CSS files.) > > Suppose I have a project set up like this: > > /project > /scribblings > main.scrbl > sample.gif > > And "main.scrbl" contains this: > > #lang scribble/manual > @image["sample.gif"] > > If I do this: > > cd project > > cd scribblings > > scribble main.html > > The HTML will render fine. > > But if I do this: > > > cd project > > scribble --dest-name doc scribblings/main.scrbl > > I'll get this error: > > open-input-file: cannot open input file > path: /project/sample.gif > > Thus, the relative path "sample.gif" is being resolved relative to the > directory where I invoke the `scribble` command, not the "directory of the main > document file", which in both cases seems like it should be > /project/scribblings (i.e., the directory containing "main.scrbl"). > > What am I misunderstanding? > > > > > > > [1] > http://docs.racket-lang.org/scribble/base.html?q=image#%28def._%28%28lib._scribb > le%2Fbase..rkt%29._image%29%29____________________ > Racket Users list: > http://lists.racket-lang.org/users From publicityifl at gmail.com Tue Sep 2 03:23:30 2014 From: publicityifl at gmail.com (publicityifl at gmail.com) Date: Tue, 02 Sep 2014 00:23:30 -0700 (PDT) Subject: [racket] Third call for papers, IFL 2014 Message-ID: <54057072.2369b40a.7eb4.ffff977b@mx.google.com> Hello, Please, find below the third call for papers for IFL 2014. The submission page is now open. The submission date has been delayed to Sep. 8 2014 anywhere on the world. Please forward these to anyone you think may be interested. Apologies for any duplicates you may receive. best regards, Jurriaan Hage --- CALL FOR PAPERS 26th SYMPOSIUM ON IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES - IFL 2014 NORTHEASTERN UNIVERSITY/BOSTON, USA OCTOBER 1-3, 2014 http://ifl2014.github.io We are pleased to announce that the 26th edition of the IFL series will be held at Northeastern University in Boston, USA. The symposium will be held from 1st to 3rd of October 2014. Scope ----- The goal of the IFL symposia is to bring together researchers actively engaged in the implementation and application of functional and function-based programming languages. IFL 2014 will be a venue for researchers to present and discuss new ideas and concepts, work in progress, and publication-ripe results related to the implementation and application of functional languages and function-based programming. Following the IFL tradition, IFL 2014 will use a post-symposium review process to produce the formal proceedings. All participants of IFL 2014 are invited to submit either a draft paper or an extended abstract describing work to be presented at the symposium. At no time may work submitted to IFL be simultaneously submitted to other venues; submissions must adhere to ACM SIGPLAN's republication policy: http://www.sigplan.org/Resources/Policies/Republication The submissions will be screened by the program committee chair to make sure they are within the scope of IFL, and will appear in the draft proceedings distributed at the symposium. Submissions appearing in the draft proceedings are not peer-reviewed publications. Hence, publications that appear only in the draft proceedings do not count as publication for the ACM SIGPLAN republication policy. After the symposium, authors will be given the opportunity to incorporate the feedback from discussions at the symposium and will be invited to submit a revised full article for the formal review process. From the revised submissions, the program committee will select papers for the formal proceedings considering their correctness, novelty, originality, relevance, significance, and clarity. Submission Details ------------------ Submission deadline draft papers: September 8 Notification of acceptance for presentation: September 10 Early registration deadline: September 11 Late registration deadline: September 17 Submission deadline for pre-symposium proceedings: September 24 26th IFL Symposium: October 1-3 Submission deadline for post-symposium proceedings: December 15 Notification of acceptance for post-symposium proceedings: January 31 2015 Camera-ready version for post-symposium proceedings: March 15 2015 Prospective authors are encouraged to submit papers or extended abstracts to be published in the draft proceedings and to present them at the symposium. All contributions must be written in English. Papers must adhere to the standard ACM two columns conference format. For the pre-symposium proceedings we adopt a 'weak' page limit of 12 pages. For the post-symposium proceedings the page limit of 12 pages is firm. A suitable document template for LaTeX can be found at: http://www.acm.org/sigs/sigplan/authorInformation.htm Papers should be submitted online at https://easychair.org/conferences/?conf=ifl2014 Topics ------ IFL welcomes submissions describing practical and theoretical work as well as submissions describing applications and tools in the context of functional programming. If you are not sure whether your work is appropriate for IFL 2014, please contact the PC chair at samth at cs.indiana.edu. Topics of interest include, but are not limited to: ??? language concepts ??? type systems, type checking, type inferencing ??? compilation techniques ??? staged compilation ??? run-time function specialization ??? run-time code generation ??? partial evaluation ??? (abstract) interpretation ??? metaprogramming ??? generic programming ??? automatic program generation ??? array processing ??? concurrent/parallel programming ??? concurrent/parallel program execution ??? embedded systems ??? web applications ??? (embedded) domain specific languages ??? security ??? novel memory management techniques ??? run-time profiling performance measurements ??? debugging and tracing ??? virtual/abstract machine architectures ??? validation, verification of functional programs ??? tools and programming techniques ??? (industrial) applications Peter Landin Prize ------------------ The Peter Landin Prize is awarded to the best paper presented at the symposium every year. The honoured article is selected by the program committee based on the submissions received for the formal review process. The prize carries a cash award equivalent to 150 Euros. Programme committee ------------------- Sam Tobin-Hochstadt, Indiana University (Chair) Rinus Plasmeijer, Radboud University Nijmegen (Co-Chair) Atze Dijkstra, Utrecht University Colin Runciman, University of York Graham Hutton, University of Nottingham Mary Sheeran, Chalmers University of Technology Patricia Johann, Appalachian State University Matthew Fluet, Rochester Institute of Technology Josef Svenningsson, Chalmers University of Technology Ma??gorzata Biernacka, University of Wroclaw Peter Achten, Radboud Univerity Nijmegen Laura Castro, University of A Coru??a Hai Paul Liu, Intel Labs Kathryn Gray, Cambridge University Lars Bergstrom, Mozilla Research Lindsey Kuper, Indiana University Nicolas Wu, Oxford T. Stephen Strickland, University of Maryland Xavier Clerc, INRIA Venue ----- The 26th IFL will be held in association with the College of Computer and Information Science at Northeastern University. It can be reached quickly and easily by public transport. From publicityifl at gmail.com Tue Sep 2 03:23:46 2014 From: publicityifl at gmail.com (publicityifl at gmail.com) Date: Tue, 02 Sep 2014 00:23:46 -0700 (PDT) Subject: [racket] Third call for papers, IFL 2014 Message-ID: <54057082.2369b40a.7eb4.ffff9794@mx.google.com> Hello, Please, find below the third call for papers for IFL 2014. The submission page is now open. The submission date has been delayed to Sep. 8 2014 anywhere on the world. Please forward these to anyone you think may be interested. Apologies for any duplicates you may receive. best regards, Jurriaan Hage --- CALL FOR PAPERS 26th SYMPOSIUM ON IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES - IFL 2014 NORTHEASTERN UNIVERSITY/BOSTON, USA OCTOBER 1-3, 2014 http://ifl2014.github.io We are pleased to announce that the 26th edition of the IFL series will be held at Northeastern University in Boston, USA. The symposium will be held from 1st to 3rd of October 2014. Scope ----- The goal of the IFL symposia is to bring together researchers actively engaged in the implementation and application of functional and function-based programming languages. IFL 2014 will be a venue for researchers to present and discuss new ideas and concepts, work in progress, and publication-ripe results related to the implementation and application of functional languages and function-based programming. Following the IFL tradition, IFL 2014 will use a post-symposium review process to produce the formal proceedings. All participants of IFL 2014 are invited to submit either a draft paper or an extended abstract describing work to be presented at the symposium. At no time may work submitted to IFL be simultaneously submitted to other venues; submissions must adhere to ACM SIGPLAN's republication policy: http://www.sigplan.org/Resources/Policies/Republication The submissions will be screened by the program committee chair to make sure they are within the scope of IFL, and will appear in the draft proceedings distributed at the symposium. Submissions appearing in the draft proceedings are not peer-reviewed publications. Hence, publications that appear only in the draft proceedings do not count as publication for the ACM SIGPLAN republication policy. After the symposium, authors will be given the opportunity to incorporate the feedback from discussions at the symposium and will be invited to submit a revised full article for the formal review process. From the revised submissions, the program committee will select papers for the formal proceedings considering their correctness, novelty, originality, relevance, significance, and clarity. Submission Details ------------------ Submission deadline draft papers: September 8 Notification of acceptance for presentation: September 10 Early registration deadline: September 11 Late registration deadline: September 17 Submission deadline for pre-symposium proceedings: September 24 26th IFL Symposium: October 1-3 Submission deadline for post-symposium proceedings: December 15 Notification of acceptance for post-symposium proceedings: January 31 2015 Camera-ready version for post-symposium proceedings: March 15 2015 Prospective authors are encouraged to submit papers or extended abstracts to be published in the draft proceedings and to present them at the symposium. All contributions must be written in English. Papers must adhere to the standard ACM two columns conference format. For the pre-symposium proceedings we adopt a 'weak' page limit of 12 pages. For the post-symposium proceedings the page limit of 12 pages is firm. A suitable document template for LaTeX can be found at: http://www.acm.org/sigs/sigplan/authorInformation.htm Papers should be submitted online at https://easychair.org/conferences/?conf=ifl2014 Topics ------ IFL welcomes submissions describing practical and theoretical work as well as submissions describing applications and tools in the context of functional programming. If you are not sure whether your work is appropriate for IFL 2014, please contact the PC chair at samth at cs.indiana.edu. Topics of interest include, but are not limited to: ??? language concepts ??? type systems, type checking, type inferencing ??? compilation techniques ??? staged compilation ??? run-time function specialization ??? run-time code generation ??? partial evaluation ??? (abstract) interpretation ??? metaprogramming ??? generic programming ??? automatic program generation ??? array processing ??? concurrent/parallel programming ??? concurrent/parallel program execution ??? embedded systems ??? web applications ??? (embedded) domain specific languages ??? security ??? novel memory management techniques ??? run-time profiling performance measurements ??? debugging and tracing ??? virtual/abstract machine architectures ??? validation, verification of functional programs ??? tools and programming techniques ??? (industrial) applications Peter Landin Prize ------------------ The Peter Landin Prize is awarded to the best paper presented at the symposium every year. The honoured article is selected by the program committee based on the submissions received for the formal review process. The prize carries a cash award equivalent to 150 Euros. Programme committee ------------------- Sam Tobin-Hochstadt, Indiana University (Chair) Rinus Plasmeijer, Radboud University Nijmegen (Co-Chair) Atze Dijkstra, Utrecht University Colin Runciman, University of York Graham Hutton, University of Nottingham Mary Sheeran, Chalmers University of Technology Patricia Johann, Appalachian State University Matthew Fluet, Rochester Institute of Technology Josef Svenningsson, Chalmers University of Technology Ma??gorzata Biernacka, University of Wroclaw Peter Achten, Radboud Univerity Nijmegen Laura Castro, University of A Coru??a Hai Paul Liu, Intel Labs Kathryn Gray, Cambridge University Lars Bergstrom, Mozilla Research Lindsey Kuper, Indiana University Nicolas Wu, Oxford T. Stephen Strickland, University of Maryland Xavier Clerc, INRIA Venue ----- The 26th IFL will be held in association with the College of Computer and Information Science at Northeastern University. It can be reached quickly and easily by public transport. From dbastos at toledo.com Tue Sep 2 11:45:23 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Tue, 2 Sep 2014 12:45:23 -0300 Subject: [racket] missing solution 20.1.1 ex:sem-funcs Message-ID: A candidate for a solution. Exercise 20.1.1. Assume the Definitions window in DrScheme contains (define (f x) x). Identify the values among the following expressions: (1) (cons f empty) (2) (f f) (3) (cons f (cons 10 (cons (f 10) empty))) Explain why they are values and why the remaining expressions are not values. Solution. First we consider (1). Here's the relevant part of the grammar. = empty | (cons ) = | | | empty | | (names of defined functions) | So (1) is a value because it is of the form (cons empty), where f is because it is a defined function. Let's consider (3) before (2). (3) is a list of either or , so (3) is as well. Now we consider (2). Here's the relevant part of the grammar. = | | ( ...) So (2) is ( ), a list of expressions, which is an , not a . So (2) is not a value, although it's a legal expression. From dpavlov at ipa.nw.ru Tue Sep 2 11:53:37 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Tue, 02 Sep 2014 19:53:37 +0400 Subject: [racket] fl vs. unsafe-fl In-Reply-To: References: <54048CEC.20109@ipa.nw.ru> Message-ID: <5405E801.9050808@ipa.nw.ru> Greg, > The best thing about Typed Racket is that you can delegate that > problem. Not only do you not need to write unsafe-fl+, you don't even > need to write fl+. You can write +. Typed Racket will determine if + > can safely be replaced with unsafe-fl+. (Assuming you typed things as > Float a.k.a. Flonum, FlVector, &c.) I agree with you; however, I think I am in an unlucky situation. I actually have to write code that works with flonums or (optionally) with extflonums. As Extflonums are not part of the numeric tower, Typed Racket will not allow me to use "+" instead of "extfl+". Regards, Dmitry From dbastos at toledo.com Tue Sep 2 12:05:18 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Tue, 2 Sep 2014 13:05:18 -0300 Subject: [racket] missing solution 20.1.2 ex:syn-funcs Message-ID: Exercise 20.1.2. Argue why the following sentences are legal definitions: (define (f x) (x 10)) (define (f x) f) (define (f x y) (x 'a y 'b)) Solution. The relevant part of the grammar is the following. = (define ( ...) ) | (define ) | (define-struct ( ...)) (*) First definition The LHS is a list of , since we find f and x as members of the list and they're both variables. The RHS is a list consisting of a and a . That composes an , satisfying the first form of . In other words, (define ( ) ( ) ( ) = (define ( ) ). Therefore it's a legal . (*) Second definition Same LHS as the previous, so we need only check the RHS which is a . is a valid form of , so we have (define ( ) ) = (define ( ) ). Therefore it's a legal . (*) Third definition The LHS is ( ), while the RHS is ( ), so we have (define ( ) ( )) = (define ( ) ( )) = (define ( ) ). Therefore it's a legal . From samth at cs.indiana.edu Tue Sep 2 12:05:45 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Tue, 2 Sep 2014 12:05:45 -0400 Subject: [racket] fl vs. unsafe-fl In-Reply-To: <5405E801.9050808@ipa.nw.ru> References: <54048CEC.20109@ipa.nw.ru> <5405E801.9050808@ipa.nw.ru> Message-ID: On Tue, Sep 2, 2014 at 11:53 AM, Dmitry Pavlov wrote: > > >> The best thing about Typed Racket is that you can delegate that >> >> problem. Not only do you not need to write unsafe-fl+, you don't even >> need to write fl+. You can write +. Typed Racket will determine if + >> can safely be replaced with unsafe-fl+. (Assuming you typed things as >> Float a.k.a. Flonum, FlVector, &c.) > > > I agree with you; however, I think I am in an unlucky situation. > I actually have to write code that works with flonums or (optionally) > with extflonums. As Extflonums are not part of the numeric tower, > Typed Racket will not allow me to use "+" instead of "extfl+". But `fl+` and `unsafe-fl+` also do not work on Extflonums, so you should be able to use TR and then just replace uses of unsafe-fl+ with + as appropriate, and your extfl+ will still be there. Sam From dpavlov at ipa.nw.ru Tue Sep 2 12:13:50 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Tue, 02 Sep 2014 20:13:50 +0400 Subject: [racket] fl vs. unsafe-fl In-Reply-To: References: <54048CEC.20109@ipa.nw.ru> <5405E801.9050808@ipa.nw.ru> Message-ID: <5405ECBE.4010402@ipa.nw.ru> >> I agree with you; however, I think I am in an unlucky situation. >> I actually have to write code that works with flonums or (optionally) >> with extflonums. As Extflonums are not part of the numeric tower, >> Typed Racket will not allow me to use "+" instead of "extfl+". > > > But `fl+` and `unsafe-fl+` also do not work on Extflonums, so you > should be able to use TR and then just replace uses of unsafe-fl+ with > + as appropriate, and your extfl+ will still be there. Right. I was just dreaming about Typed Racket replacing "+" with "fl+" or "extfl+" basing on compile-time type inference. Regards, Dmitry From samth at cs.indiana.edu Wed Sep 3 08:30:24 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Wed, 3 Sep 2014 08:30:24 -0400 Subject: [racket] fl vs. unsafe-fl In-Reply-To: <5405ECBE.4010402@ipa.nw.ru> References: <54048CEC.20109@ipa.nw.ru> <5405E801.9050808@ipa.nw.ru> <5405ECBE.4010402@ipa.nw.ru> Message-ID: On Tue, Sep 2, 2014 at 12:13 PM, Dmitry Pavlov wrote: > >>> I agree with you; however, I think I am in an unlucky situation. >>> I actually have to write code that works with flonums or (optionally) >>> with extflonums. As Extflonums are not part of the numeric tower, >>> Typed Racket will not allow me to use "+" instead of "extfl+". >> >> >> >> But `fl+` and `unsafe-fl+` also do not work on Extflonums, so you >> should be able to use TR and then just replace uses of unsafe-fl+ with >> + as appropriate, and your extfl+ will still be there. > > > Right. I was just dreaming about Typed Racket replacing "+" > with "fl+" or "extfl+" basing on compile-time type inference. Ah, ok. I don't think we'll do that, since we want to keep the same Racket runtime semantics. However, if there was a `generic-+` with that behavior (which you could then rename to `+` :) then TR could optimize as you desired (maybe). Sam From dbastos at toledo.com Wed Sep 3 09:29:32 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Wed, 3 Sep 2014 10:29:32 -0300 Subject: [racket] missing solution 20.2.1 ex:arrows-dd Message-ID: A candidate for a solution. Exercise 20.2.1. Explain the following classes of functions: 1. (number -> boolean), 2. (boolean symbol -> boolean), 3. (number number number -> number), 4. (number -> (listof number)), and 5. ((listof number) -> boolean). Solution. (1) consumes a number and produces a boolean; (2) consumes a boolean and a symbol and produces a boolean; (3) consumes three numbers and produces a number; (4) consumes a number and produces a list of numbers; (5) consumes a list of numbers and produces a boolean. From dbastos at toledo.com Wed Sep 3 09:30:40 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Wed, 3 Sep 2014 10:30:40 -0300 Subject: [racket] missing solution 20.2.2 ex:fancy-contracts Message-ID: A candidate for a solution. Exercise 20.2.2. Formulate contracts for the following functions: 1. sort, which consumes a list of numbers and a function that consumes two numbers (from the list) and produces a boolean; sort produces a list of numbers. 2. map, which consumes a function from numbers to numbers and a list of numbers; it also produces a list of numbers. 3. project, which consumes a list of lists of symbols and a function from lists of symbols to symbols; it produces a list of symbols. Solution. sort: (listof number) (number number -> boolean) -> (listof number) map: (number -> number) (listof number) -> (listof number) project: (listof (listof symbol)) ((listof symbol) -> symbol) -> (listof symbol) From dbastos at toledo.com Wed Sep 3 09:31:25 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Wed, 3 Sep 2014 10:31:25 -0300 Subject: [racket] missing solution 20.2.3 ex:filter-contract Message-ID: A candidate for a solution. ;; Exercise 20.2.3. Use filter1 to develop a function that ;; consumes a list of symbols and extracts all those that ;; are not equal to 'car. Give filter1's corresponding contract. ;; Solution. (define (filter1 rel-op alon t) (cond [(empty? alon) empty] [else (cond [(rel-op (first alon) t) (cons (first alon) (filter1 rel-op (rest alon) t))] [else (filter1 rel-op (rest alon) t)])])) ;; f: (listof symbol) -> (listof symbol) ;; consumes a (listof symbol), producing a (listof symbol) without ;; any occurrence of 'car (define (f ls-of-sym) (local ((define (cmp sym1 sym2) (not (symbol=? sym1 sym2)))) (filter1 cmp ls-of-sym 'car))) (check-expect (f (list 'a 'b 'car 'x)) (list 'a 'b 'x)) (check-expect (f (list 'car 'car 'x 'car)) (list 'x)) ;; The contract of filter1 ;; filter1: (symbol symbol -> boolean) (listof symbol) symbol -> (listof symbol) From gil.martinez242 at gmail.com Wed Sep 3 12:01:21 2014 From: gil.martinez242 at gmail.com (Gilbert Martinez) Date: Wed, 3 Sep 2014 11:01:21 -0500 Subject: [racket] Issue reading bytes from TCP port Message-ID: I'm having issues reading the response from a TCP server. Specifically, any attempt to read the input port does not terminate. I've used port->bytes, read-byte, and read-line. In all cases the effect is the same. I thought that if there were no bytes available on an input port that the read attempt would just return . Is this some kind of exclusivity issue? Can I not read from the port until the connection with the server is closed or something? My traffic monitor shows that the server is receiving the request and responding (here is the exchange): Time Src. & Dst. Type Function Code Data 908.875 10.10.10.10:49967<- TCP Req. 0x04 [0x000 - 0x027] 00 01 00 00 00 06 0B 04 00 3B 00 03 908.90510.10.10.10:49967-> TCP Resp. 0x04 [0x000 - 0x027] 00 01 00 00 00 09 0B 04 06 00 00 00 00 00 00 Here is the code I am using to query: #lang racket (define (hex-bytes->bytes hex-bytes-list) (define (hex-byte->dec-byte hex-byte) (string->number (string-append "#x" ((if (symbol? hex-byte) symbol->string number->string) hex-byte)))) (apply bytes (for/list ((hex-byte (in-list hex-bytes-list))) (hex-byte->dec-byte hex-byte)))) (define-values (c-in c-out) (tcp-connect "10.10.10.11" 502)) (write-bytes (hex-bytes->bytes '(00 01 00 00 00 06 0B 04 00 3B 00 03)) c-out) (flush-output c-out) I run the code above and execute the following in the interactions pane: Welcome to DrRacket, version 6.1.0.5--2014-08-25(32ae3f8/a) [3m]. Language: racket [custom]. 12 >(for ((byte (in-bytes (port->bytes c-in)))) (printf "~x " byte)) The entry above above hangs on port->bytes. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Wed Sep 3 12:18:07 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed, 3 Sep 2014 18:18:07 +0200 Subject: [racket] Issue reading bytes from TCP port In-Reply-To: References: Message-ID: Have you tried closing the ports? -- Matthias On Sep 3, 2014, at 6:01 PM, Gilbert Martinez wrote: > I'm having issues reading the response from a TCP server. Specifically, any attempt to read the input port does not terminate. I've used port->bytes, read-byte, and read-line. In all cases the effect is the same. > > I thought that if there were no bytes available on an input port that the read attempt would just return . Is this some kind of exclusivity issue? Can I not read from the port until the connection with the server is closed or something? > > My traffic monitor shows that the server is receiving the request and responding (here is the exchange): > > Time Src. & Dst. Type Function Code Data > 908.875 10.10.10.10:49967<- TCP Req. 0x04 [0x000 - 0x027] 00 01 00 00 00 06 0B 04 00 3B 00 03 > 908.905 10.10.10.10:49967-> TCP Resp. 0x04 [0x000 - 0x027] 00 01 00 00 00 09 0B 04 06 00 00 00 00 00 00 > > Here is the code I am using to query: > > #lang racket > > > (define (hex-bytes->bytes hex-bytes-list) > (define (hex-byte->dec-byte hex-byte) > (string->number (string-append "#x" ((if (symbol? hex-byte) > symbol->string > number->string) > hex-byte)))) > (apply bytes (for/list ((hex-byte (in-list hex-bytes-list))) > (hex-byte->dec-byte hex-byte)))) > > (define-values (c-in c-out) (tcp-connect "10.10.10.11" 502)) > > (write-bytes (hex-bytes->bytes '(00 01 00 00 00 06 0B 04 00 3B 00 03)) c-out) > (flush-output c-out) > > > I run the code above and execute the following in the interactions pane: > > Welcome to DrRacket, version 6.1.0.5--2014-08-25(32ae3f8/a) [3m]. > Language: racket [custom]. > 12 > >(for ((byte (in-bytes (port->bytes c-in)))) > (printf "~x " byte)) > > > The entry above above hangs on port->bytes. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From neil at neilvandyke.org Wed Sep 3 12:23:10 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Wed, 03 Sep 2014 12:23:10 -0400 Subject: [racket] Issue reading bytes from TCP port In-Reply-To: References: Message-ID: <5407406E.9010603@neilvandyke.org> Gilbert Martinez wrote at 09/03/2014 12:01 PM: > > I run the code above and execute the following in the interactions pane: > > > Welcome to DrRacket, version 6.1.0.5--2014-08-25(32ae3f8/a) [3m]. > Language: racket [custom]. > 12 > >(for ((byte (in-bytes (port->bytes c-in)))) > (printf "~x " byte)) > > > The entry above above hangs on port->bytes. Unless "in-bytes" is doing more magic than I feared, I believe that here "port->bytes" is a procedure that reads all the input to the end-of-file (which won't happen until the TCP connection is closed), before "in-bytes" or "for" or anyone else sees anything from the port. "port->bytes" is a convenience, mainly for reading files. You instead probably want to read one byte at a time from the port, or (a little harder) to do block reads of available bytes from the port. BTW, I think this is another example of how "for" and friends are confusing to people. I still think that people are better off first learning how to do things using named-"let" and mutually-recursive procedures *before* being introduced to "for". (My biggest objection is that people introduced to "for" first then end up shoehorning control-flow into "for" even when it doesn't fit. But I'm saving this new kind of anecdote, about syntactic sugar obscuring evaluation model, as additional evidence of "for"'s crimes against humanity.) Neil V. -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.vanderson at gmail.com Wed Sep 3 17:48:36 2014 From: david.vanderson at gmail.com (David Vanderson) Date: Wed, 03 Sep 2014 17:48:36 -0400 Subject: [racket] Issue reading bytes from TCP port In-Reply-To: References: Message-ID: <54078CB4.50207@gmail.com> On 09/03/2014 12:01 PM, Gilbert Martinez wrote: > I'm having issues reading the response from a TCP server. > Specifically, any attempt to read the input port does not terminate. > I've used port->bytes, read-byte, and read-line. In all cases the > effect is the same. > > I thought that if there were no bytes available on an input port that > the read attempt would just return . Is this some kind of > exclusivity issue? Can I not read from the port until the connection > with the server is closed or something? This is not true. Most functions like 'read-byte' block until there are bytes available to read. You don't get until the port (connection) is closed. If you want a non-blocking call, look at 'read-bytes-avail!*'. #lang racket (define-values (in out) (make-pipe)) (thread (lambda () (for ((i 5)) (write-byte i out) (sleep 1)) (close-output-port out))) (for ((b in)) (printf "~x " b)) 'for' is pretty smart in my experience. I believe in this case it's using a sequence from 'in-port'. But in any case, you should see numbers print out before the port is closed. Does this help? Thanks, Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: From clements at brinckerhoff.org Wed Sep 3 19:00:00 2014 From: clements at brinckerhoff.org (John Clements) Date: Wed, 3 Sep 2014 16:00:00 -0700 Subject: [racket] racket search: a compelling reason to use duckduckgo.com Message-ID: <89769A17-173D-487C-8127-029CCA5D7EA1@brinckerhoff.org> Once I have duckduckgo set as my default browser search engine, I can search !racket add1 ? and I get to not bad. I think I?m ready to switch to this search engine permanently. John From jhemann at umail.iu.edu Wed Sep 3 23:09:07 2014 From: jhemann at umail.iu.edu (Jason Hemann) Date: Wed, 3 Sep 2014 23:09:07 -0400 Subject: [racket] [ANN] *Extended Deadline* CFP for 2014 Scheme and Functional Programming Workshop Message-ID: The paper submission deadline has been extended one week, to Friday, Sept. 12 23:59 (UTC-12). [Apologies for duplication from cross-postings.] NEW DEADLINE: 12 September 2014, 23:59 (UTC-12) WEBSITE: http://homes.soic.indiana.edu/jhemann/scheme-14/ LOCATION: Washington, DC (co-located with Clojure/conj) DATE: 19 November 2014 The 2014 Scheme and Functional Programming Workshop is calling for submissions. Submissions related to Scheme and functional programming are welcome and encouraged. Topics of interest include but are not limited to: - Program-development environments, debugging, testing - Implementation (interpreters, compilers, tools, benchmarks, etc) - Syntax, macros, and hygiene - Distributed computing, concurrency, parallelism - Interoperability with other languages, FFIs - Continuations, modules, object systems, types - Theory, formal semantics, correctness - History, evolution and standardization of Scheme - Applications, experience and industrial uses of Scheme - Education - Scheme pearls (elegant, instructive uses of Scheme) We also welcome papers related to dynamic or multiparadigmatic languages and programming techniques. Full papers are due 12 September 2014. Authors will be notified by 10 October 2014. Camera-ready versions are due 24 October 2014. All deadlines are 23:59 (UTC-12, "Anywhere on Earth"). For more information, please see: http://homes.soic.indiana.edu/jhemann/scheme-14/ Jason Hemann Organizer, Scheme '14 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tarmo at cs.ioc.ee Tue Sep 2 06:28:35 2014 From: tarmo at cs.ioc.ee (Tarmo Uustalu) Date: Tue, 2 Sep 2014 13:28:35 +0300 (EEST) Subject: [racket] ETAPS 2015 2nd call for papers Message-ID: ****************************************************************** CALL FOR PAPERS: ETAPS 2015 18th European Joint Conferences on Theory And Practice of Software London, UK, 11-18 April 2015 http://www.etaps.org/2015 ****************************************************************** -- ABOUT ETAPS -- ETAPS is the primary European forum for academic and industrial researchers working on topics relating to software science. ETAPS, established in 1998, is a confederation of six main annual conferences, accompanied by satellite workshops. ETAPS 2015 is the eighteenth event in the series. -- MAIN CONFERENCES (13-17 April) -- * CC: Compiler Construction (PC chair Bj?rn Franke, University of Edinburgh, UK) * ESOP: European Symposium on Programming (PC chair Jan Vitek, Northeastern University, USA) * FASE: Fundamental Approaches to Software Engineering (PC chairs Alexander Egyed, Johannes Kepler U Linz, Austria, and Ina Schaefer, Technische Universit?t Braunschweig, Germany) * FOSSACS: Foundations of Software Science and Computation Structures (PC chair Andrew Pitts, University of Cambridge, UK) * POST: Principles of Security and Trust (PC chairs Riccardo Focardi, Universit? Ca' Foscari Venezia, Italy, and Andrew Myers, Cornell University, USA) * TACAS: Tools and Algorithms for the Construction and Analysis of Systems (PC chairs Christel Baier, Technische Univ Dresden, Germany, and Cesare Tinelli, The University of Iowa, USA) TACAS '15 will host the 4rd Competition on Software Verification (SV-COMP). -- INVITED SPEAKERS -- * Unifying speakers: Robert Harper (Carnegie Mellon University, USA) Catuscia Palamidessi (INRIA Saclay and LIX, France) * CC invited speaker: Keshav Pingali (University of Texas, USA) * FoSSaCS invited speaker: Frank Pfenning (Carnegie Mellon University, USA) * TACAS invited speaker: Wang Yi (Uppsala Universitet, Sweden) -- IMPORTANT DATES -- * 10 October 2014: Submission deadline for abstracts * 17 October 2014: Submission deadline for full papers * 3-5 December 2014: Author response period (ESOP and FoSSaCS only) * 19 December 2014: Notification of acceptance * 16 January 2015: Camera-ready versions due -- SUBMISSION INSTRUCTIONS -- ETAPS conferences accept two types of contributions: research papers and tool demonstration papers. Both types will appear in the proceedings and have presentations during the conference. ESOP and FoSSaCS accept only research papers. TACAS has more paper categories (see http://www.etaps.org/2015/tacas). A condition of submission is that, if the submission is accepted, one of the authors attends the conference to give the presentation. Submitted papers must be in English presenting original research. They must be unpublished and not submitted for publication elsewhere. In particular, simultaneous submission of the same contribution to multiple ETAPS conferences is forbidden. The proceedings will be published in the Advanced Research in Computing and Software Science (ARCoSS) subline of Springer's Lecture Notes in Computer Science series. Papers must follow the formatting guidelines specified by Springer at http://www.springer.de/comp/lncs/authors.html and be submitted electronically in pdf through the EasyChair author interface of the respective conference (HotCRP for ESOP). Submissions not adhering to the specified format and length may be rejected immediately. - Research papers FASE, FOSSACS and TACAS have a page limit of 15 pages for research papers, whereas CC, POST allow at most 20 pages and ESOP 25 pages. Additional material intended for the referees but not for publication in the final version - for example, details of proofs - may be placed in a clearly marked appendix that is not included in the page limit. ETAPS referees are at liberty to ignore appendices and papers must be understandable without them. In addition to regular research papers, TACAS solicits also case study papers (at most 15 pages). Both TACAS and FASE solicit also regular tool papers (at most 15 pages). - Tool demonstration papers Submissions should consist of two parts: * The first part, at most 4 pages, should describe the tool presented. Please include the URL of the tool (if available) and provide information that illustrates the maturity and robustness of the tool. (This part will be included in the proceedings.) * The second part, at most 6 pages, should explain how the demonstration will be carried out and what it will show, including screen dumps and examples. (This part will be not be included in the proceedings, but will be evaluated.) ESOP and FOSSACS do not accept tool demonstration papers. TACAS has a page limit of 6 pages for tool demonstrations. -- SATELLITE EVENTS (11-12 April, 18 April) -- Around 20 satellite workshops will take place before and after the main conferences. -- HOST CITY -- London, the capital city of England and the UK, is a leading global city, with strengths in the arts, commerce, education, entertainment, fashion, finance, healthcare, media, professional services, research and development, tourism and transport all contributing to its prominence. It is one of the world's leading financial centers and a world cultural capital. It is the world's most-visited city as measured by international arrivals and has the world's largest city airport system measured by passenger traffic. In 2012, London became the first city to host the modern Summer Olympic Games three times. -- HOST INSTITUTION -- ETAPS 2015 is hosted by the School of Electrical Engineering and Computer Science of the Queen Mary University of London. The main campus is located in the Mile End area of the East End of London. -- ORGANIZERS * General chairs: Pasquale Malacaria, Nikos Tzevelekos * Workshops chair: Paulo Oliva -- FURTHER INFORMATION -- Please do not hesitate to contact the organizers at p.malacaria at qmul.ac.uk, nikos.tzevelekos at qmul.ac.uk. From dbastos at toledo.com Thu Sep 4 12:54:57 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Thu, 4 Sep 2014 13:54:57 -0300 Subject: [racket] missing solution 20.2.4 ex:fancy-contracts-poly Message-ID: A candidate for a solution. (I'm not sure I'm correct regarding the function project. The description says "a lists of lists" (which I translate to (listof ITEM)) and "a function from lists to Xs", so I wonder if the domain of this function-argument must be (listof ITEM) or it could be more general such as (listof Y). I decided to imagine that the domain of the function-argument would be items of the "list of lists" and so I made it into (listof ITEM). Thank you for your attention. Exercise 20.2.4. Formulate general contracts for the following functions: 1. sort, which consumes a list of items and a function that consumes two items (from the list) and produces a boolean; it produces a list of items. 2. map, which consumes a function from list items to Xs and a list; it produces a list of Xs. 3. project, which consumes a list of lists and a function from lists to Xs; it produces a list of Xs. Compare with exercise 20.2.2. Solution. sort: (listof ITEM) (ITEM ITEM -> boolean) -> (listof ITEM) map: ((listof ITEM) -> X) (listof ITEM) -> (listof X) project: (listof (listof ITEM)) ((listof ITEM) -> (listof X)) -> (listof X) (*) Comparison with exercise 20.2.2 For sort, we replaced number with X. So we generalized the type of the list which we sort. The new procedure can sort a generic list. For map, we generalized both the domain and co-domain of the function consumed by map. Before, the consumed function was only a mapping from numbers to numbers and now it is a mapping from a generic domain ITEM to a generic co-domain X. For project, we generalized the type of the list of lists. It was of type symbol and now it can be a list of lists of any kind of item. From johnbclements at gmail.com Thu Sep 4 13:45:48 2014 From: johnbclements at gmail.com (John Clements) Date: Thu, 4 Sep 2014 10:45:48 -0700 Subject: [racket] Best typed/racket representation for bitfield of width 125? Message-ID: I want to represent a bitfield of 125 bits, using typed racket. I?ll be combining them using bitwise operations, and checking for zero-ness. I think that?s about it. I could just use type Integer, but it seems like that would impose additional checking, since the type system doesn?t know the size. In untyped racket I used a vector of four integers in the range 0-2^32, but those don?t fit in typed Racket?s ?Fixnum? because it uses a signed representation (and indeed, untyped racket may have been falling prey to the same problem. Perhaps I should break it up into four integers in the range 0-2^31? That seems weird, but maybe that?s my best choice? Or? I could use a byte string. Apologies if I?m missing something in the docs, here; I?ve spent a few minutes searching, without turning anything up. Thanks for any advice, John -------------- next part -------------- An HTML attachment was scrubbed... URL: From greghendershott at gmail.com Thu Sep 4 14:41:31 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Thu, 4 Sep 2014 14:41:31 -0400 Subject: [racket] Best typed/racket representation for bitfield of width 125? In-Reply-To: References: Message-ID: Although I haven't tried data/bit-vector in Typed Racket, could you do something like the following? #lang typed/racket (require/typed data/bit-vector [#:opaque BitVector bit-vector?] [make-bit-vector (-> Index BitVector)] ... TO-DO ...) (define bv (make-bit-vector 125)) On Thu, Sep 4, 2014 at 1:45 PM, John Clements wrote: > I want to represent a bitfield of 125 bits, using typed racket. I?ll be > combining them using bitwise operations, and checking for zero-ness. I think > that?s about it. > > I could just use type Integer, but it seems like that would impose > additional checking, since the type system doesn?t know the size. In > untyped racket I used a vector of four integers in the range 0-2^32, but > those don?t fit in typed Racket?s ?Fixnum? because it uses a signed > representation (and indeed, untyped racket may have been falling prey to the > same problem. Perhaps I should break it up into four integers in the range > 0-2^31? That seems weird, but maybe that?s my best choice? Or? I could use a > byte string. > > Apologies if I?m missing something in the docs, here; I?ve spent a few > minutes searching, without turning anything up. > > Thanks for any advice, > > John > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From stamourv at ccs.neu.edu Thu Sep 4 15:35:57 2014 From: stamourv at ccs.neu.edu (Vincent St-Amour) Date: Thu, 04 Sep 2014 15:35:57 -0400 Subject: [racket] Best typed/racket representation for bitfield of width 125? In-Reply-To: References: Message-ID: <878ulzji02.wl%stamourv@ccs.neu.edu> Would an fxvector of length 5 (to account for the tag bits) work? If all you're doing is bitwise ops and comparisons, it should be easy to convince TR that you're staying within fixnum range. Vincent At Thu, 4 Sep 2014 10:45:48 -0700, John Clements wrote: > > [1 ] > [1.1 ] > I want to represent a bitfield of 125 bits, using typed racket. I?ll be > combining them using bitwise operations, and checking for zero-ness. I > think that?s about it. > > I could just use type Integer, but it seems like that would impose > additional checking, since the type system doesn?t know the size. In > untyped racket I used a vector of four integers in the range 0-2^32, but > those don?t fit in typed Racket?s ?Fixnum? because it uses a signed > representation (and indeed, untyped racket may have been falling prey to > the same problem. Perhaps I should break it up into four integers in the > range 0-2^31? That seems weird, but maybe that?s my best choice? Or? I > could use a byte string. > > Apologies if I?m missing something in the docs, here; I?ve spent a few > minutes searching, without turning anything up. > > Thanks for any advice, > > John > [1.2 ] > > [2 ] > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From steve at stevelloyd.net Thu Sep 4 15:48:43 2014 From: steve at stevelloyd.net (Steve Lloyd) Date: Thu, 4 Sep 2014 20:48:43 +0100 Subject: [racket] Snapshot builds Message-ID: I recently ?discovered? (thanks to a tweet from @dkvansnickajr) the snapshot builds for ARM6 built on Raspbian. Previously I?d been recommending people try out Racket on RasPi via the source+built packages route, but realise they might baulk at the build times and this other route seems very attractive in this respect. Can I just sanity-check that this new approach is sensible? Thanks. From marco at neniu.org Fri Sep 5 06:04:45 2014 From: marco at neniu.org (Marco Monteiro) Date: Fri, 5 Sep 2014 11:04:45 +0100 Subject: [racket] Understanding error in use of submodule in my language In-Reply-To: <20140822153851.1C28965018F@mail-svr1.cs.utah.edu> References: <20140822153851.1C28965018F@mail-svr1.cs.utah.edu> Message-ID: Thanks, Matthew. I fixed it by not expanding the module* form in the local-expand, i.e. I used (list #'module*) as the third argument to local-expand. Cheers, Marco On Fri, Aug 22, 2014 at 4:38 PM, Matthew Flatt wrote: > I think this may be a problem in macro expansion with submodules. > > The `#%module-begin` from `racket/base` adds a submodule declaration > for `configure-runtime` when it doesn't see an existing submodule > declaration for `configure-runtime` --- but it looks for an existing > declaration as an immediate one, before macro-expanding the module > body. > > In your code, the `mute` wrapper hides the declaration of > `configure-runtime`, so a conflicting one gets added. The tricky part > is that this happens the second time that the `test` submodule is > expanded: > > * The overall module's body is forced via `local-expand`. > > * As a part of that local expansion, the `test` submodule is expanded' > its expansion includes a declaration of a `configure-runtime` > submodule. > > * The overall module's expanded body is wrapped back in > `#%module-begin`, which will re-expand all of the content, including > the `test` submodule. > > * The `test` submodule this second time around has a `#%module-begin` > that is supposed to be bound to `#%plain-module-begin`, but it ends > up being captured[*] by `#%module-begin` from "bootstrap-lang.rkt", > so that the submodule's body is again local-expanded and again send > to `#%module-begin` from `racket/base` with a `mute` wrapper around > the `configure-runtime` sub-submodule. > > The [*] step seems wrong to me. I think this may be an example of a > problem deep in the macro expander, and solving that is my next > project. > > > Since the repair (assuming that I have correctly diagnosed the cause) > may be a while, do you have a workaround already? The macro name `mute` > suggests that you may want to suppress the printing of expression > results at the top-level of a module, and that might be as easy as > expanding `#%module-begin` to `#%plain-module-begin`. Or maybe > `syntax/wrap-modbeg` can help, or maybe the strategy used by > `syntax/wrap-modbeg` would work better for your macro. > > > At Thu, 21 Aug 2014 17:22:29 +0100, Marco Monteiro wrote: > > Hello! > > > > I'm using Racket 6.1 > > > > I'm trying to understand this error. I'm using submodules in a language I > > defined. The language file is here: > > > > http://pastebin.com/7RiHHRmi > > > > Notice the commented out line 28. > > > > I use that language in the following code > > > > http://pastebin.com/Qa6RD9wF > > > > raco expanding this last file fails with > > > > module: duplicate submodule definition > > at: configure-runtime > > in: module > > context...: > > > /usr/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:29:11: > > loop > > /usr/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt: > > [running body] > > /usr/share/racket/collects/raco/raco.rkt: [running body] > > /usr/share/racket/collects/raco/main.rkt: [running body] > > > > If I uncomment line 28 it no longer fails. If I use (module ...) instead > of > > (module* ...) it no longer fails independently of line 28 being commented > > out or not. > > > > Trying to macro expand that in drracket gives me "Internal error: car: > > contract violation ." error. > > > > What is happending here? > > > > Thanks, > > Marco > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From acarrico at memebeam.org Fri Sep 5 11:12:40 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Fri, 05 Sep 2014 11:12:40 -0400 Subject: [racket] typed racket cps, state machines Message-ID: <5409D2E8.2070903@memebeam.org> Thanks for occasional help learning typed racket on IRC. I'm still finding the pitfalls that await those of us used to dynamically typed programs. The other day I posted some cps patterns I figured out: http://pasterack.org/pastes/49759 Extending that to simple state machines that loop through various states gets me into trouble. The simplest example is just looping through one state, or not: (define #:? (B0V B1V) (p0 (branch0 : (-> B0V)) (branch1 : (-> B1V))) : (U B0V B1V) ;; This one is fine: (define (no-loop) : (U B0V B1V) (branch0)) ;; insufficient type information to typecheck this one: (define (loop) : (U B0V B1V) (loop)) ;; insufficient type information to typecheck this one too: (define (loop*) : (U B0V B1V) ((inst loop* B0V B1V))) ;; insufficient type information to typecheck this one too: (define (loop**) : (U B0V B1V) ((inst loop** (U B0V B1V) (U B0V B1V)))) (no-loop) (loop) (loop*) (loop**)) I'm still thinking about this problem, but since I have distilled it to the simplest cases, I thought I'd post. I have the intuition that this has something to do with the nested instantiation of polymorphic types. The unions would "obviously" (to a human) collapse, but I suppose the type checker isn't picking up on this. -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From matthias at ccs.neu.edu Fri Sep 5 11:48:40 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 5 Sep 2014 11:48:40 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <5409D2E8.2070903@memebeam.org> References: <5409D2E8.2070903@memebeam.org> Message-ID: <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> 1. Your programs don't look like conventional cps. Perhaps you're thinking 2-way continuations (as in Prolog implementations). 2. Don't use polymorphism. Just use (define (halt) (printf "done") (halt)) as the proper halt continuation, often falsely called initial continuation. 3. Think about the algorithm. This hint comes in the form of a cps algorithm: http://pasterack.org/pastes/55294 #lang typed/racket (require typed/rackunit) (define-type ? ;; e = (is one of) (U Symbol ;; x (List 'lambda Symbol ?) ;; ?x.e (List ? ?) ;; (e e) )) (: e1 ?) (define e1 'x) (: e2 ?) (define e2 '(lambda x x)) (: e3 ?) (define e3 `(,e1 ,e2)) (: e1-cps ?) (define e1-cps '(lambda k (k x))) (: e2-cps ?) (define e2-cps '(lambda k (k (lambda x (lambda k (k x)))))) (: e3-cps ?) (define e3-cps `(lambda k (,e1-cps (lambda k-e1 (,e2-cps (lambda k-e2 ((k-e1 k-e2) k))))))) (: cps (-> ? Symbol ?)) (define (cps e k) (match e [(? symbol? x) `(lambda ,k (,k ,x))] [`(lambda ,(? symbol? x) ,e) `(lambda ,k (,k (lambda ,x ,(cps e 'k))))] [`(,f ,a) `(lambda ,k (,(cps f 'k) (lambda k-e1 (,(cps a 'k) (lambda k-e2 ((k-e1 k-e2) ,k))))))])) (check-equal? (cps e1 'k) e1-cps) (check-equal? (cps e2 'k) e2-cps) (check-equal? (cps e3 'k) e3-cps) ;; --------------------------------------------------------------------------------------------------- ;; now write an evaluator for ? and run the examples (: halt ?) (define halt '(lambda x x)) (: e1-run-cps ?) (define e1-run-cps `(,e1 ,halt)) (: e2-run-cps ?) (define e2-run-cps `(,e2 ,halt)) (: e3-run-cps ?) (define e3-run-cps `(,e3 ,halt)) On Sep 5, 2014, at 11:12 AM, Anthony Carrico wrote: > Thanks for occasional help learning typed racket on IRC. I'm still > finding the pitfalls that await those of us used to dynamically typed > programs. > > The other day I posted some cps patterns I figured out: > http://pasterack.org/pastes/49759 > > Extending that to simple state machines that loop through various states > gets me into trouble. The simplest example is just looping through one > state, or not: > > (define #:? (B0V B1V) > (p0 (branch0 : (-> B0V)) > (branch1 : (-> B1V))) > : (U B0V B1V) > > ;; This one is fine: > (define (no-loop) : (U B0V B1V) > (branch0)) > > ;; insufficient type information to typecheck this one: > (define (loop) : (U B0V B1V) > (loop)) > > ;; insufficient type information to typecheck this one too: > (define (loop*) : (U B0V B1V) > ((inst loop* B0V B1V))) > > ;; insufficient type information to typecheck this one too: > (define (loop**) : (U B0V B1V) > ((inst loop** (U B0V B1V) (U B0V B1V)))) > > (no-loop) > (loop) > (loop*) > (loop**)) > > I'm still thinking about this problem, but since I have distilled it to > the simplest cases, I thought I'd post. I have the intuition that this > has something to do with the nested instantiation of polymorphic types. > The unions would "obviously" (to a human) collapse, but I suppose the > type checker isn't picking up on this. > > -- > Anthony Carrico > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From skanaley at gmail.com Fri Sep 5 15:14:44 2014 From: skanaley at gmail.com (Sean Kanaley) Date: Fri, 5 Sep 2014 15:14:44 -0400 Subject: [racket] Submodules can't be imported in same file? Message-ID: Hello, For ease of exporting wrapper functions I am trying to do something like #lang racket (module wrap racket or module+ wrap (provide (all-defined-out)) ) (require 'wrap) (provide (all-from-out 'wrap)) With (module wrap racket ...), (require 'wrap) works but the stuff to be wrapped isn't visible in the module, which is what the module+ form is for, but then there doesn't seem to be a way to require wrap then. It seems to require REPL or another file using (submod "" wrap). Obviously I can just split the code into two files in the first place, but then what was the intended use for modules or submodules vs. just plain files? -------------- next part -------------- An HTML attachment was scrubbed... URL: From acarrico at memebeam.org Fri Sep 5 15:48:57 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Fri, 05 Sep 2014 15:48:57 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> Message-ID: <540A13A9.50204@memebeam.org> On 09/05/2014 11:48 AM, Matthias Felleisen wrote:> > 1. Your programs don't look like conventional cps... I have distilled my "cps-ish" examples too far away from any context. A concrete example of this pattern would be searching. The direct style is: (findf proc lst) -> any/c When I say "cps-ish", I'm talking about the following style: (find proc lst found-tail not-found-tail) the type turns out to be something like this: (: find (Any (Element FoundV NotFoundV) (-> (-> Element Boolean) (Listof Element) (-> Element FoundV) (-> NotFoundV) (U FoundV NotFoundV))) In my mind, the computation is essentially "returning" to either the found-tail, or the not-found-tail. The result types of the tails are irrelevant to the search computation; they don't show up in direct style version. Another way to express this would be with two return points, in the multi-return lambda calculus of Shivers/Fisher, where findf could be: (: findf (Any (Element) (-> Element Boolean) (Listof Element) )) Here are there are two return points, , found and not found. This pattern does show up occasionally in plain old racket code. Sometimes the pattern translates easily to TR, but sometimes not. In my looping "state machine" example, I had a scanner or parser in mind which would exit through one of the tails. > 2. Don't use polymorphism. Apparently. I was trying to figure out if this is something I don't know how to annotate properly, or something that really requires a code transformation to type. > 3. Think about the algorithm. This hint comes in the form of a cps > algorithm: Thank you for the cps converter. I'm not sure if it is relevant to the intended question, but I think I will write the evaluator you suggest as an exercise. -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From acarrico at memebeam.org Fri Sep 5 15:53:59 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Fri, 05 Sep 2014 15:53:59 -0400 Subject: [racket] Submodules can't be imported in same file? In-Reply-To: References: Message-ID: <540A14D7.30605@memebeam.org> Look at the grammer in http://docs.racket-lang.org/reference/require.html, you use something like (submod "." wrap). -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From skanaley at gmail.com Fri Sep 5 16:11:43 2014 From: skanaley at gmail.com (Sean Kanaley) Date: Fri, 5 Sep 2014 16:11:43 -0400 Subject: [racket] Submodules can't be imported in same file? In-Reply-To: <540A14D7.30605@memebeam.org> References: <540A14D7.30605@memebeam.org> Message-ID: (reply to all) Right but that doesn't work from within the file, only at REPL or another file. #lang racket (module+ invisible (provide x) (define x 3)) (require (submod "." invisible)) doesn't work -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Fri Sep 5 16:44:23 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Fri, 5 Sep 2014 14:44:23 -0600 Subject: [racket] Snapshot builds In-Reply-To: References: Message-ID: <20140905204425.BCC9965018E@mail-svr1.cs.utah.edu> At Thu, 4 Sep 2014 20:48:43 +0100, Steve Lloyd wrote: > I recently ?discovered? (thanks to a tweet from @dkvansnickajr) the snapshot > builds for ARM6 built on Raspbian. > Previously I?d been recommending people try out Racket on RasPi via the > source+built packages route, but realise they might baulk at the build times > and this other route seems very attractive in this respect. Can I just > sanity-check that this new approach is sensible? Yes, definitely. From gustavo at oma.org.ar Fri Sep 5 17:24:59 2014 From: gustavo at oma.org.ar (Gustavo Massaccesi) Date: Fri, 5 Sep 2014 18:24:59 -0300 Subject: [racket] Continuation marks Message-ID: I'm trying to add a continuation mark inside a function, but I want that the new mark to be visible after the functions returns. (Mostly for curiosity, not an actual problem.) I want something like this: ;-- #lang racket/base (define (display-cm-x) (displayln (continuation-mark-set->list (current-continuation-marks) 'x))) (define (add-cm-x v) '???) (define-syntax-rule (with-cm-x v body ...) (with-continuation-mark 'x v body ...)) (let () (display-cm-x) ;==>() (with-cm-x 7 (display-cm-x)) ;==>(7) (display-cm-x) ;==>() (add-cm-x 7) (display-cm-x) ;actual==>(), expected==>(7) ) ;-- The last line prints (), but I wish it prints (7). Gustavo From greghendershott at gmail.com Fri Sep 5 18:29:27 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Fri, 5 Sep 2014 18:29:27 -0400 Subject: [racket] Submodules can't be imported in same file? In-Reply-To: References: <540A14D7.30605@memebeam.org> Message-ID: The following approach works for me. Would that do what you need? ;; ----- mod.rkt ----- #lang racket (module private racket (define (secret) 'foo) (provide secret)) (require 'private) (define (wrapper) (secret)) (provide (all-defined-out)) ;; Note that all-defined-out will not provide stuff from 'private. ;; For that to happen, you would need to use (require (all-from-out ;; 'private)). So ... don't do that. ;; ----- use-mod.rkt ----- #lang racket (require "mod.rkt") (wrapper) ;; => 'foo (secret) ;; => error -- as desired From skanaley at gmail.com Fri Sep 5 19:23:53 2014 From: skanaley at gmail.com (Sean Kanaley) Date: Fri, 5 Sep 2014 19:23:53 -0400 Subject: [racket] Submodules can't be imported in same file? In-Reply-To: References: <540A14D7.30605@memebeam.org> Message-ID: Oh of course, I had inverted the hierarchy of modules. Your way is much more logical, thanks. I got too sidetracked into what exactly module+ does... On Fri, Sep 5, 2014 at 6:29 PM, Greg Hendershott wrote: > The following approach works for me. Would that do what you need? > > ;; ----- mod.rkt ----- > #lang racket > > (module private racket > (define (secret) > 'foo) > (provide secret)) > > (require 'private) > > (define (wrapper) > (secret)) > > (provide (all-defined-out)) > ;; Note that all-defined-out will not provide stuff from 'private. > ;; For that to happen, you would need to use (require (all-from-out > ;; 'private)). So ... don't do that. > > > ;; ----- use-mod.rkt ----- > #lang racket > > (require "mod.rkt") > (wrapper) ;; => 'foo > (secret) ;; => error -- as desired > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Fri Sep 5 20:21:21 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 5 Sep 2014 20:21:21 -0400 Subject: [racket] Continuation marks In-Reply-To: References: Message-ID: A continuation represents the rest of the computation with respect to a sub-computation, e.g., a procedure call. After a return from a procedure call, anything having to do is gone. In Racket, you can grab this continuation, including pieces from sub-sub-computations within the extent of the procedure call. Grabing means you turn them into a value within the language. And on those continuations you can find the marks. By reinstalling these continuations, you can get the marks back. On Sep 5, 2014, at 5:24 PM, Gustavo Massaccesi wrote: > I'm trying to add a continuation mark inside a function, but I want > that the new mark to be visible after the functions returns. (Mostly > for curiosity, not an actual problem.) > > I want something like this: > > ;-- > #lang racket/base > > (define (display-cm-x) > (displayln > (continuation-mark-set->list > (current-continuation-marks) 'x))) > > (define (add-cm-x v) > '???) > > (define-syntax-rule (with-cm-x v body ...) > (with-continuation-mark 'x v > body ...)) > > (let () > (display-cm-x) ;==>() > (with-cm-x 7 > (display-cm-x)) ;==>(7) > (display-cm-x) ;==>() > (add-cm-x 7) > (display-cm-x) ;actual==>(), expected==>(7) > ) > ;-- > > The last line prints (), but I wish it prints (7). > > Gustavo > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Fri Sep 5 21:37:30 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 5 Sep 2014 21:37:30 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <540A13A9.50204@memebeam.org> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> Message-ID: Would this do for you: #lang typed/racket (require typed/rackunit) (define-type Answer Boolean) (: find (All (?) (-> (-> ? Boolean) (Listof ?) (-> (Listof ?) Answer) (-> Answer) Answer))) (define (find pred? l sk fk) (cond [(empty? l) (fk)] [(pred? (first l)) (sk l)] [else (find pred? (rest l) sk fk)])) (check-equal? (find odd? '(2 3 4) (? (x) #t) (? () #f)) #t) On Sep 5, 2014, at 3:48 PM, Anthony Carrico wrote: > On 09/05/2014 11:48 AM, Matthias Felleisen wrote:> >> 1. Your programs don't look like conventional cps... > > I have distilled my "cps-ish" examples too far away from any context. A > concrete example of this pattern would be searching. The direct style is: > > (findf proc lst) -> any/c > > When I say "cps-ish", I'm talking about the following style: > > (find proc lst found-tail not-found-tail) > > the type turns out to be something like this: > > (: find (Any (Element FoundV NotFoundV) > (-> (-> Element Boolean) (Listof Element) > (-> Element FoundV) > (-> NotFoundV) > (U FoundV NotFoundV))) > > In my mind, the computation is essentially "returning" to either the > found-tail, or the not-found-tail. The result types of the tails are > irrelevant to the search computation; they don't show up in direct style > version. Another way to express this would be with two return points, in > the multi-return lambda calculus of Shivers/Fisher, where findf could be: > > (: findf (Any (Element) (-> Element Boolean) (Listof Element) Void>)) > > Here are there are two return points, , found and not found. > > This pattern does show up occasionally in plain old racket code. > Sometimes the pattern translates easily to TR, but sometimes not. In my > looping "state machine" example, I had a scanner or parser in mind which > would exit through one of the tails. > >> 2. Don't use polymorphism. > > Apparently. I was trying to figure out if this is something I don't know > how to annotate properly, or something that really requires a code > transformation to type. > >> 3. Think about the algorithm. This hint comes in the form of a cps >> algorithm: > > Thank you for the cps converter. I'm not sure if it is relevant to the > intended question, but I think I will write the evaluator you suggest as > an exercise. > > -- > Anthony Carrico > > From johnbclements at gmail.com Sat Sep 6 02:36:24 2014 From: johnbclements at gmail.com (John Clements) Date: Fri, 5 Sep 2014 23:36:24 -0700 Subject: [racket] Best typed/racket representation for bitfield of width 125? In-Reply-To: <878ulzji02.wl%stamourv@ccs.neu.edu> References: <878ulzji02.wl%stamourv@ccs.neu.edu> Message-ID: Is this a bug, or just a known limitation of typed racket? It looks like a fixnum can be up to 2^61, but the type checker for integer literals doesn't like them. This program: #lang typed/racket (require racket/fixnum) (define (ensure-fixnum i) (cond [(fixnum? i) i] [else (error 'ensure-fixnum)])) (fixnum? 281474976710656) ;; -> #t (: i Fixnum) (define i (ensure-fixnum 281474976710656)) works fine, but requires the ensure-fixnum, because the type checker does not believe that the literal 281474976710656 lives in fixnum. You can also see this at the top level, using (:print-type 281474976710656) Is this a bug, or is this just a known compromise to simplify the type-checker's portability and numeric tower? John On Thu, Sep 4, 2014 at 12:35 PM, Vincent St-Amour wrote: > Would an fxvector of length 5 (to account for the tag bits) work? > > If all you're doing is bitwise ops and comparisons, it should be easy to > convince TR that you're staying within fixnum range. > > Vincent > > > > > At Thu, 4 Sep 2014 10:45:48 -0700, > John Clements wrote: > > > > [1 ] > > [1.1 ] > > I want to represent a bitfield of 125 bits, using typed racket. I?ll be > > combining them using bitwise operations, and checking for zero-ness. I > > think that?s about it. > > > > I could just use type Integer, but it seems like that would impose > > additional checking, since the type system doesn?t know the size. In > > untyped racket I used a vector of four integers in the range 0-2^32, but > > those don?t fit in typed Racket?s ?Fixnum? because it uses a signed > > representation (and indeed, untyped racket may have been falling prey to > > the same problem. Perhaps I should break it up into four integers in the > > range 0-2^31? That seems weird, but maybe that?s my best choice? Or? I > > could use a byte string. > > > > Apologies if I?m missing something in the docs, here; I?ve spent a few > > minutes searching, without turning anything up. > > > > Thanks for any advice, > > > > John > > [1.2 ] > > > > [2 ] > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From samth at cs.indiana.edu Sat Sep 6 02:41:28 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Sat, 6 Sep 2014 02:41:28 -0400 Subject: [racket] Best typed/racket representation for bitfield of width 125? In-Reply-To: References: <878ulzji02.wl%stamourv@ccs.neu.edu> Message-ID: If you type check the file on a 64-bit system like yours, but then ran it on a 32-bit system, the fixnum range would change, making that number into a bignum. Sam On Sep 6, 2014 8:37 AM, "John Clements" wrote: > Is this a bug, or just a known limitation of typed racket? It looks like a > fixnum can be up to 2^61, but the type checker for integer literals doesn't > like them. This program: > > #lang typed/racket > > (require racket/fixnum) > > (define (ensure-fixnum i) > (cond [(fixnum? i) i] > [else (error 'ensure-fixnum)])) > > (fixnum? 281474976710656) ;; -> #t > (: i Fixnum) > (define i (ensure-fixnum 281474976710656)) > > works fine, but requires the ensure-fixnum, because the type checker does > not believe that the literal 281474976710656 lives in fixnum. > > You can also see this at the top level, using (:print-type 281474976710656) > > Is this a bug, or is this just a known compromise to simplify the > type-checker's portability and numeric tower? > > John > > > > > On Thu, Sep 4, 2014 at 12:35 PM, Vincent St-Amour > wrote: > >> Would an fxvector of length 5 (to account for the tag bits) work? >> >> If all you're doing is bitwise ops and comparisons, it should be easy to >> convince TR that you're staying within fixnum range. >> >> Vincent >> >> >> >> >> At Thu, 4 Sep 2014 10:45:48 -0700, >> John Clements wrote: >> > >> > [1 ] >> > [1.1 ] >> > I want to represent a bitfield of 125 bits, using typed racket. I?ll be >> > combining them using bitwise operations, and checking for zero-ness. I >> > think that?s about it. >> > >> > I could just use type Integer, but it seems like that would impose >> > additional checking, since the type system doesn?t know the size. In >> > untyped racket I used a vector of four integers in the range 0-2^32, but >> > those don?t fit in typed Racket?s ?Fixnum? because it uses a signed >> > representation (and indeed, untyped racket may have been falling prey to >> > the same problem. Perhaps I should break it up into four integers in the >> > range 0-2^31? That seems weird, but maybe that?s my best choice? Or? I >> > could use a byte string. >> > >> > Apologies if I?m missing something in the docs, here; I?ve spent a few >> > minutes searching, without turning anything up. >> > >> > Thanks for any advice, >> > >> > John >> > [1.2 ] >> > >> > [2 ] >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gustavo at oma.org.ar Sat Sep 6 10:36:37 2014 From: gustavo at oma.org.ar (Gustavo Massaccesi) Date: Sat, 6 Sep 2014 11:36:37 -0300 Subject: [racket] Continuation marks In-Reply-To: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> References: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> Message-ID: I agree that to get this output, using continuation marks is a bad idea. It'd be much better to use a parameter (or set!ing a global variable at a last resort). I'm trying to understand continuations marks. I'm reading some parts of the Racket compiler, and internally the functions have some flags that are not visible from the Racket code. One of the flags is 'preserves-marks. From http://docs.racket-lang.org/raco/decompile.html > The preserves-marks? field is true if calling the function is expected to leave continuation marks unchanged by the time it returns. So: Can a function change the continuation marks after it returns? What does that exactly mean? Can I use that to complete the code in my original e-mail? Is that a good idea for a real program? (The last question is easy: No. :) ) I also read the answer from Matthias Felleisen. I'm not sure that I understood it completely, but somehow it give me a new idea to solve this. But I need to try it before I'm sure it works. Gustavo On Fri, Sep 5, 2014 at 7:04 PM, John Clements wrote: > > On Sep 5, 2014, at 2:24 PM, Gustavo Massaccesi wrote: > >> I'm trying to add a continuation mark inside a function, but I want >> that the new mark to be visible after the functions returns. (Mostly >> for curiosity, not an actual problem.) >> >> I want something like this: >> >> ;-- >> #lang racket/base >> >> (define (display-cm-x) >> (displayln >> (continuation-mark-set->list >> (current-continuation-marks) 'x))) >> >> (define (add-cm-x v) >> '???) >> >> (define-syntax-rule (with-cm-x v body ...) >> (with-continuation-mark 'x v >> body ...)) >> >> (let () >> (display-cm-x) ;==>() >> (with-cm-x 7 >> (display-cm-x)) ;==>(7) >> (display-cm-x) ;==>() >> (add-cm-x 7) >> (display-cm-x) ;actual==>(), expected==>(7) >> ) >> ;-- >> >> The last line prints (), but I wish it prints (7). > > This is going to sound flip, but ? it sounds like you don?t want continuation marks. The whole point of continuation marks is that they?re associated with continuations, and will disappear when those continuations are gone. > > The example you give isn?t quite enough to figure out exactly what you want; it sounds like some combination of fluid-let and ? something else. > > Maybe you can describe why it is that you want this behavior? > > John > From clements at brinckerhoff.org Fri Sep 5 18:04:12 2014 From: clements at brinckerhoff.org (John Clements) Date: Fri, 5 Sep 2014 15:04:12 -0700 Subject: [racket] Continuation marks In-Reply-To: References: Message-ID: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> On Sep 5, 2014, at 2:24 PM, Gustavo Massaccesi wrote: > I'm trying to add a continuation mark inside a function, but I want > that the new mark to be visible after the functions returns. (Mostly > for curiosity, not an actual problem.) > > I want something like this: > > ;-- > #lang racket/base > > (define (display-cm-x) > (displayln > (continuation-mark-set->list > (current-continuation-marks) 'x))) > > (define (add-cm-x v) > '???) > > (define-syntax-rule (with-cm-x v body ...) > (with-continuation-mark 'x v > body ...)) > > (let () > (display-cm-x) ;==>() > (with-cm-x 7 > (display-cm-x)) ;==>(7) > (display-cm-x) ;==>() > (add-cm-x 7) > (display-cm-x) ;actual==>(), expected==>(7) > ) > ;-- > > The last line prints (), but I wish it prints (7). This is going to sound flip, but ? it sounds like you don?t want continuation marks. The whole point of continuation marks is that they?re associated with continuations, and will disappear when those continuations are gone. The example you give isn?t quite enough to figure out exactly what you want; it sounds like some combination of fluid-let and ? something else. Maybe you can describe why it is that you want this behavior? John From mflatt at cs.utah.edu Sat Sep 6 12:19:53 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sat, 6 Sep 2014 10:19:53 -0600 Subject: [racket] Continuation marks In-Reply-To: References: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> Message-ID: <20140906161955.6AE2E650190@mail-svr1.cs.utah.edu> The 'preserves-marks flag makes sense only in the context of the JIT's implementation. At the Racket level, there's no way to write a function `f` so that (with-continuation-mark 'x 'my-value (begin (f) (continuation-mark-set-first #f 'x))) produces anything other than 'my-value. Even if `f` contains a `with-continuation-mark` form to set a mark with the key 'x, returning from `f` necessarily means leaving the dynamic extent of that form, so the mark will not be visible. It turns out that the JITted form of `with-continuation-mark` is not responsible for popping a mark stack as it returns. Instead, every non-tail position is wrapped with a kind of push and pop of the continuation-mark stack. Since `(f)` appears in a non-tail position within with `begin` form, the call with be wrapped. If `f` is known to not have a `with-continuation-mark` as a tail form, however, then the push and pop of the continuation-mark stack will not be necessary around the `(f)` call. The 'preserves-marks flag tells the JIT that it can make that assumption. (In retrospect, a better name would be 'has-no-wcm-in-tail-position.) At Sat, 6 Sep 2014 11:36:37 -0300, Gustavo Massaccesi wrote: > I agree that to get this output, using continuation marks is a bad > idea. It'd be much better to use a parameter (or set!ing a global > variable at a last resort). > > I'm trying to understand continuations marks. I'm reading some parts > of the Racket compiler, and internally the functions have some flags > that are not visible from the Racket code. > > One of the flags is 'preserves-marks. From > http://docs.racket-lang.org/raco/decompile.html > > > The preserves-marks? field is true if calling the function is expected to > leave continuation marks unchanged by the time it returns. > > So: Can a function change the continuation marks after it returns? > What does that exactly mean? Can I use that to complete the code in my > original e-mail? Is that a good idea for a real program? > > (The last question is easy: No. :) ) > > > I also read the answer from Matthias Felleisen. I'm not sure that I > understood it completely, but somehow it give me a new idea to solve > this. But I need to try it before I'm sure it works. > > > Gustavo > > On Fri, Sep 5, 2014 at 7:04 PM, John Clements wrote: > > > > On Sep 5, 2014, at 2:24 PM, Gustavo Massaccesi wrote: > > > >> I'm trying to add a continuation mark inside a function, but I want > >> that the new mark to be visible after the functions returns. (Mostly > >> for curiosity, not an actual problem.) > >> > >> I want something like this: > >> > >> ;-- > >> #lang racket/base > >> > >> (define (display-cm-x) > >> (displayln > >> (continuation-mark-set->list > >> (current-continuation-marks) 'x))) > >> > >> (define (add-cm-x v) > >> '???) > >> > >> (define-syntax-rule (with-cm-x v body ...) > >> (with-continuation-mark 'x v > >> body ...)) > >> > >> (let () > >> (display-cm-x) ;==>() > >> (with-cm-x 7 > >> (display-cm-x)) ;==>(7) > >> (display-cm-x) ;==>() > >> (add-cm-x 7) > >> (display-cm-x) ;actual==>(), expected==>(7) > >> ) > >> ;-- > >> > >> The last line prints (), but I wish it prints (7). > > > > This is going to sound flip, but ? it sounds like you don?t want continuation > marks. The whole point of continuation marks is that they?re associated with > continuations, and will disappear when those continuations are gone. > > > > The example you give isn?t quite enough to figure out exactly what you want; > it sounds like some combination of fluid-let and ? something else. > > > > Maybe you can describe why it is that you want this behavior? > > > > John > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From jensaxel at soegaard.net Sat Sep 6 12:28:19 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Sat, 6 Sep 2014 18:28:19 +0200 Subject: [racket] Continuation marks In-Reply-To: References: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> Message-ID: 2014-09-06 16:36 GMT+02:00 Gustavo Massaccesi : > I'm trying to understand continuations marks. The second chapter of Johns dissertation "Portable and high-level access to the stack with Continuation Marks" gives a nice introduction. http://www.brinckerhoff.org/clements/papers/dissertation.pdf -- Jens Axel S?gaard From acarrico at memebeam.org Sat Sep 6 13:46:38 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Sat, 06 Sep 2014 13:46:38 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> Message-ID: <540B487E.10705@memebeam.org> Even something like this won't type check: (define #:? (V) (fn (r : V)) : V (define (loop) : Void (loop)) r) So all that stuff about cps-ish code may be irrelevant. -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From matthias at ccs.neu.edu Sat Sep 6 13:58:47 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sat, 6 Sep 2014 13:58:47 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <540B487E.10705@memebeam.org> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> Message-ID: <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> This type checks fine in v6.1 though I can't read the dang syntax and I thought I was someone who should be able to do just that :-) On Sep 6, 2014, at 1:46 PM, Anthony Carrico wrote: > Even something like this won't type check: > > (define #:? (V) (fn (r : V)) : V > (define (loop) : Void (loop)) > r) > > So all that stuff about cps-ish code may be irrelevant. > > -- > Anthony Carrico > From matthias at ccs.neu.edu Sat Sep 6 14:00:09 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sat, 6 Sep 2014 14:00:09 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> Message-ID: p.s. I have figured out the syntax. I am not sure what you want with 'loop' but in any case, this all type checks. On Sep 6, 2014, at 1:58 PM, Matthias Felleisen wrote: > > This type checks fine in v6.1 though I can't read the dang syntax and I thought I was someone who should be able to do just that :-) > > > On Sep 6, 2014, at 1:46 PM, Anthony Carrico wrote: > >> Even something like this won't type check: >> >> (define #:? (V) (fn (r : V)) : V >> (define (loop) : Void (loop)) >> r) >> >> So all that stuff about cps-ish code may be irrelevant. >> >> -- >> Anthony Carrico >> > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From gustavo at oma.org.ar Sat Sep 6 19:31:57 2014 From: gustavo at oma.org.ar (Gustavo Massaccesi) Date: Sat, 6 Sep 2014 20:31:57 -0300 Subject: [racket] Continuation marks In-Reply-To: <20140906161955.6AE2E650190@mail-svr1.cs.utah.edu> References: <4A40AA5E-88DB-4E91-99BB-D6702125E951@brinckerhoff.org> <20140906161955.6AE2E650190@mail-svr1.cs.utah.edu> Message-ID: Thanks to everyone. It's much clearer now. I tried to get the same output anyway. This is the closest I could get. The example involves a little of "cheating", because the add-cm-x function actually never return in the traditional sense, but it use call/cc and abort/cc to get the same effect. Perhaps this can be "improved" with more work, but it was only a curiosity question to understand more about the continuation marks. ;-- #lang racket/base (define (display-cm-x) (display (continuation-mark-set->list (current-continuation-marks) 'x)) (display " first: ") (displayln (continuation-mark-set-first (current-continuation-marks) 'x))) (define prompt (make-continuation-prompt-tag 'temp)) (define (add-cm-x v) (call-with-composable-continuation (lambda (xx) (with-cm-x 7 (let ([r (xx (void))]) (abort-current-continuation prompt r)))))) (define-syntax-rule (with-cm-x v body ...) (with-continuation-mark 'x v body ...)) (call-with-continuation-prompt (lambda () (with-cm-x 0 (let () (display-cm-x) ;==>(0) first: 0 (with-cm-x 7 (display-cm-x)) ;==>(7 0) first: 7 (display-cm-x) ;==>(0) first: 0 (add-cm-x 7) (display "!") (display-cm-x) ;==>(0 7 0) first: 0 :( 333))) prompt (lambda (x) x)) (newline) (call-with-continuation-prompt (lambda () (let () (display-cm-x) ;==>() first: #f (with-cm-x 7 (display-cm-x)) ;==>(7) first: 7 (display-cm-x) ;==>() first: #f (add-cm-x 7) (display "!") (display-cm-x) ;==>(7) first: 7 :) 333)) prompt (lambda (x) x)) ;-- Gustavo On Sat, Sep 6, 2014 at 1:19 PM, Matthew Flatt wrote: > The 'preserves-marks flag makes sense only in the context of the JIT's > implementation. > > At the Racket level, there's no way to write a function `f` so that > > (with-continuation-mark > 'x > 'my-value > (begin > (f) > (continuation-mark-set-first #f 'x))) > > produces anything other than 'my-value. Even if `f` contains a > `with-continuation-mark` form to set a mark with the key 'x, returning > from `f` necessarily means leaving the dynamic extent of that form, so > the mark will not be visible. > > It turns out that the JITted form of `with-continuation-mark` is not > responsible for popping a mark stack as it returns. Instead, every > non-tail position is wrapped with a kind of push and pop of the > continuation-mark stack. Since `(f)` appears in a non-tail position > within with `begin` form, the call with be wrapped. > > If `f` is known to not have a `with-continuation-mark` as a tail form, > however, then the push and pop of the continuation-mark stack will not > be necessary around the `(f)` call. The 'preserves-marks flag tells the > JIT that it can make that assumption. (In retrospect, a better name > would be 'has-no-wcm-in-tail-position.) > > > At Sat, 6 Sep 2014 11:36:37 -0300, Gustavo Massaccesi wrote: >> I agree that to get this output, using continuation marks is a bad >> idea. It'd be much better to use a parameter (or set!ing a global >> variable at a last resort). >> >> I'm trying to understand continuations marks. I'm reading some parts >> of the Racket compiler, and internally the functions have some flags >> that are not visible from the Racket code. >> >> One of the flags is 'preserves-marks. From >> http://docs.racket-lang.org/raco/decompile.html >> >> > The preserves-marks? field is true if calling the function is expected to >> leave continuation marks unchanged by the time it returns. >> >> So: Can a function change the continuation marks after it returns? >> What does that exactly mean? Can I use that to complete the code in my >> original e-mail? Is that a good idea for a real program? >> >> (The last question is easy: No. :) ) >> >> >> I also read the answer from Matthias Felleisen. I'm not sure that I >> understood it completely, but somehow it give me a new idea to solve >> this. But I need to try it before I'm sure it works. >> >> >> Gustavo >> >> On Fri, Sep 5, 2014 at 7:04 PM, John Clements wrote: >> > >> > On Sep 5, 2014, at 2:24 PM, Gustavo Massaccesi wrote: >> > >> >> I'm trying to add a continuation mark inside a function, but I want >> >> that the new mark to be visible after the functions returns. (Mostly >> >> for curiosity, not an actual problem.) >> >> >> >> I want something like this: >> >> >> >> ;-- >> >> #lang racket/base >> >> >> >> (define (display-cm-x) >> >> (displayln >> >> (continuation-mark-set->list >> >> (current-continuation-marks) 'x))) >> >> >> >> (define (add-cm-x v) >> >> '???) >> >> >> >> (define-syntax-rule (with-cm-x v body ...) >> >> (with-continuation-mark 'x v >> >> body ...)) >> >> >> >> (let () >> >> (display-cm-x) ;==>() >> >> (with-cm-x 7 >> >> (display-cm-x)) ;==>(7) >> >> (display-cm-x) ;==>() >> >> (add-cm-x 7) >> >> (display-cm-x) ;actual==>(), expected==>(7) >> >> ) >> >> ;-- >> >> >> >> The last line prints (), but I wish it prints (7). >> > >> > This is going to sound flip, but ? it sounds like you don?t want continuation >> marks. The whole point of continuation marks is that they?re associated with >> continuations, and will disappear when those continuations are gone. >> > >> > The example you give isn?t quite enough to figure out exactly what you want; >> it sounds like some combination of fluid-let and ? something else. >> > >> > Maybe you can describe why it is that you want this behavior? >> > >> > John >> > >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From neil at neilvandyke.org Sat Sep 6 20:34:00 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Sat, 06 Sep 2014 20:34:00 -0400 Subject: [racket] gnucash and racket Message-ID: <540BA7F8.4060400@neilvandyke.org> What all have people done with using Racket with GnuCash? I know that John B. Clements wrote a package for doing reports from the ".gnucash" file. (My immediate motivation is that I'd like to be able to use my "html-template" Racket package to do reports that are integrated into the GnuCash interface, like the Guile reports are. Otherwise, I'll probably use this "eguile" HTML template thing.) Neil V. From hendrik at topoi.pooq.com Sat Sep 6 20:56:25 2014 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Sat, 6 Sep 2014 20:56:25 -0400 Subject: [racket] gnucash and racket In-Reply-To: <540BA7F8.4060400@neilvandyke.org> References: <540BA7F8.4060400@neilvandyke.org> Message-ID: <20140907005625.GA7496@topoi.pooq.com> On Sat, Sep 06, 2014 at 08:34:00PM -0400, Neil Van Dyke wrote: > What all have people done with using Racket with GnuCash? Racket I don't know. But the scripting language for gnucash, from the very beginning ages ago was guile, whch is a dialect of Scheme. In fact, at one time gnucash was a guile program that invoked code written in C (or C++?). That is, of course, how a scripting language is supposed to work. I gather that the current gnucash developer(s) have decided that they would like to distance themselves from guile. But it is still alive and well as its report generator. The main problem I have with using guile for generating reports is that I can find no documentation about the guile-gnucash interface. -- hendrik From lysseus at gmail.com Sat Sep 6 21:55:40 2014 From: lysseus at gmail.com (Kevin Forchione) Date: Sat, 6 Sep 2014 18:55:40 -0700 Subject: [racket] recursion style question Message-ID: Hi guys, Which is preferable? (define (foo let ? (acc empty)) ? (foo (rest let) ... (cons ?. acc)) or (define (foo lst ...) (let loop ([lst lst] ?[acc empty]) ? (loop (rest let) ? (cons ?. acc))) On the one hand we eliminate the named let construct, but on the other hand we expose the acc in the function / contract. If the acc is not something the caller would ever need to know about, should we hide it inside the definition? -Kevin From neil at neilvandyke.org Sat Sep 6 23:38:29 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Sat, 06 Sep 2014 23:38:29 -0400 Subject: [racket] gnucash and racket In-Reply-To: <20140907005625.GA7496@topoi.pooq.com> References: <540BA7F8.4060400@neilvandyke.org> <20140907005625.GA7496@topoi.pooq.com> Message-ID: <540BD335.7060204@neilvandyke.org> Hendrik Boom wrote at 09/06/2014 08:56 PM: > I gather that the current gnucash developer(s) have decided that > they would like to distance themselves from guile. But it is still > alive and well as its report generator. I was using Guile back when GnuCash was being developed in it. Guile seemed like a great choice for extension language for GnuCash, and still could be. (RMS was intending Guile to be the GNU extension/application language for all apps, which I suspect would've been Emacs-times-100 awesome, for how people make and share software enhancements, but events not Guile's fault ended that.) Anyway, this evening, having just made my first GnuCash report, by adapting "balsheet-eg"... I have to say that the eguile report scripts aren't as pleasant to work with as they could be. It's easy to imagine someone thinking, ``This is scary and painful, and would be better in Python.'' GnuCash *could* be made better to provide a better API in Guile than is possible in Python, but is not currently. I'm very fond of GnuCash overall, however. Neil V. From acarrico at memebeam.org Sat Sep 6 23:41:47 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Sat, 06 Sep 2014 23:41:47 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> Message-ID: <540BD3FB.8080308@memebeam.org> On 09/06/2014 02:00 PM, Matthias Felleisen wrote: > > p.s. I have figured out the syntax. I am not sure what you want with > 'loop' but in any case, this all type checks. It is just a very degenerate case of my problems, with everything else gone, an infinite loop nested in the most basic polymorphic type I could think of. > On Sep 6, 2014, at 1:58 PM, Matthias Felleisen wrote: >> This type checks fine in v6.1 though I can't read the dang syntax >> and I thought I was someone who should be able to do just that :-) LOL I had been using, Racket v6.0.0.5, but here is a machine with 6.0.1, and actually I just downloaded 6.1. All give the same answer: $ racket --version Welcome to Racket v6.1. $ cat loop.rkt #lang typed/racket/base (define #:? (V) (fn (r : V)) : V (define (loop) : Void (loop)) r) $ racket loop.rkt loop.rkt:4:10: Type Checker: insufficient type information to typecheck. please add more type annotations in: loop context...: /home/acarrico/src/racket/collects/racket/private/map.rkt:21:13: map /home/acarrico/src/racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt:147:26 ...etc. -- Anthony Carrico From matthias at ccs.neu.edu Sat Sep 6 23:44:05 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sat, 6 Sep 2014 23:44:05 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <540BD3FB.8080308@memebeam.org> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> <540BD3FB.8080308@memebeam.org> Message-ID: I am working with git head. -- Matthias On Sep 6, 2014, at 11:41 PM, Anthony Carrico wrote: > On 09/06/2014 02:00 PM, Matthias Felleisen wrote: >> >> p.s. I have figured out the syntax. I am not sure what you want with >> 'loop' but in any case, this all type checks. > > It is just a very degenerate case of my problems, with everything else gone, an infinite loop nested in the most basic polymorphic type I could think of. > >> On Sep 6, 2014, at 1:58 PM, Matthias Felleisen wrote: >>> This type checks fine in v6.1 though I can't read the dang syntax >>> and I thought I was someone who should be able to do just that :-) > > LOL > > I had been using, Racket v6.0.0.5, but here is a machine with 6.0.1, and actually I just downloaded 6.1. All give the same answer: > > $ racket --version > Welcome to Racket v6.1. > > $ cat loop.rkt > #lang typed/racket/base > > (define #:? (V) (fn (r : V)) : V > (define (loop) : Void (loop)) > r) > > $ racket loop.rkt > loop.rkt:4:10: Type Checker: insufficient type information to typecheck. please add more type annotations > in: loop > context...: > /home/acarrico/src/racket/collects/racket/private/map.rkt:21:13: map > /home/acarrico/src/racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt:147:26 > > > ...etc. > > -- > Anthony Carrico From greghendershott at gmail.com Sat Sep 6 23:50:12 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sat, 6 Sep 2014 23:50:12 -0400 Subject: [racket] recursion style question In-Reply-To: References: Message-ID: Well, I think you answer your own question with good reasons in the last paragraph. :) If `acc` is an implementation detail, let's not expose it as a parameter.[1] At least, let's not do this for a function provided by a module. Especially not a function with a contract and/or documentation. But if it's a helper function that's not provided? Especially in a small module? Then I'd say it doesn't matter so much. [1]: Not even a parameter with a default value of '(), which is a 3rd possibility -- a way to try to have your cake and eat it, too. You could even have provide/contract insist that the value be '(), for "outsiders"... but inside the module the contract is N/A. I actually did this once upon a time. I changed my mind when I started to write documentation for the function, got to that parameter, and realized... yeah, nope. :) On Sat, Sep 6, 2014 at 9:55 PM, Kevin Forchione wrote: > Hi guys, > Which is preferable? > > (define (foo let ? (acc empty)) ? (foo (rest let) ... (cons ?. acc)) > > or > > (define (foo lst ...) (let loop ([lst lst] ?[acc empty]) ? (loop (rest let) ? (cons ?. acc))) > > On the one hand we eliminate the named let construct, but on the other hand we expose the acc in the function / contract. If the acc is not something the caller would ever need to know about, should we hide it inside the definition? > > -Kevin > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From m4burns at uwaterloo.ca Sun Sep 7 00:41:51 2014 From: m4burns at uwaterloo.ca (Marc Burns) Date: Sun, 7 Sep 2014 00:41:51 -0400 Subject: [racket] recursion style question In-Reply-To: References: Message-ID: <04AE2352-877E-4616-B878-ED932B04E7F0@uwaterloo.ca> As Greg explained, the named let form simplifies the interface to other code. It is much more common in practice. > On Sep 6, 2014, at 23:50, Greg Hendershott wrote: > > Well, I think you answer your own question with good reasons in the > last paragraph. :) > > If `acc` is an implementation detail, let's not expose it as a parameter.[1] > > At least, let's not do this for a function provided by a module. > Especially not a function with a contract and/or documentation. > > But if it's a helper function that's not provided? Especially in a > small module? Then I'd say it doesn't matter so much. > > > [1]: Not even a parameter with a default value of '(), which is a 3rd > possibility -- a way to try to have your cake and eat it, too. You > could even have provide/contract insist that the value be '(), for > "outsiders"... but inside the module the contract is N/A. I actually > did this once upon a time. I changed my mind when I started to write > documentation for the function, got to that parameter, and realized... > yeah, nope. :) > > >> On Sat, Sep 6, 2014 at 9:55 PM, Kevin Forchione wrote: >> Hi guys, >> Which is preferable? >> >> (define (foo let ? (acc empty)) ? (foo (rest let) ... (cons ?. acc)) >> >> or >> >> (define (foo lst ...) (let loop ([lst lst] ?[acc empty]) ? (loop (rest let) ? (cons ?. acc))) >> >> On the one hand we eliminate the named let construct, but on the other hand we expose the acc in the function / contract. If the acc is not something the caller would ever need to know about, should we hide it inside the definition? >> >> -Kevin >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From alexander at knauth.org Sun Sep 7 08:20:17 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 7 Sep 2014 08:20:17 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <540BD3FB.8080308@memebeam.org> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> <540BD3FB.8080308@memebeam.org> Message-ID: <1401901D-66FC-4CB8-B1D7-872E592B4624@knauth.org> On Sep 6, 2014, at 11:41 PM, Anthony Carrico wrote: > On 09/06/2014 02:00 PM, Matthias Felleisen wrote: >> >> p.s. I have figured out the syntax. I am not sure what you want with >> 'loop' but in any case, this all type checks. > > It is just a very degenerate case of my problems, with everything else gone, an infinite loop nested in the most basic polymorphic type I could think of. > >> On Sep 6, 2014, at 1:58 PM, Matthias Felleisen wrote: >>> This type checks fine in v6.1 though I can't read the dang syntax >>> and I thought I was someone who should be able to do just that :-) > > LOL > > I had been using, Racket v6.0.0.5, but here is a machine with 6.0.1, and actually I just downloaded 6.1. All give the same answer: > > $ racket --version > Welcome to Racket v6.1. > > $ cat loop.rkt > #lang typed/racket/base > > (define #:? (V) (fn (r : V)) : V > (define (loop) : Void (loop)) > r) > > $ racket loop.rkt > loop.rkt:4:10: Type Checker: insufficient type information to typecheck. please add more type annotations > in: loop > context...: > /home/acarrico/src/racket/collects/racket/private/map.rkt:21:13: map > /home/acarrico/src/racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt:147:26 Well, that doesn?t type check for me on v6.1.0.5, but using (: loop : [-> Void]) fixes it: #lang typed/racket/base (: fn : (All (V) [V -> V])) (define (fn r) (: loop : [-> Void]) (define (loop) (loop)) r) > > > ...etc. > > -- > Anthony Carrico > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mflatt at cs.utah.edu Sun Sep 7 08:50:12 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 7 Sep 2014 06:50:12 -0600 Subject: [racket] v6.1 freeze on Windows: help needed Message-ID: <20140907125014.05B6665018E@mail-svr1.cs.utah.edu> Several users have reported problems with Racket v6.1 on Windows where DrRacket freezes. The reports have several details in common, I think: * When DrRacket freezes, it uses 0% CPU. * On machine where the problem happens, it happens consistently, and it doesn't take long after starting DrRacket. * No particular action within DrRacket is identified as a trigger, but in some cases, it might be related to switching the foreground window. * The previous release, v6.0.1, works fine on the same machine and configuration. The Windows variant doesn't seem to matter; we've received reports for 64-bit Windows 7 and 32-bit Windows XP, at least. Unfortunately, I haven't been able to provoke the freezing behavior on any of the Windows machines/installations that I have tried (about 6 of them, using various OS flavors, many different locations and ways of installing, administrator vs. non-administrator accounts, etc.). I think I must be missing a crucial ingredient --- maybe a particular kind of network filesystem or a particular other piece of software. If anyone else can provoke the freezing behavior, I'd appreciate information about your configuration and observations. Most useful, probably, would be a stack trace obtained by attaching Visual Studio to the process when DrRacket is frozen. Otherwise, if DrRacket freezes on some machines and not others, anything that you can say about the difference in the machines could be helpful. Thanks! From jensaxel at soegaard.net Sun Sep 7 10:02:04 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Sun, 7 Sep 2014 16:02:04 +0200 Subject: [racket] An FFI question Message-ID: Hi All, While reading the source of draw-lib/racket/draw/unsafe/cairo.rkt which contains the bindings of Cairo, I noticed the following note: ;; ALLOCATION NOTE: drawing to a Cairo surface might call back to ;; Racket, because a drawing suface might be a PDF or SVG file ;; that is written through a callback to Racket. Consequently, ;; all GC-allocated arguments to Cairo functions must be allocated ;; a 'atomic-interior, so that they do not move in case of a GC. This explains why _cairo_matrix_t is defined as: (define-cstruct _cairo_matrix_t ([xx _double*] [yx _double*] [xy _double*] [yy _double*] [x0 _double*] [y0 _double*]) #:malloc-mode 'atomic-interior) However _cairo_glyph_t is defined as: (define-cstruct _cairo_glyph_t ([index _long] [x _double*] [y _double*])) Why is the #:malloc-mode 'atomic-interior not needed here? https://github.com/plt/racket/blob/c18f6e8d6dd2afc095be6764c8276b30f7c8da39/pkgs/draw-pkgs/draw-lib/racket/draw/unsafe/cairo.rkt#L16 -- Jens Axel S?gaard From mflatt at cs.utah.edu Sun Sep 7 10:18:45 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 7 Sep 2014 08:18:45 -0600 Subject: [racket] An FFI question In-Reply-To: References: Message-ID: <20140907141847.609E265018E@mail-svr1.cs.utah.edu> The function that consumes a `_cairo_glyph_t-pointer` is passed an array of glyphs, instead of a single one. It would be fine to add the `#:malloc-mode 'atomic-interior` annotation, but that annotation will have no effect on the one use, because the array is not allocated with `make-cairo_glyph_t`. At Sun, 7 Sep 2014 16:02:04 +0200, Jens Axel S?gaard wrote: > Hi All, > > While reading the source of draw-lib/racket/draw/unsafe/cairo.rkt > which contains the bindings of Cairo, I noticed the following note: > > ;; ALLOCATION NOTE: drawing to a Cairo surface might call back to > ;; Racket, because a drawing suface might be a PDF or SVG file > ;; that is written through a callback to Racket. Consequently, > ;; all GC-allocated arguments to Cairo functions must be allocated > ;; a 'atomic-interior, so that they do not move in case of a GC. > > This explains why _cairo_matrix_t is defined as: > > (define-cstruct _cairo_matrix_t ([xx _double*] [yx _double*] [xy > _double*] [yy _double*] [x0 _double*] [y0 _double*]) > #:malloc-mode 'atomic-interior) > > However _cairo_glyph_t is defined as: > > (define-cstruct _cairo_glyph_t ([index _long] [x _double*] [y _double*])) > > Why is the #:malloc-mode 'atomic-interior not needed here? > > https://github.com/plt/racket/blob/c18f6e8d6dd2afc095be6764c8276b30f7c8da39/pkgs > /draw-pkgs/draw-lib/racket/draw/unsafe/cairo.rkt#L16 > > -- > Jens Axel S?gaard > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From edu500ac at gmail.com Sun Sep 7 12:54:01 2014 From: edu500ac at gmail.com (Eduardo Costa) Date: Sun, 7 Sep 2014 13:54:01 -0300 Subject: [racket] usb/serial port Message-ID: Racketeers. I work with a small research team that is building a navigation system for blind people. The hardware is similar to the one used in robotic vision: Cameras, sonar, GPS, laser measurement sensors, and the like. There are two sonar systems: (a) A sonar belt around the head to avoid hitting walls, light poles, etc. This sonar belt has 8 sonars. There is also a pair of sonars to avoid irregularities on the sidestep. This watch your step sonar also detects curbs, and activates a camera in charge of recognising zebra crossings. The Artificial Intelligence programs are mostly written in Lush. In fact, the idea is to use the deep learning libraries and image processing facilities provided in Lush. There are also Common Lisp libraries, like cl-viola-jones and opticl. The probability of hitting are calculated by using the Rasch method for each Artificial Intelligence library. Then the probabilities are combined through the Condorcet's theorem. Once one has the probability distribution, it is easy to design a gh-filter. For the time being, the servlets are written in Racket, except for the Rasch model that is written in Bigloo. As Junia reported to this list, the Rasch model written in Racket stopped working. Therefore Junia ported the Rasch model to Bigloo to perform the calibration of the system. The cameras use the image capture provided by Lush. However, our team designed custom hardware for the GPS, sonars and other sensors. This system sends the signal as a string via serial USB to a computer (OS-X or Linux), that feeds the servlets. Here is how I use it in OS-X 10.9.4: 1- I connect the sonar to a USB port. In this example, I will use the watch your step sonar. The sonar is supposed to rotate, in order to create a synthetic aperture sonar. However I fixed it to simplify the example. 2- I discover where is the sonar: Eduardos-Mac-mini:~ edu500ac$ ls /dev/tty.* /dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem1421 /dev/tty.Bluetooth-Modem 3- screen /dev/tty.usbmodem1421 9600 4- If I send D, I get a single reading of the sonar. If I send C, I get continuous reading. D Distancia = 00141 mm D Distancia = 00176 mm Dist. Error D Distancia = 01261 mm D Distancia = 01716 mm Distancia = 01452 mm Distancia = 01445 mm Distancia = 01447 mm Distancia = 01170 mm Distancia = 01713 mm Distancia = 00011 mm Distancia = 00085 mm Distancia = 00119 mm Distancia = 02698 mm Distancia = 00149 mm Distancia = 01852 mm Distancia = 01851 mm As you can see, we are trying to employ pr?t ? porter systems, like Lush (provided by Yann Lecun), deep learning (eblearn, provided by Koray Kavukcuoglu), opticl (provided by Cyrus Harmon), etc. Is there a Racket library for USB/serial communication with our equipment? I mean, is there something like OS-X screen written in Racket? I found the following answer to a similar question: I am not sure if there a library specifically written in racket for reading/writing to serial ports, however, you can read/write to character devices using standard i/o routines. Could a member of this list elaborate on this answer? For instance, how can I open a device from Racket? I tried: > (define out (open-output-file "/dev/tty.usbmodem1421")) . . ../../Applications/Racket v6.1/share/pkgs/drracket/drracket/private/rep.rkt:1123:24: open-output-file: cannot open output file path: /dev/tty.usbmodem1421 system error: Permission denied; errno=13 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mb at mbtype.com Sun Sep 7 14:18:53 2014 From: mb at mbtype.com (Matthew Butterick) Date: Sun, 7 Sep 2014 11:18:53 -0700 Subject: [racket] How `scribble` resolves relative paths In-Reply-To: <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> References: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> Message-ID: <1EAAAD42-3C2C-4DCA-B343-104BCAC1EC47@mbtype.com> I made a rudimentary helper macro called `image/rp` that upgrades a relative path-string into a runtime path: (define-syntax (image/rp stx) (syntax-case stx () [(_ name) #'(image/rp name 1.0)] [(_ name scale) #'(begin (define-runtime-path rp name) (image rp #:scale scale))])) Of course, the problem is that it disregards the interface for `image`, which includes keyword arguments. Is there a standard idiom for matching keyword arguments with `syntax-case` ... 1) To capture all keyword arguments and pass them through unaltered? 2) To unpack keyword arguments, alter them, and reapply them? On Sep 1, 2014, at 9:59 PM, Matthew Flatt wrote: > I think the docs are wrong. While `raco setup` does set the current > directory, `scribble` does not. > > It's better to use `define-runtime-path` instead of relying on the > current directory, since that composes better. > > At Mon, 1 Sep 2014 18:20:05 -0700, Matthew Butterick wrote: >> I am confused by this statement in the docs vs. the actual behavior: >> >> The docs for `image` say that "If path is a relative path, it is relative to >> the current directory, which is set by `raco setup` and `scribble` to the >> directory of the main document file." (I'm using `image` as an example but I've >> seen the same problem with CSS files.) >> >> Suppose I have a project set up like this: >> >> /project >> /scribblings >> main.scrbl >> sample.gif >> >> And "main.scrbl" contains this: >> >> #lang scribble/manual >> @image["sample.gif"] >> >> If I do this: >>> cd project >>> cd scribblings >>> scribble main.html >> >> The HTML will render fine. >> >> But if I do this: >> >>> cd project >>> scribble --dest-name doc scribblings/main.scrbl >> >> I'll get this error: >> >> open-input-file: cannot open input file >> path: /project/sample.gif >> >> Thus, the relative path "sample.gif" is being resolved relative to the >> directory where I invoke the `scribble` command, not the "directory of the main >> document file", which in both cases seems like it should be >> /project/scribblings (i.e., the directory containing "main.scrbl"). >> >> What am I misunderstanding? >> >> >> >> >> >> >> [1] >> http://docs.racket-lang.org/scribble/base.html?q=image#%28def._%28%28lib._scribb >> le%2Fbase..rkt%29._image%29%29____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From greghendershott at gmail.com Sun Sep 7 17:11:32 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 7 Sep 2014 17:11:32 -0400 Subject: [racket] How `scribble` resolves relative paths In-Reply-To: <1EAAAD42-3C2C-4DCA-B343-104BCAC1EC47@mbtype.com> References: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> <1EAAAD42-3C2C-4DCA-B343-104BCAC1EC47@mbtype.com> Message-ID: If you don't mind requiring that `name` be supplied first, you could simply pass the remaining args through unchanged: (define-syntax (image/rp stx) (syntax-case stx () [(_ name xs ...) #'(begin (define-runtime-path id name) (image id xs ...))])) It's not ideal because normally it should be fine to put the keyword arguments before the positional one. However if this is just a private helper macro it's probably fine. If you wanted, you could have the macro sanity check that `name` is not keyword? -- or more to the point, that it _is_ identifier?. (That kind of stuff is nice to declare with syntax-parse; it make a nice error message for you.) Separately, I think one gotcha with your original macro will be if you use it more than once? I think you need to provide a fresh id to each define-runtime-path, like so: (define-syntax (image/rp stx) (syntax-case stx () [(_ name xs ...) (with-syntax ([id (generate-temporary)]) #'(begin (define-runtime-path id name) (image id xs ...)))])) On Sun, Sep 7, 2014 at 2:18 PM, Matthew Butterick wrote: > I made a rudimentary helper macro called `image/rp` that upgrades a relative path-string into a runtime path: > > (define-syntax (image/rp stx) > (syntax-case stx () > [(_ name) #'(image/rp name 1.0)] > [(_ name scale) #'(begin > (define-runtime-path rp name) > (image rp #:scale scale))])) > > Of course, the problem is that it disregards the interface for `image`, which includes keyword arguments. > > Is there a standard idiom for matching keyword arguments with `syntax-case` ... > > 1) To capture all keyword arguments and pass them through unaltered? > 2) To unpack keyword arguments, alter them, and reapply them? > > > > On Sep 1, 2014, at 9:59 PM, Matthew Flatt wrote: > >> I think the docs are wrong. While `raco setup` does set the current >> directory, `scribble` does not. >> >> It's better to use `define-runtime-path` instead of relying on the >> current directory, since that composes better. >> >> At Mon, 1 Sep 2014 18:20:05 -0700, Matthew Butterick wrote: >>> I am confused by this statement in the docs vs. the actual behavior: >>> >>> The docs for `image` say that "If path is a relative path, it is relative to >>> the current directory, which is set by `raco setup` and `scribble` to the >>> directory of the main document file." (I'm using `image` as an example but I've >>> seen the same problem with CSS files.) >>> >>> Suppose I have a project set up like this: >>> >>> /project >>> /scribblings >>> main.scrbl >>> sample.gif >>> >>> And "main.scrbl" contains this: >>> >>> #lang scribble/manual >>> @image["sample.gif"] >>> >>> If I do this: >>>> cd project >>>> cd scribblings >>>> scribble main.html >>> >>> The HTML will render fine. >>> >>> But if I do this: >>> >>>> cd project >>>> scribble --dest-name doc scribblings/main.scrbl >>> >>> I'll get this error: >>> >>> open-input-file: cannot open input file >>> path: /project/sample.gif >>> >>> Thus, the relative path "sample.gif" is being resolved relative to the >>> directory where I invoke the `scribble` command, not the "directory of the main >>> document file", which in both cases seems like it should be >>> /project/scribblings (i.e., the directory containing "main.scrbl"). >>> >>> What am I misunderstanding? >>> >>> >>> >>> >>> >>> >>> [1] >>> http://docs.racket-lang.org/scribble/base.html?q=image#%28def._%28%28lib._scribb >>> le%2Fbase..rkt%29._image%29%29____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From acarrico at memebeam.org Sun Sep 7 19:52:17 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Sun, 07 Sep 2014 19:52:17 -0400 Subject: [racket] typed racket cps, state machines In-Reply-To: <1401901D-66FC-4CB8-B1D7-872E592B4624@knauth.org> References: <5409D2E8.2070903@memebeam.org> <02BB644D-7722-412C-8319-BD440CC03561@ccs.neu.edu> <540A13A9.50204@memebeam.org> <540B487E.10705@memebeam.org> <4DB683A6-0A63-43DE-AA7A-30C6CA34816C@ccs.neu.edu> <540BD3FB.8080308@memebeam.org> <1401901D-66FC-4CB8-B1D7-872E592B4624@knauth.org> Message-ID: <540CEFB1.4020806@memebeam.org> On 09/05/2014 03:48 PM, Anthony Carrico wrote:> On 09/05/2014 11:48 AM, > Apparently. I was trying to figure out if this is something I don't > know how to annotate properly, or ... and then, On 09/07/2014 08:20 AM, Alexander D. Knauth wrote: > (: fn : (All (V) [V -> V])) > (define (fn r) > (: loop : [-> Void]) > (define (loop) (loop)) > r) Awesome! It looks like I was bumping up against a bug, or limitation in the syntax that I was using to annotate internal definitions. I need to go back through this thread, and see if this fixes all my examples. Looks very promising. Thank you very much. -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From mb at mbtype.com Sun Sep 7 19:57:30 2014 From: mb at mbtype.com (Matthew Butterick) Date: Sun, 7 Sep 2014 16:57:30 -0700 Subject: [racket] How `scribble` resolves relative paths In-Reply-To: References: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> <1EAAAD42-3C2C-4DCA-B343-104BCAC1EC47@mbtype.com> Message-ID: <2D3A141D-8E29-484A-A60E-09AAC2A5DA7E@mbtype.com> > If you don't mind requiring that `name` be supplied first, you could > simply pass the remaining args through unchanged: For my purposes that's fine, though it's still a bit of a cheat. And cheating may not be an option next time ... > Separately, I think one gotcha with your original macro will be if you > use it more than once? I think you need to provide a fresh id to each > define-runtime-path, like so: I thought that would be the case too, though it does work without `generate-temporaries`. (Looking at the macro expansion, it seems each time the macro operates, it assigns a unique subscript to each "rp" identifier so they don't collide). But I can't tell if that's just lucky behavior. `Generate-temporaries` is clearly the right way to do things. Thanks. On Sep 7, 2014, at 2:11 PM, Greg Hendershott wrote: > If you don't mind requiring that `name` be supplied first, you could > simply pass the remaining args through unchanged: > > (define-syntax (image/rp stx) > (syntax-case stx () > [(_ name xs ...) > #'(begin > (define-runtime-path id name) > (image id xs ...))])) > > It's not ideal because normally it should be fine to put the keyword > arguments before the positional one. However if this is just a private > helper macro it's probably fine. If you wanted, you could have the > macro sanity check that `name` is not keyword? -- or more to the > point, that it _is_ identifier?. (That kind of stuff is nice to > declare with syntax-parse; it make a nice error message for you.) > > > Separately, I think one gotcha with your original macro will be if you > use it more than once? I think you need to provide a fresh id to each > define-runtime-path, like so: > > (define-syntax (image/rp stx) > (syntax-case stx () > [(_ name xs ...) > (with-syntax ([id (generate-temporary)]) > #'(begin > (define-runtime-path id name) > (image id xs ...)))])) > > > On Sun, Sep 7, 2014 at 2:18 PM, Matthew Butterick wrote: >> I made a rudimentary helper macro called `image/rp` that upgrades a relative path-string into a runtime path: >> >> (define-syntax (image/rp stx) >> (syntax-case stx () >> [(_ name) #'(image/rp name 1.0)] >> [(_ name scale) #'(begin >> (define-runtime-path rp name) >> (image rp #:scale scale))])) >> >> Of course, the problem is that it disregards the interface for `image`, which includes keyword arguments. >> >> Is there a standard idiom for matching keyword arguments with `syntax-case` ... >> >> 1) To capture all keyword arguments and pass them through unaltered? >> 2) To unpack keyword arguments, alter them, and reapply them? >> >> >> >> On Sep 1, 2014, at 9:59 PM, Matthew Flatt wrote: >> >>> I think the docs are wrong. While `raco setup` does set the current >>> directory, `scribble` does not. >>> >>> It's better to use `define-runtime-path` instead of relying on the >>> current directory, since that composes better. >>> >>> At Mon, 1 Sep 2014 18:20:05 -0700, Matthew Butterick wrote: >>>> I am confused by this statement in the docs vs. the actual behavior: >>>> >>>> The docs for `image` say that "If path is a relative path, it is relative to >>>> the current directory, which is set by `raco setup` and `scribble` to the >>>> directory of the main document file." (I'm using `image` as an example but I've >>>> seen the same problem with CSS files.) >>>> >>>> Suppose I have a project set up like this: >>>> >>>> /project >>>> /scribblings >>>> main.scrbl >>>> sample.gif >>>> >>>> And "main.scrbl" contains this: >>>> >>>> #lang scribble/manual >>>> @image["sample.gif"] >>>> >>>> If I do this: >>>>> cd project >>>>> cd scribblings >>>>> scribble main.html >>>> >>>> The HTML will render fine. >>>> >>>> But if I do this: >>>> >>>>> cd project >>>>> scribble --dest-name doc scribblings/main.scrbl >>>> >>>> I'll get this error: >>>> >>>> open-input-file: cannot open input file >>>> path: /project/sample.gif >>>> >>>> Thus, the relative path "sample.gif" is being resolved relative to the >>>> directory where I invoke the `scribble` command, not the "directory of the main >>>> document file", which in both cases seems like it should be >>>> /project/scribblings (i.e., the directory containing "main.scrbl"). >>>> >>>> What am I misunderstanding? >>>> >>>> >>>> >>>> >>>> >>>> >>>> [1] >>>> http://docs.racket-lang.org/scribble/base.html?q=image#%28def._%28%28lib._scribb >>>> le%2Fbase..rkt%29._image%29%29____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From greghendershott at gmail.com Sun Sep 7 21:02:45 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 7 Sep 2014 21:02:45 -0400 Subject: [racket] How `scribble` resolves relative paths In-Reply-To: <2D3A141D-8E29-484A-A60E-09AAC2A5DA7E@mbtype.com> References: <06C12393-DBFA-4961-BC81-3B9C6CB96317@mbtype.com> <20140902045905.B477B65018C@mail-svr1.cs.utah.edu> <1EAAAD42-3C2C-4DCA-B343-104BCAC1EC47@mbtype.com> <2D3A141D-8E29-484A-A60E-09AAC2A5DA7E@mbtype.com> Message-ID: >> Separately, I think one gotcha with your original macro will be if you >> use it more than once? I think you need to provide a fresh id to each >> define-runtime-path, like so: > > I thought that would be the case too, though it does work without `generate-temporaries`. (Looking at the macro expansion, it seems each time the macro operates, it assigns a unique subscript to each "rp" identifier so they don't collide). But I can't tell if that's just lucky behavior. `Generate-temporaries` is clearly the right way to do things. > Hmm, it definitely errors for me. And I see it expand duplicating the identifier. >> If you don't mind requiring that `name` be supplied first, you could >> simply pass the remaining args through unchanged: > > For my purposes that's fine, though it's still a bit of a cheat. And cheating may not be an option next time ... Here's another attempt that cheats a bit less. ;) I do make the image file name a required keyword argument, `#:path`: #lang racket/base (require (for-syntax racket/base racket/function racket/syntax syntax/parse) racket/pretty racket/runtime-path scribble/base) (define-syntax (image/rp stx) (define-splicing-syntax-class arg (pattern (~seq kw:keyword e:expr)) (pattern (~seq e:expr))) (syntax-parse stx [(_ arg:arg ...) (define all-args (syntax->list #'(arg ...))) (define (path-arg stx) (syntax-parse stx [(#:path path:expr) #'path] [_ #f])) (with-syntax ([id (generate-temporary)] [path (ormap path-arg all-args)] [((other-args ...) ...) (filter (negate path-arg) all-args)]) (unless (syntax-e #'path) (raise-syntax-error 'image/rp "Required keyword argument #:path is missing")) #'(begin (define-runtime-path id path) (image id other-args ... ...)))])) Examples: (image/rp #:path "here.png") (image/rp #:scale 1.0 #:suffixes '() #:path "there.png"))))) ;; => (begin (define-runtime-path g1 "here.png") (image g1)) (begin (define-runtime-path g2 "there.png") (image g2 #:scale 1.0 #:suffixes '())) From f.raimondi at gmail.com Mon Sep 8 02:04:17 2014 From: f.raimondi at gmail.com (Franco Raimondi) Date: Mon, 8 Sep 2014 07:04:17 +0100 Subject: [racket] usb/serial port References: Message-ID: On 7 Sep 2014, at 17:54, Eduardo Costa wrote: > > I am not sure if there a library specifically written in racket for reading/writing to serial ports, however, you can read/write to character devices using standard i/o routines. > > Could a member of this list elaborate on this answer? For instance, how can I open a device from Racket? I tried: > >> (define out (open-output-file "/dev/tty.usbmodem1421")) > . . ../../Applications/Racket v6.1/share/pkgs/drracket/drracket/private/rep.rkt:1123:24: open-output-file: cannot open output file > path: /dev/tty.usbmodem1421 > system error: Permission denied; errno=13 >> open-output-file should work, are you sure you have the right permissions? This is what I use to write/read to/from an Arduino board connected using a USB port (where port-name is /dev/tty.usbmodem*" on mac, similar to your case): (system "stty -f " port-name " 57600 cs8 cread clocal") (set! out (open-output-file port-name #:mode 'binary #:exists 'append)) (set! in (open-input-file port-name #:mode 'binary)) (file-stream-buffer-mode out 'none) It works both on mac and linux. I have a separate thread to read the USB port, but it may not be necessary in your case. Have a look at open-firmata (line 414) of this file: https://bitbucket.org/fraimondi/racket-firmata/src/7707268b4b52aabe336c69d347877459dc8c7ae5/firmata.rkt?at=master if you want more information. This works also under Windows. F From dpavlov at ipa.nw.ru Mon Sep 8 14:17:07 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Mon, 08 Sep 2014 22:17:07 +0400 Subject: [racket] Text snip bleaches canvas space that does not belong to it Message-ID: <540DF2A3.5020707@ipa.nw.ru> Hello, I need a text snip on a canvas that paints itself strictly in some defined WxH bounds. I need no interactive moving or resizing, only interactive editing. Here is a code I have come up with, which also displays a window with the snip and a grid. The grid facilitates the visual check of the text snip bounds. (require racket/gui racket/draw) (define my-pasteboard% (class pasteboard% (super-new) (define/augment (can-select? snip on?) #f) (define/augment (can-interactive-move? snip) #f) (define/augment (can-interactive-resize? snip) #f))) (define frame (new frame% (label "Test"))) (define pasteboard (new my-pasteboard%)) (define my-canvas% (class editor-canvas% (super-new) (define/override (on-paint) (super on-paint) (define dc (send this get-dc)) ;; Draw a 10x10 grid with cell size 20x20 pixels (for ((x (in-range 10))) (send dc draw-line (* x 20) 0 (* x 20) 200)) (for ((y (in-range 10))) (send dc draw-line 0 (* y 20) 200 (* y 20))) ))) (define editor-canvas (new my-canvas% (editor pasteboard) (vertical-inset 0) (horizontal-inset 0) (parent frame) (style '(no-border no-hscroll no-vscroll)))) (send frame resize 200 200) (send frame show #t) (define text-obj (new text%)) (send text-obj insert "Hello" 0) (define text-snip (new editor-snip% (editor text-obj) (left-margin 0) (right-margin 0) (top-margin 0) (bottom-margin 0) (left-inset 0) (right-inset 0) (top-inset 0) (bottom-inset 0) (with-border? #f) (min-width 40) (max-width 40) (min-height 20) (max-height 20))) (send pasteboard insert text-snip 40 60) (send pasteboard set-caret-owner text-snip) When I click on the snip in the window and try to add a "!" character after the "Hello" text, I get this: http://imgur.com/cikwlqh It is obvious that the text snip (or something associated with it) expanded its supposed area of rendering by 3-4 pixels in all directions. And if I do silly things, like pressing "Enter", things get even worse. Can that be avoided somehow? Best regards, Dmitry From skanaley at gmail.com Mon Sep 8 17:23:59 2014 From: skanaley at gmail.com (Sean Kanaley) Date: Mon, 8 Sep 2014 17:23:59 -0400 Subject: [racket] DrRacket 6.1 or Hardware Issue? Message-ID: After investigating a near complete lock up some more (saved by TTY window and killing DrRacket after seeing it with 3GB+ residency), it's clearly correlated with background expansion of an accidentally infinitely looping macro. A few questions.. 1. Is the OS supposed to break and enter an infinite swap loop? If that is just a fact of life for a program requesting too much memory simultaneously (and an ever increasing amount), well for example ghc just shuts itself down claiming "too much memory requested" or something like that. 2. Is this related to my very long time ago issue where I removed a bad 1GB from the 3rd slot, lazily leaving the 4th slot where it is, causing me to have 3GB instead of 4, even though it's "supposed to" have 4 based on the max slot (I have never encountered this sort of system freeze before however)? Maybe the OS would more gracefully handle the paging? 3. Can DrRacket simply realize it's expanding the same thing and not demand infinite memory (I don't understand the system on the implementation level, sorry if that's off base). The solution, aside from me not writing incorrect macros is to disable background expansion. Relatedly, DrRacket doesn't seem able to reclaim this space without being restarted. Closing the file and clicking the garbage collection thing only recovers say 20MB out of 2GB if I turn off expansion before the OS locks. Lastly, a related possible bug I've encountered since 6.1 is the infinite garbage collection loop, where the OS remains responsive but DrRacket has to be restarted, but this one I have no idea where it comes from only that it seems to happen after a while, and fairly reliably so. -------------- next part -------------- An HTML attachment was scrubbed... URL: From m4burns at uwaterloo.ca Mon Sep 8 18:00:32 2014 From: m4burns at uwaterloo.ca (Marc Burns) Date: Mon, 8 Sep 2014 18:00:32 -0400 Subject: [racket] DrRacket 6.1 or Hardware Issue? In-Reply-To: References: Message-ID: <20140908220032.GU27226@happierface.uwaterloo.ca> 1. Generally, requests to allocate memory will succeed even when RAM is full and the system is deep into swap. Random access over a set of pages that cannot all fit into RAM results in "thrashing": continuously swapping pages out to the disk and reading other pages in. This can make the system unusable, and is independent of Racket. I'm not sure how GHC decides to terminate with the "too much memory requested" error, but I speculate it's a self-imposed limit perhaps based on the amount of accessible RAM. 2. I strongly doubt the issue is related to your memory configuration. If applications run well at normal memory pressure and the system is generally stable, the problem is likely caused by plain old swap thrashing. You could try booting off some Linux install disk and running memtest86+ to be sure. 3. I think implementing a time and memory limit for each background expansion attempt is a good idea. I don't know about the unreclaimable memory. That seems like a bug. On Mon, Sep 08, 2014 at 05:23:59PM -0400, Sean Kanaley wrote: > After investigating a near complete lock up some more (saved by TTY window > and killing DrRacket after seeing it with 3GB+ residency), it's clearly > correlated with background expansion of an accidentally infinitely looping > macro. A few questions.. > > 1. Is the OS supposed to break and enter an infinite swap loop? If that is > just a fact of life for a program requesting too much memory simultaneously > (and an ever increasing amount), well for example ghc just shuts itself > down claiming "too much memory requested" or something like that. > > 2. Is this related to my very long time ago issue where I removed a bad 1GB > from the 3rd slot, lazily leaving the 4th slot where it is, causing me to > have 3GB instead of 4, even though it's "supposed to" have 4 based on the > max slot (I have never encountered this sort of system freeze before > however)? Maybe the OS would more gracefully handle the paging? > > 3. Can DrRacket simply realize it's expanding the same thing and not demand > infinite memory (I don't understand the system on the implementation level, > sorry if that's off base). > > The solution, aside from me not writing incorrect macros is to disable > background expansion. Relatedly, DrRacket doesn't seem able to reclaim this > space without being restarted. Closing the file and clicking the garbage > collection thing only recovers say 20MB out of 2GB if I turn off expansion > before the OS locks. > > Lastly, a related possible bug I've encountered since 6.1 is the infinite > garbage collection loop, where the OS remains responsive but DrRacket has > to be restarted, but this one I have no idea where it comes from only that > it seems to happen after a while, and fairly reliably so. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Mon Sep 8 20:51:35 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 8 Sep 2014 20:51:35 -0400 Subject: [racket] missing solution 20.2.4 ex:fancy-contracts-poly In-Reply-To: References: Message-ID: On Sep 4, 2014, at 12:54 PM, Daniel Bastos wrote: > A candidate for a solution. (I'm not sure I'm correct regarding the > function project. The description says "a lists of lists" (which I > translate to (listof ITEM)) and "a function from lists to Xs", so I > wonder if the domain of this function-argument must be (listof ITEM) > or it could be more general such as (listof Y). I decided to imagine > that the domain of the function-argument would be items of the "list > of lists" and so I made it into (listof ITEM). In this context ITEM and X and Y are variables (placeholders) that stand for sets (classes) of data. In the following I have translated the purpose statements for these functions into prototype calls: > sort: (listof ITEM) (ITEM ITEM -> boolean) -> (listof ITEM) (sort a-list-of-Xs compare-Xs) : a-list-of-Xs (same Xs indeed, but rearranged) > map: ((listof ITEM) -> X) (listof ITEM) -> (listof X) (map a-function-from-item-on-list-to-X a-list-of-ITEMs) : a-list-of-Xs > project: (listof (listof ITEM)) ((listof ITEM) -> (listof X)) -> (listof X) (project a-list-of-list-of-ITEMs a-function-from-list-of-ITEMs-to-X) : a-list-of-Xs > (*) Comparison with exercise 20.2.2 Abstraction works by taking two concrete examples and replacing matching concrete things with variables. 20.2.2 asks you to come up with contracts for functions that work on one basic kind of data. Use a distinct kind and then apply the abstraction design recipe. You will find that at least one of the above is wrong. -- Matthias From matthias at ccs.neu.edu Mon Sep 8 20:51:37 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 8 Sep 2014 20:51:37 -0400 Subject: [racket] missing solution 20.1.1 ex:sem-funcs In-Reply-To: References: Message-ID: On Sep 2, 2014, at 11:45 AM, Daniel Bastos wrote: > A candidate for a solution. > > Exercise 20.1.1. Assume the Definitions window in DrScheme contains > (define (f x) x). Identify the values among the following expressions: > > (1) (cons f empty) > (2) (f f) > (3) (cons f (cons 10 (cons (f 10) empty))) > > Explain why they are values and why the remaining expressions are not > values. > > Solution. First we consider (1). Here's the relevant part of the > grammar. > > = empty | (cons ) > > = | | | empty | > | (names of defined functions) > | > > So (1) is a value because it is of the form (cons empty), > where f is because it is a defined function. > > Let's consider (3) before (2). (3) is a list of either or , > so (3) is as well. You checked only one half of the value-grammar for lst. Check the other half, too. Report back whether you want to change the answer or not. -- Matthias From matthias at ccs.neu.edu Mon Sep 8 20:51:43 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 8 Sep 2014 20:51:43 -0400 Subject: [racket] missing solution 20.2.2 ex:fancy-contracts In-Reply-To: References: Message-ID: <9B78EB6A-1772-4811-BFA7-2F8EC03CB6ED@ccs.neu.edu> Yes. On Sep 3, 2014, at 9:30 AM, Daniel Bastos wrote: > A candidate for a solution. > > Exercise 20.2.2. Formulate contracts for the following functions: > > 1. sort, which consumes a list of numbers and a function that consumes > two numbers (from the list) and produces a boolean; sort produces a > list of numbers. > > 2. map, which consumes a function from numbers to numbers and a list > of numbers; it also produces a list of numbers. > > 3. project, which consumes a list of lists of symbols and a function > from lists of symbols to symbols; it produces a list of symbols. > > Solution. > > sort: (listof number) (number number -> boolean) -> (listof number) > > map: (number -> number) (listof number) -> (listof number) > > project: (listof (listof symbol)) ((listof symbol) -> symbol) -> (listof symbol) > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Mon Sep 8 20:51:39 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 8 Sep 2014 20:51:39 -0400 Subject: [racket] missing solution 20.1.2 ex:syn-funcs In-Reply-To: References: Message-ID: <7E897494-BFBC-499C-B189-AFB890468E62@ccs.neu.edu> On Sep 2, 2014, at 12:05 PM, Daniel Bastos wrote: > Exercise 20.1.2. Argue why the following sentences are legal > definitions: > > (define (f x) (x 10)) > > (define (f x) f) > > (define (f x y) (x 'a y 'b)) > > Solution. The relevant part of the grammar is the following. > > = (define ( ...) ) > | (define ) > | (define-struct ( ...)) > > (*) First definition > > The LHS is a list of , since we find f and x as members of the > list and they're both variables. The RHS is a list consisting of a > and a . Small correction. Let's not call (x 10) a list. It's an application. '(x 10) would be a list and this one character is critical. > (*) Second definition > > Same LHS as the previous, so we need only check the RHS which is a > . is a valid form of , so we have > > (*) Third definition > > The LHS is ( ), while the RHS is ( > ), > > Therefore it's a legal . OKAY. From stevebyan at verizon.net Tue Sep 9 10:38:57 2014 From: stevebyan at verizon.net (Steve Byan) Date: Tue, 9 Sep 2014 10:38:57 -0400 Subject: [racket] Cut, copy, and paste keybindings not working on OS X with Racket 6.1 Message-ID: I just installed Racket 6.1, and noticed that the standard cut, copy, and paste keybindings aren't working on OS X 10.9.4. The Edit->Keybindings->Show All Keybindiings dialog shows that they are set to d:x, d:c, and d:v. Undo, which is bound to d:z, works as expected. Cut (Cmd-x) doesn't appear to do anything; paste (Cmd-v) acts like it is being interpreted as esc;v (previous-page), and copy (Cmd-c) acts like it is being interpreted as esc;c (capitalize-word). Best regards, -Steve -- Steve Byan Littleton, MA 01460 From stevebyan at verizon.net Tue Sep 9 10:57:42 2014 From: stevebyan at verizon.net (Steve Byan) Date: Tue, 9 Sep 2014 10:57:42 -0400 Subject: [racket] Cut, copy, and paste keybindings not working on OS X with Racket 6.1 In-Reply-To: References: Message-ID: <7F488959-21E4-4B31-81EC-67FD00024997@verizon.net> On Sep 9, 2014, at 10:38 AM, Steve Byan wrote: > I just installed Racket 6.1, and noticed that the standard cut, copy, and paste keybindings aren't working on OS X 10.9.4. The Edit->Keybindings->Show All Keybindiings dialog shows that they are set to d:x, d:c, and d:v. > > Undo, which is bound to d:z, works as expected. Cut (Cmd-x) doesn't appear to do anything; paste (Cmd-v) acts like it is being interpreted as esc;v (previous-page), and copy (Cmd-c) acts like it is being interpreted as esc;c (capitalize-word). Never mind, I just found the "Treat command key as meta" checkbox in the Preferences dialog. I should have read further in the manual. Best regards, -Steve -- Steve Byan Littleton, MA 01460 From geoff at knauth.org Tue Sep 9 11:32:06 2014 From: geoff at knauth.org (Geoffrey S. Knauth) Date: Tue, 9 Sep 2014 11:32:06 -0400 Subject: [racket] Emacs keybindings for DrRacket on Win8 platform Message-ID: <1CBB6D6D-58E7-43CE-9BCA-F9B192A10712@knauth.org> I usually run DrRacket on *nix platforms. When I run DrRacket on a Windows computer, how do I get my beloved Emacs keybindings? I've looked, but can't find the preference. Thanks, Geoff From geoff at knauth.org Tue Sep 9 11:36:16 2014 From: geoff at knauth.org (Geoffrey S. Knauth) Date: Tue, 9 Sep 2014 11:36:16 -0400 Subject: [racket] Emacs keybindings for DrRacket on Win8 platform In-Reply-To: <1CBB6D6D-58E7-43CE-9BCA-F9B192A10712@knauth.org> References: <1CBB6D6D-58E7-43CE-9BCA-F9B192A10712@knauth.org> Message-ID: <6DC86009-7345-4BC9-8A3F-0033BBD8759D@knauth.org> NEVER MIND. I figured it out. [Uncheck the Enable keybindings in menus preference.] --Geoff On Sep 9, 2014, at 11:32 , Geoffrey S. Knauth wrote: > I usually run DrRacket on *nix platforms. When I run DrRacket on a Windows computer, how do I get my beloved Emacs keybindings? I've looked, but can't find the preference. From mangpo at eecs.berkeley.edu Tue Sep 9 13:57:57 2014 From: mangpo at eecs.berkeley.edu (Mangpo Phitchaya Phothilimthana) Date: Tue, 9 Sep 2014 10:57:57 -0700 Subject: [racket] kill and check status of future Message-ID: Hi, I try to write a racket parallel program using future and touch. I want the main thread to be able to check the status of future object if it has already terminated for not, and able to kill future execution if timeout. These features exist for subprocess but I can't find these features for future. Best, Mangpo -------------- next part -------------- An HTML attachment was scrubbed... URL: From neil at neilvandyke.org Tue Sep 9 16:33:24 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Tue, 09 Sep 2014 16:33:24 -0400 Subject: [racket] racket loader/vm detecting out-of-date cached compiled files Message-ID: <540F6414.3040309@neilvandyke.org> Is there any low-hanging fruit for making the command-line Racket detect more cases in which some of the compiled files are out-of-date? Details... I have run into a few instances of undetected out-of-date compiled Racket code a few times in the last year. For example, today, after sys-admin did a code patch a production server, one part of the system gave this error when it was run: link: bad variable linkage; reference to a variable that has the wrong procedure or structure-type shape My guess in this case is that either the code was not recompiled (though it should be when they do "make run" of the system), or that the compile was wrong because the file mtimes were wrong (such as might happen with SVN with clock skew, or with "tar"). This was with Racket 5.3.4. (Incidentally, this particular system has a large number of files and a somewhat funny dependency graph, possibly bigger than DrRacket's or any other core Racket code. But my guess is that's not the cause of this problem.) We also ran into out-of-date compiled files once before in production, in the last year. Also involving some kind of update to the source files. And I have run into out-of-date compiles in development of my open source code and personal apps, perhaps several times in recent years. Usually when using DrRacket (perhaps alternating between DrRacket and command-line "racket"), and probably when I was doing heavy syntax transformer work (especially when the module-file graph was messier, before submodules simplified that greatly). Sometimes, it was obvious from things in error messages that an old compiled version of the code was being picked up from somewhere. This is not a huge problem, but if there's some easy and efficient checks that could be added, that would be a win. (Maybe there's already something like a file "stat" of source and corresponding compiled files, and some knowledge of the dependency graph that's consulted. If that's bulletproof, then I wonder whether it would make sense to supplement the mtime checking with checking embedding timestamps embedded *within* the compiled files, consulted separately from the mtimes. Though embedded timestamps might be significant work to do, when it's unclear whether bad mtimes are actually a problem for anyone in practice.) Neil From mb at mbtype.com Tue Sep 9 22:56:35 2014 From: mb at mbtype.com (Matthew Butterick) Date: Tue, 9 Sep 2014 19:56:35 -0700 Subject: [racket] racket loader/vm detecting out-of-date cached compiled files In-Reply-To: <540F6414.3040309@neilvandyke.org> References: <540F6414.3040309@neilvandyke.org> Message-ID: <676D1B90-019A-441B-8479-6BF9F1AD6AD6@mbtype.com> I also get similar "bad variable linkage" errors frequently with Racket. Deleting the "compiled" folder is always the cure. But it's not obvious from the error message why that should be so. On Sep 9, 2014, at 1:33 PM, Neil Van Dyke wrote: > Is there any low-hanging fruit for making the command-line Racket detect more cases in which some of the compiled files are out-of-date? > > Details... > > I have run into a few instances of undetected out-of-date compiled Racket code a few times in the last year. > > For example, today, after sys-admin did a code patch a production server, one part of the system gave this error when it was run: > > link: bad variable linkage; reference to a variable that has the wrong procedure or structure-type shape > > My guess in this case is that either the code was not recompiled (though it should be when they do "make run" of the system), or that the compile was wrong because the file mtimes were wrong (such as might happen with SVN with clock skew, or with "tar"). This was with Racket 5.3.4. (Incidentally, this particular system has a large number of files and a somewhat funny dependency graph, possibly bigger than DrRacket's or any other core Racket code. But my guess is that's not the cause of this problem.) > > We also ran into out-of-date compiled files once before in production, in the last year. Also involving some kind of update to the source files. > > And I have run into out-of-date compiles in development of my open source code and personal apps, perhaps several times in recent years. Usually when using DrRacket (perhaps alternating between DrRacket and command-line "racket"), and probably when I was doing heavy syntax transformer work (especially when the module-file graph was messier, before submodules simplified that greatly). Sometimes, it was obvious from things in error messages that an old compiled version of the code was being picked up from somewhere. > > This is not a huge problem, but if there's some easy and efficient checks that could be added, that would be a win. (Maybe there's already something like a file "stat" of source and corresponding compiled files, and some knowledge of the dependency graph that's consulted. If that's bulletproof, then I wonder whether it would make sense to supplement the mtime checking with checking embedding timestamps embedded *within* the compiled files, consulted separately from the mtimes. Though embedded timestamps might be significant work to do, when it's unclear whether bad mtimes are actually a problem for anyone in practice.) > > Neil > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dbastos at toledo.com Wed Sep 10 13:02:14 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Wed, 10 Sep 2014 14:02:14 -0300 Subject: [racket] htdp: functions of section 19 violate the grammar of section 8 Message-ID: I have not been able to verify this statement. "As a matter of fact, the functions of section 19 violate the Scheme grammar of section 8." -- First paragraph of section 20. I think the statement is referring to functions such as filter1. (define (filter1 rel-op alon t) (cond [(empty? alon) empty] [else (cond [(rel-op (first alon) t) (cons (first alon) (filter1 rel-op (rest alon) t))] [else (filter1 rel-op (rest alon) t)])])) It must be because of rel-op, I figure. But rel-op is a . According to Figure 21 (the grammar of section 8), ( ...) is an , so I think filter1 doesn't violate the grammar of section 8. Where am I wrong? Thank you! From stchang at ccs.neu.edu Wed Sep 10 14:25:42 2014 From: stchang at ccs.neu.edu (Stephen Chang) Date: Wed, 10 Sep 2014 14:25:42 -0400 Subject: [racket] htdp: functions of section 19 violate the grammar of section 8 In-Reply-To: References: Message-ID: I believe it's answered in a subsequent paragraph? "The abstract functions of section 19 violate Scheme's basic grammar in two ways. First, the names of functions and primitive operations are used as arguments in applications. An argument, though, is an expression, and the class of expressions does not contain primitive operations and function names. It does contain variables, but we agreed that they are only those variables mentioned in variable definitions and as function parameters. Second, parameters are used as if they were functions, that is, the first position of applications. But the grammar of section 8 allows only the names of functions and primitive operations in this place." On Wed, Sep 10, 2014 at 1:02 PM, Daniel Bastos wrote: > I have not been able to verify this statement. > > "As a matter of fact, the functions of section 19 violate the Scheme > grammar of section 8." -- First paragraph of section 20. > > I think the statement is referring to functions such as filter1. > > (define (filter1 rel-op alon t) > (cond > [(empty? alon) empty] > [else (cond > [(rel-op (first alon) t) > (cons (first alon) > (filter1 rel-op (rest alon) t))] > [else > (filter1 rel-op (rest alon) t)])])) > > It must be because of rel-op, I figure. But rel-op is a . > According to Figure 21 (the grammar of section 8), ( > ...) is an , so I think filter1 doesn't violate the grammar > of section 8. > > Where am I wrong? Thank you! > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dbastos at toledo.com Wed Sep 10 14:57:58 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Wed, 10 Sep 2014 15:57:58 -0300 Subject: [racket] htdp: functions of section 19 violate the grammar of section 8 In-Reply-To: References: Message-ID: I remember having had that question when I was at that chapter. I must have thought I answered it, but I'm having it again and unable to answer now. IOW, I'm confused. I'm having difficulties with this phrase too. "First, the names of functions and primitive operations are used as arguments in applications." What is an argument in application? I'm going to try to answer it. An application is, according to the grammar of section 8, ( ...) or ( ...) So its arguments are , , ... and the final . Similarly, the second application has arguments , , ..., . Is that correct? Thank you. On Wed, Sep 10, 2014 at 3:25 PM, Stephen Chang wrote: > I believe it's answered in a subsequent paragraph? > > "The abstract functions of section 19 violate Scheme's basic grammar > in two ways. First, the names of functions and primitive operations > are used as arguments in applications. An argument, though, is an > expression, and the class of expressions does not contain primitive > operations and function names. It does contain variables, but we > agreed that they are only those variables mentioned in variable > definitions and as function parameters. Second, parameters are used as > if they were functions, that is, the first position of applications. > But the grammar of section 8 allows only the names of functions and > primitive operations in this place." From stchang at ccs.neu.edu Wed Sep 10 15:10:03 2014 From: stchang at ccs.neu.edu (Stephen Chang) Date: Wed, 10 Sep 2014 15:10:03 -0400 Subject: [racket] htdp: functions of section 19 violate the grammar of section 8 In-Reply-To: References: Message-ID: The arguments are the .... The function position is or Essentially, the grammar in sec20 extends sec8 with the ability to: - pass functions and primitives, like +, as arguments, and - compute the applied function in the function position instead of always using predefined s or s Does that make sense? On Wed, Sep 10, 2014 at 2:57 PM, Daniel Bastos wrote: > I remember having had that question when I was at that chapter. I must > have thought I answered it, but I'm having it again and unable to > answer now. IOW, I'm confused. > > I'm having difficulties with this phrase too. "First, the names of > functions and primitive operations are used as arguments in > applications." > > What is an argument in application? I'm going to try to answer it. An > application is, according to the grammar of section 8, > > ( ...) > > or > > ( ...) > > So its arguments are , , ... and the final . Similarly, > the second application has arguments , , ..., . Is that > correct? > > Thank you. > > On Wed, Sep 10, 2014 at 3:25 PM, Stephen Chang wrote: >> I believe it's answered in a subsequent paragraph? >> >> "The abstract functions of section 19 violate Scheme's basic grammar >> in two ways. First, the names of functions and primitive operations >> are used as arguments in applications. An argument, though, is an >> expression, and the class of expressions does not contain primitive >> operations and function names. It does contain variables, but we >> agreed that they are only those variables mentioned in variable >> definitions and as function parameters. Second, parameters are used as >> if they were functions, that is, the first position of applications. >> But the grammar of section 8 allows only the names of functions and >> primitive operations in this place." From johnbclements at gmail.com Wed Sep 10 17:03:13 2014 From: johnbclements at gmail.com (John Clements) Date: Wed, 10 Sep 2014 14:03:13 -0700 Subject: [racket] catalog pkg versioning: am I doing it right? Message-ID: It's possible to specify "version exceptions" in the new package catalog system (i.e., on pkg.racket-lang.org). I want to use one version (old version) for pre-6.0, and another one for >= 6.0. IIUC, the right way to do this is to specify a mapping for 'default to my pre-6 branch, and then explicit mappings for 6.0 and 6.1 to the new version. My questions: 1) how are version numbers matched? I just tried an experiment, and it looks like my version exceptions are confined to exact matches; e.g., when I have a version exception for 6.1, and I do a raco pkg catalog-show for 6.1.0.8, I get the default one. 2) This requires me to add an exception for every new version, right? Finally, I'm still kind of baffled by the pkg.racket-lang.org interface; it seems that when I make changes to a package and then close and re-open the floating window, my changes are still there, but that actually hitting browser reload often causes the changes to be lost. Am I just waiting for a change to propagate through a back-end database, here? Many thanks, John -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Wed Sep 10 17:26:54 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Wed, 10 Sep 2014 17:26:54 -0400 Subject: [racket] catalog pkg versioning: am I doing it right? In-Reply-To: References: Message-ID: On Wed, Sep 10, 2014 at 5:03 PM, John Clements wrote: > It's possible to specify "version exceptions" in the new package catalog > system (i.e., on pkg.racket-lang.org). I want to use one version (old > version) for pre-6.0, and another one for >= 6.0. IIUC, the right way to do > this is to specify a mapping for 'default to my pre-6 branch, and then > explicit mappings for 6.0 and 6.1 to the new version. > > My questions: > > 1) how are version numbers matched? I just tried an experiment, and it looks > like my version exceptions are confined to exact matches; e.g., when I have > a version exception for 6.1, and I do a raco pkg catalog-show for 6.1.0.8, I > get the default one. > 2) This requires me to add an exception for every new version, right? This sounds right. The versioning system was principally designed for dealing with keeping a small number of old Racket versions back on an old version of the package. Since there are a small number of versions since the package system existed, this seemed cheap. > Finally, I'm still kind of baffled by the pkg.racket-lang.org interface; it > seems that when I make changes to a package and then close and re-open the > floating window, my changes are still there, but that actually hitting > browser reload often causes the changes to be lost. Am I just waiting for a > change to propagate through a back-end database, here? When you make changes to a package's metadata, those changes are saved instantly (as soon as you press enter or de-focus the text input) and both your browser and the back-end server (modulo network errors.) Every time the back-end server receives a change, it updates the S3 cache. This updating process takes about X seconds and then S3 takes about Y seconds. If you reload your browser, you are throwing away your local copy with updated changes and getting the S3 cache. If you reload in under X+Y seconds (or your browser doesn't make the request at all), then you won't see any changes. Jay > Many thanks, > > John > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- Jay McCarthy 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&C 64:33 From ameliastahlman at gmail.com Wed Sep 10 20:29:53 2014 From: ameliastahlman at gmail.com (Amy Stahlman) Date: Wed, 10 Sep 2014 19:29:53 -0500 Subject: [racket] Possible bug with init-auto-scrollbars Message-ID: I've been working on a program that uses "init-auto-scrollbars" and I noticed that when the window is resized it actually changes the size of the virtual canvas along with the literal canvas instead of just resizing the scrollbar and changing the size of the literal canvas. Here's an example that shows this: *(require racket/gui)(define frame (new frame% [label "Example"] [width 300] [height 300]))(define canv (new canvas% [parent frame] [style '(vscroll hscroll)] [paint-callback (lambda (canvas dc)(send dc draw-ellipse 0 0 500 500))]))(send frame show #t)(send canv init-auto-scrollbars 500 500 0.0 0.0)* Resize the window, making it large enough to show the entire ellipse; notice how the scrollbar's relative size doesn't change, and there is blank space at the bottom. Is this by design or some kind of bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Wed Sep 10 20:46:54 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Wed, 10 Sep 2014 18:46:54 -0600 Subject: [racket] Possible bug with init-auto-scrollbars In-Reply-To: References: Message-ID: <20140911004655.A7029650194@mail-svr1.cs.utah.edu> That's a bug in v6.1 and earlier (on platforms other than Mac OS X). The bug has been fixed for the next version, so you could try a snapshot from http://pre.racket-lang.org/ If you need to stick with a different version, I think you can work around the bug by creating a `canvas%` subclass that calls `init-auto-scrollbars` on each `on-resize`: #lang racket (require racket/gui) (define frame (new frame% [label "Example"] [width 300] [height 300])) (define workaround-canvas% (class canvas% (super-new) (inherit init-auto-scrollbars) (define/override (on-size w h) (init-auto-scrollbars 500 500 0.0 0.0)))) (define canv (new workaround-canvas% [parent frame] [style '(vscroll hscroll)] [paint-callback (lambda (canvas dc) (send dc draw-ellipse 0 0 500 500))])) (send frame show #t) At Wed, 10 Sep 2014 19:29:53 -0500, Amy Stahlman wrote: > I've been working on a program that uses "init-auto-scrollbars" and I > noticed that when the window is resized it actually changes the size of the > virtual canvas along with the literal canvas instead of just resizing the > scrollbar and changing the size of the literal canvas. > > Here's an example that shows this: > > > > > > > > > > > > > > > *(require racket/gui)(define frame (new frame% [label > "Example"] [width 300] [height > 300]))(define canv (new canvas% [parent frame] [style '(vscroll > hscroll)] [paint-callback (lambda (canvas dc)(send > dc draw-ellipse 0 0 500 500))]))(send frame show #t)(send canv > init-auto-scrollbars 500 500 0.0 0.0)* > > Resize the window, making it large enough to show the entire ellipse; > notice how the scrollbar's relative size doesn't change, and there is blank > space at the bottom. > Is this by design or some kind of bug? > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From ameliastahlman at gmail.com Wed Sep 10 21:55:13 2014 From: ameliastahlman at gmail.com (Amy Stahlman) Date: Wed, 10 Sep 2014 20:55:13 -0500 Subject: [racket] Possible bug with init-auto-scrollbars In-Reply-To: <20140911004655.A7029650194@mail-svr1.cs.utah.edu> References: <20140911004655.A7029650194@mail-svr1.cs.utah.edu> Message-ID: On Wed, Sep 10, 2014 at 7:46 PM, Matthew Flatt wrote: > That's a bug in v6.1 and earlier (on platforms other than Mac OS X). > > The bug has been fixed for the next version, so you could try a > snapshot from > http://pre.racket-lang.org/ > > If you need to stick with a different version, I think you can work > around the bug by creating a `canvas%` subclass that calls > `init-auto-scrollbars` on each `on-resize`: > Thanks, the workaround works great for my program. Sincerely, Campbell Stahlman > > #lang racket > (require racket/gui) > > (define frame (new frame% > [label "Example"] > [width 300] > [height 300])) > > (define workaround-canvas% > (class canvas% > (super-new) > (inherit init-auto-scrollbars) > (define/override (on-size w h) > (init-auto-scrollbars 500 500 0.0 0.0)))) > > (define canv (new workaround-canvas% > [parent frame] > [style '(vscroll hscroll)] > [paint-callback > (lambda (canvas dc) > (send dc draw-ellipse 0 0 500 500))])) > > (send frame show #t) > > At Wed, 10 Sep 2014 19:29:53 -0500, Amy Stahlman wrote: > > I've been working on a program that uses "init-auto-scrollbars" and I > > noticed that when the window is resized it actually changes the size of > the > > virtual canvas along with the literal canvas instead of just resizing the > > scrollbar and changing the size of the literal canvas. > > > > Here's an example that shows this: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *(require racket/gui)(define frame (new frame% [label > > "Example"] [width 300] [height > > 300]))(define canv (new canvas% [parent frame] [style '(vscroll > > hscroll)] [paint-callback (lambda (canvas dc)(send > > dc draw-ellipse 0 0 500 500))]))(send frame show #t)(send canv > > init-auto-scrollbars 500 500 0.0 0.0)* > > > > Resize the window, making it large enough to show the entire ellipse; > > notice how the scrollbar's relative size doesn't change, and there is > blank > > space at the bottom. > > Is this by design or some kind of bug? > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From acarrico at memebeam.org Wed Sep 10 22:50:35 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Wed, 10 Sep 2014 22:50:35 -0400 Subject: [racket] TR predicate documentation, typo? Message-ID: <54110DFB.3000803@memebeam.org> In http://docs.racket-lang.org/ts-reference/type-ref.html 1.6 Other Type Constructors "The filter specifies that when (string? x) evaluates to a true value, the variable x can be assumed to have type String. Likewise, if the expression evaluates to #f, the variable has type String." I think there must be a typo here, what exactly happens if the expression evaluates to #f? -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From asumu at ccs.neu.edu Wed Sep 10 23:43:26 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Wed, 10 Sep 2014 23:43:26 -0400 Subject: [racket] TR predicate documentation, typo? In-Reply-To: <54110DFB.3000803@memebeam.org> References: <54110DFB.3000803@memebeam.org> Message-ID: <20140911034326.GC21882@localhost> On 2014-09-10 22:50:35 -0400, Anthony Carrico wrote: > "The filter specifies that when (string? x) evaluates to a true value, > the variable x can be assumed to have type String. Likewise, if the > expression evaluates to #f, the variable has type String." > > I think there must be a typo here, what exactly happens if the > expression evaluates to #f? You're right, that sentence doesn't make sense (my fault, I think). It should say that the variable is known to *not* have type String in branches where `(string? x)` evaluated to #f. Thanks, will fix it. Cheers, Asumu From zeppieri at gmail.com Thu Sep 11 00:56:12 2014 From: zeppieri at gmail.com (Jon Zeppieri) Date: Thu, 11 Sep 2014 00:56:12 -0400 Subject: [racket] possibility of defining recontract-all-from-out Message-ID: Rather than listing a large number of identifiers in a (recontract-out ...) spec, I'd like to re-contract everything from a certain required private module. I don't know how to do this. The crux of the problem is that syntax-local-module-required-identifiers can only be called while a provide transformer is running, but recontract-out is a provide pre-transformer. So, by the time I'm able to grab all of the identifiers from the required module, it's too late to make use of recontract-out (or contract-out). Is it even possible to do this? And, if so, is there a way to do it without duplicating much of racket/contract/private/out.rkt? -Jon From whukriede at gmail.com Thu Sep 11 06:00:01 2014 From: whukriede at gmail.com (Wolfgang Hukriede) Date: Thu, 11 Sep 2014 12:00:01 +0200 Subject: [racket] error writing to stream port (Broken pipe; errno=32) Message-ID: How am I supposed to catch: error writing to stream port (Broken pipe; errno=32) ? Thanks, Wolfgang From whukriede at gmail.com Thu Sep 11 06:26:00 2014 From: whukriede at gmail.com (Wolfgang Hukriede) Date: Thu, 11 Sep 2014 12:26:00 +0200 Subject: [racket] error writing to stream port (Broken pipe; errno=32) Message-ID: To expand a bit: the handling of the broken pipe seems okay to me, I just don't want to see the error message. Thanks! From whukriede at gmail.com Thu Sep 11 07:18:18 2014 From: whukriede at gmail.com (Wolfgang Hukriede) Date: Thu, 11 Sep 2014 13:18:18 +0200 Subject: [racket] error writing to stream port (Broken pipe; errno=32) Message-ID: Do I need to install a signal handler catching SIGPIPE? (Or replace the existing signal-handler?) Thanks! From matthias at ccs.neu.edu Thu Sep 11 08:01:38 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Thu, 11 Sep 2014 08:01:38 -0400 Subject: [racket] error writing to stream port (Broken pipe; errno=32) In-Reply-To: References: Message-ID: <0EFC27ED-01FE-4B47-A588-3F159121BD0C@ccs.neu.edu> (with-handlers ((exn:fail? (lambda (x) "let's throw away the exception from a closed port")) ... do stuff with ports and pipes ...) [[ You probably need to provide more context to get truly useful answers. ]] On Sep 11, 2014, at 7:18 AM, Wolfgang Hukriede wrote: > Do I need to install a signal handler catching SIGPIPE? (Or replace > the existing signal-handler?) > Thanks! > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Thu Sep 11 10:35:05 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Thu, 11 Sep 2014 10:35:05 -0400 Subject: [racket] possibility of defining recontract-all-from-out In-Reply-To: References: Message-ID: For a project last year, I developed a suite of syntactic abstractions that expand into contracted provides. With the core abstract you specify a header-file-like 'thing' and the exporting module(s) can then require this 'thing' to export identifiers. A re-export would work the same way. If my abstractions were robust enough, I'd put them on github but they aren't and I don't have the time to fortify them sufficiently now. But the idea is slightly different from yours and may help you think along different lines. -- Matthias On Sep 11, 2014, at 12:56 AM, Jon Zeppieri wrote: > Rather than listing a large number of identifiers in a (recontract-out > ...) spec, I'd like to re-contract everything from a certain required > private module. I don't know how to do this. The crux of the problem > is that syntax-local-module-required-identifiers can only be called > while a provide transformer is running, but recontract-out is a > provide pre-transformer. So, by the time I'm able to grab all of the > identifiers from the required module, it's too late to make use of > recontract-out (or contract-out). > > Is it even possible to do this? And, if so, is there a way to do it > without duplicating much of racket/contract/private/out.rkt? > > -Jon > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dbastos at toledo.com Thu Sep 11 17:34:44 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Thu, 11 Sep 2014 18:34:44 -0300 Subject: [racket] htdp: functions of section 19 violate the grammar of section 8 In-Reply-To: References: Message-ID: It makes sense, yes. I mean, the overall message. But I'm trying to pinpoint where the grammar of section 8 tells me "no, you cannot put a function name in an argument of an application". I read again the entire section 8, am reading section 19 again and I still don't see it. I'll write my argument and you'll spot a false statement somewhere. (By the way, I know the language Beginning Student doesn't allow a function name to be passed as an application argument. I've checked it.) It's clear that a primitive cannot be passed as an argument in the grammar of section 8. Here's my proof. An application in that grammar is of the form ( ...). Since primitives do not appear in this form, it cannot be present in an application. (We're done.) However, any expression /can/ be used as an application argument because an application is of the form ( ...). What are the possible expressions in the grammar of section 8? It begins with . When I define a user-defined function, its name is a . Therefore, any user-defined function's name is an expression and hence can appear in an application. But section 20 says that "[an argument [...] is an expression, and the class of expressions does not contain primitive operations and function names. It does contain variables, but we agreed that they are only those variables mentioned in variable definitions and as function parameters." This must be where the problem is. Where did we agree to that? I went back to section 8 to see what a is. "The first category is that of variables, which are the names of functions and values." So a names a function such as (define (f x) (* 2 x)) and so f should be allowed to appear as an application argument. Doesn't that follow from the text? Thank you! On Wed, Sep 10, 2014 at 4:10 PM, Stephen Chang wrote: > The arguments are the .... The function position is or > > Essentially, the grammar in sec20 extends sec8 with the ability to: > - pass functions and primitives, like +, as arguments, and > - compute the applied function in the function position instead of > always using predefined s or s > > Does that make sense? From zeppieri at gmail.com Fri Sep 12 10:20:17 2014 From: zeppieri at gmail.com (Jon Zeppieri) Date: Fri, 12 Sep 2014 10:20:17 -0400 Subject: [racket] possibility of defining recontract-all-from-out In-Reply-To: References: Message-ID: Matthias, Would you be willing to elaborate on this a bit? Specifically, how is the header specified? Thanks, Jon On Thu, Sep 11, 2014 at 10:35 AM, Matthias Felleisen wrote: > > For a project last year, I developed a suite of syntactic abstractions > that expand into contracted provides. With the core abstract you specify > a header-file-like 'thing' and the exporting module(s) can then require > this 'thing' to export identifiers. A re-export would work the same way. > > If my abstractions were robust enough, I'd put them on github but they > aren't and I don't have the time to fortify them sufficiently now. But > the idea is slightly different from yours and may help you think along > different lines. > > -- Matthias > > > > > > On Sep 11, 2014, at 12:56 AM, Jon Zeppieri wrote: > >> Rather than listing a large number of identifiers in a (recontract-out >> ...) spec, I'd like to re-contract everything from a certain required >> private module. I don't know how to do this. The crux of the problem >> is that syntax-local-module-required-identifiers can only be called >> while a provide transformer is running, but recontract-out is a >> provide pre-transformer. So, by the time I'm able to grab all of the >> identifiers from the required module, it's too late to make use of >> recontract-out (or contract-out). >> >> Is it even possible to do this? And, if so, is there a way to do it >> without duplicating much of racket/contract/private/out.rkt? >> >> -Jon >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > From matthias at ccs.neu.edu Fri Sep 12 10:47:20 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 12 Sep 2014 10:47:20 -0400 Subject: [racket] possibility of defining recontract-all-from-out In-Reply-To: References: Message-ID: <578676E7-627B-4C4B-AF19-50F57362648D@ccs.neu.edu> Does this sketch help: #lang racket ;; define a header file language (module L racket ;; specification (provide export) ;; ---------------------------------------------- ;; implementation (define-syntax (export stx) (syntax-case stx () [(_ file name ctc) #'(define-syntax (file stx) (syntax-case stx () [(_) ;; let's break hygiene here: (let* ([x '(provide (contract-out (name ctc)))] [y (datum->syntax stx x)]) y)]))]))) ;; ------------------------------------------------------- (module header-file racket (require (submod ".." L)) (provide provide-stack) ;; ----------------------------------------------------- (export provide-stack make (-> empty?))) (module good-server racket (require (submod ".." header-file)) (provide-stack) ;; ----------------------------------------------------- (define (make) '())) (module bad-server racket (require (submod ".." header-file)) (provide-stack) ;; ----------------------------------------------------- (define (make) "the empty stack")) (module client racket (provide (contract-out (test (-> (values string? string?))))) ;; ----------------------------------------------------- (require (prefix-in good: (submod ".." good-server)) (prefix-in bad: (submod ".." bad-server))) (define (test) (values (with-handlers ((exn:fail:contract? (lambda (_) "passed"))) (bad:make) "failed") (begin (good:make) "passed")))) ;; RUN BABY RUN (require 'client) (test) From zeppieri at gmail.com Fri Sep 12 11:39:36 2014 From: zeppieri at gmail.com (Jon Zeppieri) Date: Fri, 12 Sep 2014 11:39:36 -0400 Subject: [racket] possibility of defining recontract-all-from-out In-Reply-To: <578676E7-627B-4C4B-AF19-50F57362648D@ccs.neu.edu> References: <578676E7-627B-4C4B-AF19-50F57362648D@ccs.neu.edu> Message-ID: Yes, this is very helpful. Thank you. -Jon On Fri, Sep 12, 2014 at 10:47 AM, Matthias Felleisen wrote: > > Does this sketch help: > > #lang racket > > ;; define a header file language > (module L racket > ;; specification > (provide export) > ;; ---------------------------------------------- > ;; implementation > (define-syntax (export stx) > (syntax-case stx () > [(_ file name ctc) > #'(define-syntax (file stx) > (syntax-case stx () > [(_) > ;; let's break hygiene here: > (let* ([x '(provide (contract-out (name ctc)))] > [y (datum->syntax stx x)]) > y)]))]))) > > ;; ------------------------------------------------------- > (module header-file racket > (require (submod ".." L)) > (provide provide-stack) > ;; ----------------------------------------------------- > (export provide-stack make (-> empty?))) > > (module good-server racket > (require (submod ".." header-file)) > (provide-stack) > ;; ----------------------------------------------------- > (define (make) > '())) > > (module bad-server racket > (require (submod ".." header-file)) > (provide-stack) > ;; ----------------------------------------------------- > (define (make) > "the empty stack")) > > (module client racket > (provide > (contract-out > (test (-> (values string? string?))))) > ;; ----------------------------------------------------- > (require (prefix-in good: (submod ".." good-server)) > (prefix-in bad: (submod ".." bad-server))) > > (define (test) > (values > (with-handlers ((exn:fail:contract? (lambda (_) "passed"))) > (bad:make) > "failed") > (begin (good:make) "passed")))) > > ;; RUN BABY RUN > (require 'client) > (test) > > > > From dbastos at toledo.com Fri Sep 12 13:05:04 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Fri, 12 Sep 2014 14:05:04 -0300 Subject: [racket] missing solution 20.2.4 ex:fancy-contracts-poly In-Reply-To: References: Message-ID: On Mon, Sep 8, 2014 at 9:51 PM, Matthias Felleisen wrote: On Sep 4, 2014, at 12:54 PM, Daniel Bastos wrote: > > > A candidate for a solution. (I'm not sure I'm correct regarding the > > function project. The description says "a lists of lists" (which I > > translate to (listof ITEM)) and "a function from lists to Xs", so I > > wonder if the domain of this function-argument must be (listof ITEM) > > or it could be more general such as (listof Y). I decided to imagine > > that the domain of the function-argument would be items of the "list > > of lists" and so I made it into (listof ITEM). > > > In this context ITEM and X and Y are variables (placeholders) that stand > for sets (classes) of data. > > In the following I have translated the purpose statements for these > functions into prototype calls: > > > sort: (listof ITEM) (ITEM ITEM -> boolean) -> (listof ITEM) > > > (sort a-list-of-Xs compare-Xs) : a-list-of-Xs > (same Xs indeed, but rearranged) > > > map: ((listof ITEM) -> X) (listof ITEM) -> (listof X) > > (map a-function-from-item-on-list-to-X a-list-of-ITEMs) : a-list-of-Xs > > > > > project: (listof (listof ITEM)) ((listof ITEM) -> (listof X)) -> (listof > X) > > (project a-list-of-list-of-ITEMs a-function-from-list-of-ITEMs-to-X) : > a-list-of-Xs > > > (*) Comparison with exercise 20.2.2 > > Abstraction works by taking two concrete examples and replacing matching > concrete things with variables. > > 20.2.2 asks you to come up with contracts for functions that work on one > basic kind of data. Use a distinct kind and then apply the abstraction > design recipe. You will find that at least one of the above is wrong. Indeed. (That was map.) Thank you. (*) Candidate for solution for exercise 20.2.4 Our approach will be to take two concrete examples and replace matching concrete things with variables. (-) Sort sort1: (listof number) (number number -> boolean) -> (listof number) sort2: (listof name) (name name -> boolean) -> (listof name) sort: (listof ITEM) (ITEM ITEM -> boolean) -> (listof ITEM) Type variable: ITEM. (-) Map map1: (number -> number) (listof number) -> (listof number) map2: (name -> name) (listof name) -> (listof name) map: (x -> x) (listof x) -> (listof x) Type variable: x. (-) Project project1: (listof (listof symbol)) ((listof symbol) -> symbol) -> (listof symbol) project2: (listof (listof name)) ((listof name) -> name) -> (listof name) project: (listof (listof x)) ((listof x) -> x) -> (listof x) Type variable: x. -------------- next part -------------- An HTML attachment was scrubbed... URL: From whukriede at gmail.com Fri Sep 12 15:57:30 2014 From: whukriede at gmail.com (Wolfgang Hukriede) Date: Fri, 12 Sep 2014 21:57:30 +0200 Subject: [racket] error writing to stream port (Broken pipe; errno=32) Message-ID: Hi Matthias, nice to meet you! Yes, this was what I was looking for. For the records: (define (epipe? x) (and (exn:fail:filesystem:errno? x) (equal? '(32 . posix) (exn:fail:filesystem:errno-errno x)))) (define (epipe-handler x) "ignore") (with-handlers ((epipe? epipe-handler)) transput...) Many thanks! Results are mixed though. Usage like $ mzscheme --no-init-file --load pipetest.scm | head mostly works okay, but depending on how and how much is written to standard out and on the parameters to "head" failures reproducibly occur: in some situations the signal is not caught, yielding a "system error: Broken pipe; errno=32" message (versions 6.1 and 5.93 on freebsd, and 4.1 on generic linux, 6.1 precompiled racket on archlinux), or sometimes the pipe even just hangs (6.1 on freebsd). These were the combinations I tried. (On 4.1 exn:fail:filesystem was used instead of non-existing exn:fail:filesystem:errno.) From dbastos at toledo.com Fri Sep 12 16:40:14 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Fri, 12 Sep 2014 17:40:14 -0300 Subject: [racket] missing solution 20.1.1 ex:sem-funcs In-Reply-To: References: Message-ID: On Mon, Sep 8, 2014 at 9:51 PM, Matthias Felleisen wrote: On Sep 2, 2014, at 11:45 AM, Daniel Bastos wrote: > > > A candidate for a solution. > > > > Exercise 20.1.1. Assume the Definitions window in DrScheme contains > > (define (f x) x). Identify the values among the following expressions: > > > > (1) (cons f empty) > > (2) (f f) > > (3) (cons f (cons 10 (cons (f 10) empty))) > > > > Explain why they are values and why the remaining expressions are not > > values. > > > > Solution. First we consider (1). Here's the relevant part of the > > grammar. > > > > = empty | (cons ) > > > > = | | | empty | > > | (names of defined functions) > > | > > > > So (1) is a value because it is of the form (cons empty), > > where f is because it is a defined function. > > > > Let's consider (3) before (2). (3) is a list of either or , > > so (3) is as well. > > You checked only one half of the value-grammar for lst. Check the other > half, too. Report back whether you want to change the answer or not. -- > Matthias > I want to change it completely. I'm not very sure about what's going on. Perhaps the other half would be this: since is a value in this context because f is in fact a defined function, then we get (cons ) because empty is a too and then (cons ) = due to the definition of . Since any is a , we get a value. (Is that what you meant with 'check the other half'?) Here's my new complete attempt at the problem. (I ended up saying they're all values, due to the fact that we know f and f always yields values.) Exercise 20.1.1. Assume the Definitions window in DrScheme contains (define (f x) x). Identify the values among the following expressions: (1) (cons f empty) (2) (f f) (3) (cons f (cons 10 (cons (f 10) empty))) Explain why they are values and why the remaining expressions are not values. Solution. A value is anything of the form = | | | empty | | (names of defined functions) | where is of the form = empty | (cons ). Now we start with (1) and apply a series of substitutions based on the definitions we have. (cons f empty) = (cons ) ;; since f is a = (cons ) ;; since empty is a = (cons ) ;; since is a subset of = ;; definition of = ;; definition of Therefore (1) is a value. Next we consider (2). Here's the relevant part of the grammar. = | | ( ...) Again, we start with (2) and apply a series of substitutions. (f f) = ( ) ;; since f is a = ( ) ;; since is a subset of However, ( ) is not by definition a value. It is an expression which may or may not /have/ a value. We know the definition of f, however, which tells us that it behaves like the identity function. So the evaluation of that ( ) yields a function, which is a value. We end with = Therefore (2) is a value. Now (3). (cons f (cons 10 (cons (f 10) empty))) = (cons (cons (cons ( ) ))) Now again, the whole expressions depends on the application ( ), which may or may not have a value. Since that is a call to f, the identity function, we know it returns its argument, so = (cons (cons (cons ))) = (cons (cons (cons ))) ;; is a = (cons (cons )) ;; definition of = (cons (cons )) ;; is a = (cons ) ;; definition of = (cons ) ;; is a = ;; definition of = ;; is a Therefore (3) is a value. Thanks for your attention. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Fri Sep 12 17:43:46 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 12 Sep 2014 17:43:46 -0400 Subject: [racket] missing solution 20.1.1 ex:sem-funcs In-Reply-To: References: Message-ID: On Sep 12, 2014, at 4:40 PM, Daniel Bastos wrote: > Again, we start with (2) and apply a series of substitutions. > > (f f) > = ( ) ;; since f is a > = ( ) ;; since is a subset of > > However, ( ) is not by definition a value. It is an > expression which may or may not /have/ a value. We know the > definition of f, however, which tells us that it behaves like > the identity function. So the evaluation of that ( ) > yields a function, which is a value. We end with > > = > > Therefore (2) is a value Is there a difference between the statements "Daniel is a hat." and "Daniel has a hat." or do they really mean the same thing? In this spirit, is there a difference between the statement "(f f) is a value." and "(f f) has a value." or do they really mean the same thing? -- Matthias From robby at eecs.northwestern.edu Fri Sep 12 18:16:34 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Fri, 12 Sep 2014 17:16:34 -0500 Subject: [racket] DrRacket 6.1 or Hardware Issue? In-Reply-To: References: Message-ID: I've pushed a fix for DrRacket so that it limits online expansion to the same limits that are in place for running programs. Thanks, Robby On Mon, Sep 8, 2014 at 4:23 PM, Sean Kanaley wrote: > After investigating a near complete lock up some more (saved by TTY window > and killing DrRacket after seeing it with 3GB+ residency), it's clearly > correlated with background expansion of an accidentally infinitely looping > macro. A few questions.. > > 1. Is the OS supposed to break and enter an infinite swap loop? If that is > just a fact of life for a program requesting too much memory simultaneously > (and an ever increasing amount), well for example ghc just shuts itself down > claiming "too much memory requested" or something like that. > > 2. Is this related to my very long time ago issue where I removed a bad 1GB > from the 3rd slot, lazily leaving the 4th slot where it is, causing me to > have 3GB instead of 4, even though it's "supposed to" have 4 based on the > max slot (I have never encountered this sort of system freeze before > however)? Maybe the OS would more gracefully handle the paging? > > 3. Can DrRacket simply realize it's expanding the same thing and not demand > infinite memory (I don't understand the system on the implementation level, > sorry if that's off base). > > The solution, aside from me not writing incorrect macros is to disable > background expansion. Relatedly, DrRacket doesn't seem able to reclaim this > space without being restarted. Closing the file and clicking the garbage > collection thing only recovers say 20MB out of 2GB if I turn off expansion > before the OS locks. > > Lastly, a related possible bug I've encountered since 6.1 is the infinite > garbage collection loop, where the OS remains responsive but DrRacket has to > be restarted, but this one I have no idea where it comes from only that it > seems to happen after a while, and fairly reliably so. > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From uselpa.list at gmail.com Fri Sep 12 18:21:11 2014 From: uselpa.list at gmail.com (Patrick Useldinger) Date: Sat, 13 Sep 2014 00:21:11 +0200 Subject: [racket] integer-sqrt Message-ID: <541371D7.5090206@gmail.com> Hi all, according to the documentation, the above procedure accepts a *number* and returns an integer. But (at least in Racket 6.1) there's an error message stating that the parameter needs to be an *integer*: --------------------------------------- > (integer-sqrt 151.29) integer-sqrt: contract violation expected: integer? given: 151.29 --------------------------------------- Is this an error in the documentation or in the implementation? Regards, -Patrick From robby at eecs.northwestern.edu Fri Sep 12 18:27:50 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Fri, 12 Sep 2014 17:27:50 -0500 Subject: [racket] integer-sqrt In-Reply-To: <541371D7.5090206@gmail.com> References: <541371D7.5090206@gmail.com> Message-ID: The docs, I believe. Robby On Fri, Sep 12, 2014 at 5:21 PM, Patrick Useldinger wrote: > Hi all, > > according to the documentation, the above procedure accepts a *number* and > returns an integer. > > But (at least in Racket 6.1) there's an error message stating that the > parameter needs to be an *integer*: > > --------------------------------------- > > (integer-sqrt 151.29) > integer-sqrt: contract violation > expected: integer? > given: 151.29 > --------------------------------------- > > Is this an error in the documentation or in the implementation? > > Regards, > -Patrick > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mflatt at cs.utah.edu Fri Sep 12 18:34:22 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Fri, 12 Sep 2014 16:34:22 -0600 Subject: [racket] error writing to stream port (Broken pipe; errno=32) In-Reply-To: References: Message-ID: <20140912223424.5BA9565018C@mail-svr1.cs.utah.edu> To make the program concrete, suppose we have "a.rkt" as #lang racket/base (define (epipe? x) (and (exn:fail:filesystem:errno? x) (equal? '(32 . posix) (exn:fail:filesystem:errno-errno x)))) (define (epipe-handler x) "ignore") (with-handlers ([epipe? epipe-handler]) (let loop () (displayln "hi") (loop))) and then we run racket a.rkt | more and then we hit "q" to exit `more`. In that case, we will get error writing to stream port system error: Broken pipe; errno=32 The problem is that `epipe-handler` returns a string that becomes the result of the whole `with-handlers`. When Racket attempts to print that string, it fails (outside the `with-handlers`, of course). In other words, the exception reports the failure to print "ignore", not a failure from `(displayln "hi")`. In this little example, changing `epipe-handler` to (define (epipe-handler x) (void)) avoids the problem, because a void result isn't printed. Another solution is (define (epipe-handler x) (exit 0)) to immediately exit, instead of returning a value. At Fri, 12 Sep 2014 21:57:30 +0200, Wolfgang Hukriede wrote: > Hi Matthias, nice to meet you! Yes, this was what I was looking for. > > For the records: > > (define (epipe? x) > (and > (exn:fail:filesystem:errno? x) > (equal? '(32 . posix) (exn:fail:filesystem:errno-errno x)))) > > (define (epipe-handler x) > "ignore") > > (with-handlers > ((epipe? epipe-handler)) > transput...) > > Many thanks! > > Results are mixed though. Usage like > > $ mzscheme --no-init-file --load pipetest.scm | head > > mostly works okay, but depending on how and how much is written to > standard out and on the parameters to "head" failures reproducibly > occur: in some situations the signal is not caught, yielding a "system > error: Broken pipe; errno=32" message (versions 6.1 and 5.93 on > freebsd, and 4.1 on generic linux, 6.1 precompiled racket on > archlinux), or sometimes the pipe even just hangs (6.1 on freebsd). > These were the combinations I tried. > (On 4.1 exn:fail:filesystem was used instead of non-existing > exn:fail:filesystem:errno.) > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Fri Sep 12 18:42:39 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 12 Sep 2014 18:42:39 -0400 Subject: [racket] integer-sqrt In-Reply-To: References: <541371D7.5090206@gmail.com> Message-ID: <66074A93-14E0-4040-8F92-7A8860739974@ccs.neu.edu> The docs contradict themselves here :-) On Sep 12, 2014, at 6:27 PM, Robby Findler wrote: > The docs, I believe. > > Robby > > On Fri, Sep 12, 2014 at 5:21 PM, Patrick Useldinger > wrote: >> Hi all, >> >> according to the documentation, the above procedure accepts a *number* and >> returns an integer. >> >> But (at least in Racket 6.1) there's an error message stating that the >> parameter needs to be an *integer*: >> >> --------------------------------------- >>> (integer-sqrt 151.29) >> integer-sqrt: contract violation >> expected: integer? >> given: 151.29 >> --------------------------------------- >> >> Is this an error in the documentation or in the implementation? >> >> Regards, >> -Patrick >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From matthias at ccs.neu.edu Fri Sep 12 19:03:16 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Fri, 12 Sep 2014 19:03:16 -0400 Subject: [racket] integer-sqrt In-Reply-To: <541371D7.5090206@gmail.com> References: <541371D7.5090206@gmail.com> Message-ID: I have pushed a repair for the teaching languages. The Racket docs for git head seem to be okay. On Sep 12, 2014, at 6:21 PM, Patrick Useldinger wrote: > Hi all, > > according to the documentation, the above procedure accepts a *number* and returns an integer. > > But (at least in Racket 6.1) there's an error message stating that the parameter needs to be an *integer*: > > --------------------------------------- > > (integer-sqrt 151.29) > integer-sqrt: contract violation > expected: integer? > given: 151.29 > --------------------------------------- > > Is this an error in the documentation or in the implementation? > > Regards, > -Patrick > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From oev-racket at sibmail.com Sat Sep 13 10:28:10 2014 From: oev-racket at sibmail.com (Evgeny Odegov) Date: Sat, 13 Sep 2014 21:28:10 +0700 (NOVT) Subject: [racket] Some problem with hash-update! Message-ID: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> Hi, all! I have a problem with the code below: (define result (make-hash)) (define (callback dwTextID lpszInfoText lpvUser) (hash-update! result lpszInfoText (lambda (id-lst) (define v (list dwTextID)) (if id-lst (append id-lst v) v)) #f) #t) (The `callback' is passed to some enumeration function via FFI. Its type is defined as: (define _TXT_ENUM_INFOTEXTS_PROC (_cprocedure (list _DWORD _string/locale _pointer) _bool #:abi 'sysv)). It seems like problem not with FFI, but I could give more details if needed.) Mostly, parameter `lpszInfoText' is unique, so length of `is-lst' is rarely more than one. But, when there are lot of entries with empty `lpszInfoText', the list becomes big. At some moment something goes wrong, and my program fails with error: append: contract violation expected: list? given: (list* 80 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 602 603 604 605 606 607 608 609 610 612 613 614 615 616 617 618 619 621 622 623 624 625 626 627 628 629 631 632 633 634 635 636 637 638 640 641 642 6... I add a code that prints the wrong list before `append'. Result differs from run to run, but always belongs to one of two categories. Examples: * http://pastebin.com/bnNYY8EL * http://pastebin.com/x7nDdnWn If I change the code to below, it works without problems: (define result (make-hash)) (define big-list (list)) (define (callback dwTextID lpszInfoText lpvUser) (if (equal? lpszInfoText "") (set! big-list (cons dwTextID big-list)) (hash-update! result lpszInfoText (lambda (id-lst) (define v (list dwTextID)) (if id-lst (append id-lst v) v)) #f)) #t) Racket version: 6.1 release, x86, 32-bit OS: Windows XP Prof 32 bit From oev-racket at sibmail.com Sat Sep 13 11:45:28 2014 From: oev-racket at sibmail.com (Evgeny Odegov) Date: Sat, 13 Sep 2014 22:45:28 +0700 (NOVT) Subject: [racket] Some problem with hash-update! In-Reply-To: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> Message-ID: <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> Oh, I'm wrong. The last code is not equivalent to initial. The equivalent code has this problem: (define result (make-hash)) (define big-list (list)) (define (callback dwTextID lpszInfoText lpvUser) (if (equal? lpszInfoText "") (set! big-list (append big-list (list dwTextID))) (hash-update! result lpszInfoText (lambda (id-lst) (define v (list dwTextID)) (append id-lst v)) '())) #t) The code with `cons' instead `append' works fine: (define result (make-hash)) (define (callback dwTextID lpszInfoText lpvUser) (hash-update! result lpszInfoText (lambda (id-lst) (define new-id-lst (cons dwTextID id-lst)) (unless (list? new-id-lst) (error "~v" new-id-lst)) new-id-lst) '()) #t) From cody at cs.brown.edu Sun Sep 14 03:10:00 2014 From: cody at cs.brown.edu (Mello, Cody) Date: Sun, 14 Sep 2014 03:10:00 -0400 Subject: [racket] Setting umask from within Racket Message-ID: Hello everyone, Is there a way to set the umask of the process from within Racket? Or to specify the mode of a newly created file? I've been looking through the documentation, but I'm not finding anything along these lines. I was hoping that I could do something like the following from within my program: (parameterize ([umask #o007]) (display-to-file 5 "test-file")) Or like this: (display-to-file 5 "test-file" #:perms #o660) I could change the permissions of the file with file-or-directory-permissions after creating the file, but what I really want to do is create the file with those permissions from the start. Is there a good way to accomplish this? Am I missing something in the documentation? Thanks! - Cody -------------- next part -------------- An HTML attachment was scrubbed... URL: From neil at neilvandyke.org Sun Sep 14 04:09:53 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Sun, 14 Sep 2014 04:09:53 -0400 Subject: [racket] Setting umask from within Racket In-Reply-To: References: Message-ID: <54154D51.8050102@neilvandyke.org> If you don't find exactly the solution you want, possible measures: * If the concern is security, create the files in a directory on which you've set sufficiently restrictive permissions. (Even if you always set the file permissions immediately after opening the file for writing, there could be a race condition that lets the file be opened between create and permissions set.) * If you are ruthless, you could set the umask for entire process, using the FFI for the system call. * If you don't want to FFI, but you really-really want to second-guess the parent process's umask, you could kludge it in pure Racket plus host processes, at least on Unix-ish systems. Have the Racket program check its umask, and if not the desired one, use process/shell API to create a new process of the same Racket program, with the same command line, but under the new umask. * Consider writing your own pure Racket convenience procedures for opening files with desired permissions. (Maybe you could even have it secretly do tricks to do the non-atomic create and chmod securely without messing with FFI or umask. Some tricks of moving and copying files might occasionally run afoul of unusual situations in the filesystem, and of finer points of different filesystem semantics, but in practice, most people will never encounter any problems with simple tricks.) Side note: The Unix o/g/a-r/w/x permissions are pragmatic and archaic, so (like much of Unix) don't read too much into them, but they seem to have survived OK. And there seems to be less need for fancier ACLs and compartmentalization and such, now that we've moved most multi-user access control out of the filesystem and into Internet protocols and larger structures of same. And into VMs. Neil V. From brettstahlman at gmail.com Sun Sep 14 07:57:34 2014 From: brettstahlman at gmail.com (Brett Stahlman) Date: Sun, 14 Sep 2014 06:57:34 -0500 Subject: [racket] Possible bug involving sync on tcp ports Message-ID: Hello, I have the following loop in a tcp client program that sends forms typed by user at the terminal to a listening server, and receives such forms typed by other clients (broadcast to all clients by the server). (define server-msg-evt (wrap-evt in handle-server-msg)) (define rdy-to-send-evt (wrap-evt (standard-input-port) handle-rdy-to-send)) (let loop () (sync rdy-to-send-evt server-msg-evt) (loop)) The problem is that the server-msg-evt isn't reliably ready when the server flushes a message. I know the messages are being sent and flushed properly by the server because if I type a new form on stdin and hit enter, I see the following sequence: 1. Client processes new stdin form in handle-rdy-to-send 2. Client loops and calls sync 3. The server-msg-evt is *immediately* ready, and client handles the message in handle-server-msg. Note: The message handled in step 3 may have been sent long before, but the client remained blocked in sync until the (unrelated) stdin event unblocked it. The really weird part is that the client blocks in this manner even if I change the sync to a sync/timeout! Any clue as to what could be going on here? I'm running both client and server in a DOS box on a Windows 7 machine. Thanks, Brett Stahlman -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Sun Sep 14 08:40:07 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 14 Sep 2014 14:40:07 +0200 Subject: [racket] Some problem with hash-update! In-Reply-To: <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> Message-ID: <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> My best guess is that it's an issue with memory management, because memory management gets a lot trickier when you call a function that can call back into Racket. A GC can happen during the callback, and therefore during the dynamic extent of the foreign-function call, which can move arguments that were passed to the foreign function, for example. Would it be possible to provide a complete example? At Sat, 13 Sep 2014 22:45:28 +0700 (NOVT), "Evgeny Odegov" wrote: > Oh, I'm wrong. The last code is not equivalent to initial. > The equivalent code has this problem: > > (define result (make-hash)) > (define big-list (list)) > (define (callback dwTextID lpszInfoText lpvUser) > (if (equal? lpszInfoText "") > (set! big-list (append big-list (list dwTextID))) > (hash-update! result > lpszInfoText > (lambda (id-lst) > (define v (list dwTextID)) > (append id-lst v)) > '())) > #t) > > > The code with `cons' instead `append' works fine: > > (define result (make-hash)) > (define (callback dwTextID lpszInfoText lpvUser) > (hash-update! result > lpszInfoText > (lambda (id-lst) > (define new-id-lst (cons dwTextID id-lst)) > (unless (list? new-id-lst) > > (error "~v" new-id-lst)) > new-id-lst) > '()) > #t) > > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mflatt at cs.utah.edu Sun Sep 14 08:56:52 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 14 Sep 2014 14:56:52 +0200 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: References: Message-ID: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> It's possible that something is wrong with `sync` and TCP ports --- although the test suite at least includes that combination --- but can you provide a complete program? For example, I'm interested in what `handle-rdy-to-send` does. In the part that you show, the function will be triggered when one byte is available on stdin. If `handle-rdy-to-send` tries to read more bytes than are immediately available, then it can block; i.e., the blocking part could be in `handle-rdy-to-send`, not in `sync`. That would also explain why using `sync/timeout` doesn't change anything. Again, that's just an example of what might be wrong other than `sync`. A complete program would let us sort out the possibilities. At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: > Hello, > > I have the following loop in a tcp client program that sends forms typed by > user at the terminal to a listening server, and receives such forms typed by > other clients (broadcast to all clients by the server). > > (define server-msg-evt (wrap-evt in handle-server-msg)) > (define rdy-to-send-evt (wrap-evt (standard-input-port) handle-rdy-to-send)) > > (let loop () > (sync rdy-to-send-evt server-msg-evt) > (loop)) > > The problem is that the server-msg-evt isn't reliably ready when the server > flushes a message. I know the messages are being sent and flushed properly > by > the server because if I type a new form on stdin and hit enter, I see the > following sequence: > > 1. Client processes new stdin form in handle-rdy-to-send > 2. Client loops and calls sync > 3. The server-msg-evt is *immediately* ready, and client handles the > message in handle-server-msg. > Note: The message handled in step 3 may have been sent long before, but > the client remained blocked in sync until the (unrelated) stdin event > unblocked it. > > The really weird part is that the client blocks in this manner even if I > change the sync to a sync/timeout! > > Any clue as to what could be going on here? I'm running both client and > server > in a DOS box on a Windows 7 machine. > > Thanks, > Brett Stahlman > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From brettstahlman at gmail.com Sun Sep 14 09:20:26 2014 From: brettstahlman at gmail.com (Brett Stahlman) Date: Sun, 14 Sep 2014 08:20:26 -0500 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> Message-ID: On Sep 14, 2014 7:56 AM, "Matthew Flatt" wrote: > > It's possible that something is wrong with `sync` and TCP ports --- > although the test suite at least includes that combination --- but can > you provide a complete program? > > For example, I'm interested in what `handle-rdy-to-send` does. In the > part that you show, the function will be triggered when one byte is > available on stdin. If `handle-rdy-to-send` tries to read more bytes > than are immediately available, then it can block; i.e., the blocking > part could be in `handle-rdy-to-send`, not in `sync`. That would also > explain why using `sync/timeout` doesn't change anything. Actually, I know it's blocking in the sync (or sync/timeout) because the actual code is littered with immediately-flushed printf's, and there's one right before and one right after the sync call. I will try to put together a version to send you, though. Would you prefer it with the debug printf's stripped out? Thanks, Brett S. > > Again, that's just an example of what might be wrong other than `sync`. > A complete program would let us sort out the possibilities. > > At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: > > Hello, > > > > I have the following loop in a tcp client program that sends forms typed by > > user at the terminal to a listening server, and receives such forms typed by > > other clients (broadcast to all clients by the server). > > > > (define server-msg-evt (wrap-evt in handle-server-msg)) > > (define rdy-to-send-evt (wrap-evt (standard-input-port) handle-rdy-to-send)) > > > > (let loop () > > (sync rdy-to-send-evt server-msg-evt) > > (loop)) > > > > The problem is that the server-msg-evt isn't reliably ready when the server > > flushes a message. I know the messages are being sent and flushed properly > > by > > the server because if I type a new form on stdin and hit enter, I see the > > following sequence: > > > > 1. Client processes new stdin form in handle-rdy-to-send > > 2. Client loops and calls sync > > 3. The server-msg-evt is *immediately* ready, and client handles the > > message in handle-server-msg. > > Note: The message handled in step 3 may have been sent long before, but > > the client remained blocked in sync until the (unrelated) stdin event > > unblocked it. > > > > The really weird part is that the client blocks in this manner even if I > > change the sync to a sync/timeout! > > > > Any clue as to what could be going on here? I'm running both client and > > server > > in a DOS box on a Windows 7 machine. > > > > Thanks, > > Brett Stahlman > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Sun Sep 14 09:24:18 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 14 Sep 2014 15:24:18 +0200 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> Message-ID: <20140914132423.08A346501B1@mail-svr1.cs.utah.edu> At Sun, 14 Sep 2014 08:20:26 -0500, Brett Stahlman wrote: > I will try to put together > a version to send you, though. Would you prefer it with the debug printf's > stripped out? Either way is fine. From mflatt at cs.utah.edu Sun Sep 14 10:23:32 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 14 Sep 2014 16:23:32 +0200 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> Message-ID: <20140914142336.7EE6F6501C1@mail-svr1.cs.utah.edu> I think the problem is in `standard-input-port` from `rnrs/io/ports-6`. If you use `current-input-port` instead of `standard-input-port`, does the client behave correctly? At Sun, 14 Sep 2014 08:20:26 -0500, Brett Stahlman wrote: > On Sep 14, 2014 7:56 AM, "Matthew Flatt" wrote: > > > > It's possible that something is wrong with `sync` and TCP ports --- > > although the test suite at least includes that combination --- but can > > you provide a complete program? > > > > For example, I'm interested in what `handle-rdy-to-send` does. In the > > part that you show, the function will be triggered when one byte is > > available on stdin. If `handle-rdy-to-send` tries to read more bytes > > than are immediately available, then it can block; i.e., the blocking > > part could be in `handle-rdy-to-send`, not in `sync`. That would also > > explain why using `sync/timeout` doesn't change anything. > > Actually, I know it's blocking in the sync (or sync/timeout) because the > actual code is littered with immediately-flushed printf's, and there's one > right before and one right after the sync call. I will try to put together > a version to send you, though. Would you prefer it with the debug printf's > stripped out? > > Thanks, Brett S. > > > > > Again, that's just an example of what might be wrong other than `sync`. > > A complete program would let us sort out the possibilities. > > > > At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: > > > Hello, > > > > > > I have the following loop in a tcp client program that sends forms > typed by > > > user at the terminal to a listening server, and receives such forms > typed by > > > other clients (broadcast to all clients by the server). > > > > > > (define server-msg-evt (wrap-evt in handle-server-msg)) > > > (define rdy-to-send-evt (wrap-evt (standard-input-port) > handle-rdy-to-send)) > > > > > > (let loop () > > > (sync rdy-to-send-evt server-msg-evt) > > > (loop)) > > > > > > The problem is that the server-msg-evt isn't reliably ready when the > server > > > flushes a message. I know the messages are being sent and flushed > properly > > > by > > > the server because if I type a new form on stdin and hit enter, I see > the > > > following sequence: > > > > > > 1. Client processes new stdin form in handle-rdy-to-send > > > 2. Client loops and calls sync > > > 3. The server-msg-evt is *immediately* ready, and client handles the > > > message in handle-server-msg. > > > Note: The message handled in step 3 may have been sent long before, but > > > the client remained blocked in sync until the (unrelated) stdin event > > > unblocked it. > > > > > > The really weird part is that the client blocks in this manner even if I > > > change the sync to a sync/timeout! > > > > > > Any clue as to what could be going on here? I'm running both client and > > > server > > > in a DOS box on a Windows 7 machine. > > > > > > Thanks, > > > Brett Stahlman > > > ____________________ > > > Racket Users list: > > > http://lists.racket-lang.org/users > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From brettstahlman at gmail.com Sun Sep 14 10:38:49 2014 From: brettstahlman at gmail.com (Brett Stahlman) Date: Sun, 14 Sep 2014 09:38:49 -0500 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: <20140914142336.7EE6F6501C1@mail-svr1.cs.utah.edu> References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> <20140914142336.7EE6F6501C1@mail-svr1.cs.utah.edu> Message-ID: On Sun, Sep 14, 2014 at 9:23 AM, Matthew Flatt wrote: > I think the problem is in `standard-input-port` from `rnrs/io/ports-6`. > > If you use `current-input-port` instead of `standard-input-port`, does > the client behave correctly? It does indeed! Can't recall why I used standard-input-port to begin with, but I'm thinking this could account for some of the weirdness I've been seeing. I didn't mention it in my original posts, but part of the reason I went to such a convoluted strategy for peeking and reading ports was that byte-ready? was blocking as well. Actually, I've been planning to change the client/server architecture entirely - to one in which each port reader operates in a dedicated thread, and simply blocks until a new form can be read, at which point it writes the data to an async channel to be processed at a higher level - but I didn't want to proceed without resolving these issues... Out of curiosity, what is the proper way to set the current input port to stdin (if somehow it's been changed from the default)? (It hasn't, in my case, but perhaps the reason I went to standard-input-port in the first place was that there didn't appear to be any guarantee that the current input port would be stdin...) Thanks, Brett S. > > At Sun, 14 Sep 2014 08:20:26 -0500, Brett Stahlman wrote: >> On Sep 14, 2014 7:56 AM, "Matthew Flatt" wrote: >> > >> > It's possible that something is wrong with `sync` and TCP ports --- >> > although the test suite at least includes that combination --- but can >> > you provide a complete program? >> > >> > For example, I'm interested in what `handle-rdy-to-send` does. In the >> > part that you show, the function will be triggered when one byte is >> > available on stdin. If `handle-rdy-to-send` tries to read more bytes >> > than are immediately available, then it can block; i.e., the blocking >> > part could be in `handle-rdy-to-send`, not in `sync`. That would also >> > explain why using `sync/timeout` doesn't change anything. >> >> Actually, I know it's blocking in the sync (or sync/timeout) because the >> actual code is littered with immediately-flushed printf's, and there's one >> right before and one right after the sync call. I will try to put together >> a version to send you, though. Would you prefer it with the debug printf's >> stripped out? >> >> Thanks, Brett S. >> >> > >> > Again, that's just an example of what might be wrong other than `sync`. >> > A complete program would let us sort out the possibilities. >> > >> > At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: >> > > Hello, >> > > >> > > I have the following loop in a tcp client program that sends forms >> typed by >> > > user at the terminal to a listening server, and receives such forms >> typed by >> > > other clients (broadcast to all clients by the server). >> > > >> > > (define server-msg-evt (wrap-evt in handle-server-msg)) >> > > (define rdy-to-send-evt (wrap-evt (standard-input-port) >> handle-rdy-to-send)) >> > > >> > > (let loop () >> > > (sync rdy-to-send-evt server-msg-evt) >> > > (loop)) >> > > >> > > The problem is that the server-msg-evt isn't reliably ready when the >> server >> > > flushes a message. I know the messages are being sent and flushed >> properly >> > > by >> > > the server because if I type a new form on stdin and hit enter, I see >> the >> > > following sequence: >> > > >> > > 1. Client processes new stdin form in handle-rdy-to-send >> > > 2. Client loops and calls sync >> > > 3. The server-msg-evt is *immediately* ready, and client handles the >> > > message in handle-server-msg. >> > > Note: The message handled in step 3 may have been sent long before, but >> > > the client remained blocked in sync until the (unrelated) stdin event >> > > unblocked it. >> > > >> > > The really weird part is that the client blocks in this manner even if I >> > > change the sync to a sync/timeout! >> > > >> > > Any clue as to what could be going on here? I'm running both client and >> > > server >> > > in a DOS box on a Windows 7 machine. >> > > >> > > Thanks, >> > > Brett Stahlman >> > > ____________________ >> > > Racket Users list: >> > > http://lists.racket-lang.org/users >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From mflatt at cs.utah.edu Sun Sep 14 10:49:56 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 14 Sep 2014 16:49:56 +0200 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> <20140914142336.7EE6F6501C1@mail-svr1.cs.utah.edu> Message-ID: <20140914145002.69ACF6501C4@mail-svr1.cs.utah.edu> I'll push a repair to make `rnrs/io/ports-6` ports work right with `sync`. There's not really a way to get the OS-process-level stdin and stdout in Racket, except by using scheme_make_fd_input_port() via `ffi/unsafe`. The intent is that the initial ports, which correspond to stdin and stdout, can be made inaccessible to untrusted code by changing the `current-input-port` and `current-output-port` parameters. Usually, it's best to just use `(current-input-port)`. The initial parameter value corresponds to stdin for a stand-alone Racket process; in other cases, a program should normally accept whatever adjustments are made by its environment. If you really need the OS-process-level stdin and stdout, through, then `ffi/unsafe' can reach them. The `standard-input-port` function in Racket's R6RS implementation, meanwhile, returns the current input port at the time that the R6RS library was loaded. So, it's not necessary stdin in the sense of the OS process, but it's "stdin" in the sense of the being the designated source for input when the library starts. At Sun, 14 Sep 2014 09:38:49 -0500, Brett Stahlman wrote: > On Sun, Sep 14, 2014 at 9:23 AM, Matthew Flatt wrote: > > I think the problem is in `standard-input-port` from `rnrs/io/ports-6`. > > > > If you use `current-input-port` instead of `standard-input-port`, does > > the client behave correctly? > > It does indeed! Can't recall why I used standard-input-port to begin > with, but I'm thinking this could account for some of the weirdness > I've been seeing. I didn't mention it in my original posts, but part > of the reason I went to such a convoluted strategy for peeking and > reading ports was that byte-ready? was blocking as well. Actually, > I've been planning to change the client/server architecture entirely - > to one in which each port reader operates in a dedicated thread, and > simply blocks until a new form can be read, at which point it writes > the data to an async channel to be processed at a higher level - but I > didn't want to proceed without resolving these issues... > > Out of curiosity, what is the proper way to set the current input port > to stdin (if somehow it's been changed from the default)? (It hasn't, > in my case, but perhaps the reason I went to standard-input-port in > the first place was that there didn't appear to be any guarantee that > the current input port would be stdin...) > > Thanks, > Brett S. > > > > > At Sun, 14 Sep 2014 08:20:26 -0500, Brett Stahlman wrote: > >> On Sep 14, 2014 7:56 AM, "Matthew Flatt" wrote: > >> > > >> > It's possible that something is wrong with `sync` and TCP ports --- > >> > although the test suite at least includes that combination --- but can > >> > you provide a complete program? > >> > > >> > For example, I'm interested in what `handle-rdy-to-send` does. In the > >> > part that you show, the function will be triggered when one byte is > >> > available on stdin. If `handle-rdy-to-send` tries to read more bytes > >> > than are immediately available, then it can block; i.e., the blocking > >> > part could be in `handle-rdy-to-send`, not in `sync`. That would also > >> > explain why using `sync/timeout` doesn't change anything. > >> > >> Actually, I know it's blocking in the sync (or sync/timeout) because the > >> actual code is littered with immediately-flushed printf's, and there's one > >> right before and one right after the sync call. I will try to put together > >> a version to send you, though. Would you prefer it with the debug printf's > >> stripped out? > >> > >> Thanks, Brett S. > >> > >> > > >> > Again, that's just an example of what might be wrong other than `sync`. > >> > A complete program would let us sort out the possibilities. > >> > > >> > At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: > >> > > Hello, > >> > > > >> > > I have the following loop in a tcp client program that sends forms > >> typed by > >> > > user at the terminal to a listening server, and receives such forms > >> typed by > >> > > other clients (broadcast to all clients by the server). > >> > > > >> > > (define server-msg-evt (wrap-evt in handle-server-msg)) > >> > > (define rdy-to-send-evt (wrap-evt (standard-input-port) > >> handle-rdy-to-send)) > >> > > > >> > > (let loop () > >> > > (sync rdy-to-send-evt server-msg-evt) > >> > > (loop)) > >> > > > >> > > The problem is that the server-msg-evt isn't reliably ready when the > >> server > >> > > flushes a message. I know the messages are being sent and flushed > >> properly > >> > > by > >> > > the server because if I type a new form on stdin and hit enter, I see > >> the > >> > > following sequence: > >> > > > >> > > 1. Client processes new stdin form in handle-rdy-to-send > >> > > 2. Client loops and calls sync > >> > > 3. The server-msg-evt is *immediately* ready, and client handles the > >> > > message in handle-server-msg. > >> > > Note: The message handled in step 3 may have been sent long before, but > >> > > the client remained blocked in sync until the (unrelated) stdin event > >> > > unblocked it. > >> > > > >> > > The really weird part is that the client blocks in this manner even if I > >> > > change the sync to a sync/timeout! > >> > > > >> > > Any clue as to what could be going on here? I'm running both client and > >> > > server > >> > > in a DOS box on a Windows 7 machine. > >> > > > >> > > Thanks, > >> > > Brett Stahlman > >> > > ____________________ > >> > > Racket Users list: > >> > > http://lists.racket-lang.org/users > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From brettstahlman at gmail.com Sun Sep 14 11:03:39 2014 From: brettstahlman at gmail.com (Brett Stahlman) Date: Sun, 14 Sep 2014 10:03:39 -0500 Subject: [racket] Possible bug involving sync on tcp ports In-Reply-To: <20140914145002.69ACF6501C4@mail-svr1.cs.utah.edu> References: <20140914125656.22E386501A8@mail-svr1.cs.utah.edu> <20140914142336.7EE6F6501C1@mail-svr1.cs.utah.edu> <20140914145002.69ACF6501C4@mail-svr1.cs.utah.edu> Message-ID: On Sun, Sep 14, 2014 at 9:49 AM, Matthew Flatt wrote: > I'll push a repair to make `rnrs/io/ports-6` ports work right with > `sync`. Excellent! Thanks. > > There's not really a way to get the OS-process-level stdin and stdout > in Racket, except by using scheme_make_fd_input_port() via > `ffi/unsafe`. The intent is that the initial ports, which correspond to > stdin and stdout, can be made inaccessible to untrusted code by > changing the `current-input-port` and `current-output-port` parameters. > > Usually, it's best to just use `(current-input-port)`. The initial > parameter value corresponds to stdin for a stand-alone Racket process; > in other cases, a program should normally accept whatever adjustments > are made by its environment. If you really need the OS-process-level > stdin and stdout, through, then `ffi/unsafe' can reach them. Understood. That certainly works for my use-case... Brett S. > > The `standard-input-port` function in Racket's R6RS implementation, > meanwhile, returns the current input port at the time that the R6RS > library was loaded. So, it's not necessary stdin in the sense of the OS > process, but it's "stdin" in the sense of the being the designated > source for input when the library starts. > > At Sun, 14 Sep 2014 09:38:49 -0500, Brett Stahlman wrote: >> On Sun, Sep 14, 2014 at 9:23 AM, Matthew Flatt wrote: >> > I think the problem is in `standard-input-port` from `rnrs/io/ports-6`. >> > >> > If you use `current-input-port` instead of `standard-input-port`, does >> > the client behave correctly? >> >> It does indeed! Can't recall why I used standard-input-port to begin >> with, but I'm thinking this could account for some of the weirdness >> I've been seeing. I didn't mention it in my original posts, but part >> of the reason I went to such a convoluted strategy for peeking and >> reading ports was that byte-ready? was blocking as well. Actually, >> I've been planning to change the client/server architecture entirely - >> to one in which each port reader operates in a dedicated thread, and >> simply blocks until a new form can be read, at which point it writes >> the data to an async channel to be processed at a higher level - but I >> didn't want to proceed without resolving these issues... >> >> Out of curiosity, what is the proper way to set the current input port >> to stdin (if somehow it's been changed from the default)? (It hasn't, >> in my case, but perhaps the reason I went to standard-input-port in >> the first place was that there didn't appear to be any guarantee that >> the current input port would be stdin...) >> >> Thanks, >> Brett S. >> >> > >> > At Sun, 14 Sep 2014 08:20:26 -0500, Brett Stahlman wrote: >> >> On Sep 14, 2014 7:56 AM, "Matthew Flatt" wrote: >> >> > >> >> > It's possible that something is wrong with `sync` and TCP ports --- >> >> > although the test suite at least includes that combination --- but can >> >> > you provide a complete program? >> >> > >> >> > For example, I'm interested in what `handle-rdy-to-send` does. In the >> >> > part that you show, the function will be triggered when one byte is >> >> > available on stdin. If `handle-rdy-to-send` tries to read more bytes >> >> > than are immediately available, then it can block; i.e., the blocking >> >> > part could be in `handle-rdy-to-send`, not in `sync`. That would also >> >> > explain why using `sync/timeout` doesn't change anything. >> >> >> >> Actually, I know it's blocking in the sync (or sync/timeout) because the >> >> actual code is littered with immediately-flushed printf's, and there's one >> >> right before and one right after the sync call. I will try to put together >> >> a version to send you, though. Would you prefer it with the debug printf's >> >> stripped out? >> >> >> >> Thanks, Brett S. >> >> >> >> > >> >> > Again, that's just an example of what might be wrong other than `sync`. >> >> > A complete program would let us sort out the possibilities. >> >> > >> >> > At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote: >> >> > > Hello, >> >> > > >> >> > > I have the following loop in a tcp client program that sends forms >> >> typed by >> >> > > user at the terminal to a listening server, and receives such forms >> >> typed by >> >> > > other clients (broadcast to all clients by the server). >> >> > > >> >> > > (define server-msg-evt (wrap-evt in handle-server-msg)) >> >> > > (define rdy-to-send-evt (wrap-evt (standard-input-port) >> >> handle-rdy-to-send)) >> >> > > >> >> > > (let loop () >> >> > > (sync rdy-to-send-evt server-msg-evt) >> >> > > (loop)) >> >> > > >> >> > > The problem is that the server-msg-evt isn't reliably ready when the >> >> server >> >> > > flushes a message. I know the messages are being sent and flushed >> >> properly >> >> > > by >> >> > > the server because if I type a new form on stdin and hit enter, I see >> >> the >> >> > > following sequence: >> >> > > >> >> > > 1. Client processes new stdin form in handle-rdy-to-send >> >> > > 2. Client loops and calls sync >> >> > > 3. The server-msg-evt is *immediately* ready, and client handles the >> >> > > message in handle-server-msg. >> >> > > Note: The message handled in step 3 may have been sent long before, but >> >> > > the client remained blocked in sync until the (unrelated) stdin event >> >> > > unblocked it. >> >> > > >> >> > > The really weird part is that the client blocks in this manner even if I >> >> > > change the sync to a sync/timeout! >> >> > > >> >> > > Any clue as to what could be going on here? I'm running both client and >> >> > > server >> >> > > in a DOS box on a Windows 7 machine. >> >> > > >> >> > > Thanks, >> >> > > Brett Stahlman >> >> > > ____________________ >> >> > > Racket Users list: >> >> > > http://lists.racket-lang.org/users >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From oev-racket at sibmail.com Mon Sep 15 00:07:52 2014 From: oev-racket at sibmail.com (Evgeny Odegov) Date: Mon, 15 Sep 2014 11:07:52 +0700 (NOVT) Subject: [racket] Some problem with hash-update! In-Reply-To: <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> Message-ID: <58297.91.221.60.217.1410754072.squirrel@www.sibmail.com> More complete example: http://pasterack.org/pastes/25901 I guess I've found reason of the problem. I think the problem was in that line: (define lpdwItems (make-bytes (ctype-sizeof _pointer) 0)) I've changed it to: (define lpdwItems (make-bytes (ctype-sizeof _DWORD) 0)) There is no visible problems now, but I doubt that applying `make-bytes' here is right. Should I use `malloc' in such cases? Anyway, sorry for the noise. > My best guess is that it's an issue with memory management, because > memory management gets a lot trickier when you call a function that can > call back into Racket. A GC can happen during the callback, and > therefore during the dynamic extent of the foreign-function call, which > can move arguments that were passed to the foreign function, for example. > > Would it be possible to provide a complete example? > > At Sat, 13 Sep 2014 22:45:28 +0700 (NOVT), "Evgeny Odegov" wrote: >> Oh, I'm wrong. The last code is not equivalent to initial. >> The equivalent code has this problem: >> >> (define result (make-hash)) >> (define big-list (list)) >> (define (callback dwTextID lpszInfoText lpvUser) >> (if (equal? lpszInfoText "") >> (set! big-list (append big-list (list dwTextID))) >> (hash-update! result >> lpszInfoText >> (lambda (id-lst) >> (define v (list dwTextID)) >> (append id-lst v)) >> '())) >> #t) >> >> >> The code with `cons' instead `append' works fine: >> >> (define result (make-hash)) >> (define (callback dwTextID lpszInfoText lpvUser) >> (hash-update! result >> lpszInfoText >> (lambda (id-lst) >> (define new-id-lst (cons dwTextID id-lst)) >> (unless (list? new-id-lst) >> >> (error "~v" new-id-lst)) >> new-id-lst) >> '()) >> #t) >> >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > From mflatt at cs.utah.edu Mon Sep 15 01:58:08 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Mon, 15 Sep 2014 07:58:08 +0200 Subject: [racket] Some problem with hash-update! In-Reply-To: <58297.91.221.60.217.1410754072.squirrel@www.sibmail.com> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> <58297.91.221.60.217.1410754072.squirrel@www.sibmail.com> Message-ID: <20140915055811.D05D0650188@mail-svr1.cs.utah.edu> I think that changing `_pointer` to `_DWORD` can't be the real answer, since `_pointer` is at least as large as `_DWORD`. But I agree that you should use `malloc`, and you should also supply 'atomic-interior: (malloc _DWORD 'atomic-interior) The 'atomic-interior flag ensures that the allocated memory does not move during an invocation of the callback. Along similar lines, I think you need to add #:malloc-mode 'atomic-interior to the declaration of `_CMN_ERROR`. You may need to copy the `filter` argument into non-moving memory, but that's probably not an issue if it's always "". At Mon, 15 Sep 2014 11:07:52 +0700 (NOVT), "Evgeny Odegov" wrote: > More complete example: > http://pasterack.org/pastes/25901 > > I guess I've found reason of the problem. > > I think the problem was in that line: > (define lpdwItems (make-bytes (ctype-sizeof _pointer) 0)) > > I've changed it to: > (define lpdwItems (make-bytes (ctype-sizeof _DWORD) 0)) > > There is no visible problems now, but I doubt that applying `make-bytes' > here is right. > > Should I use `malloc' in such cases? > > > Anyway, sorry for the noise. > > > > My best guess is that it's an issue with memory management, because > > memory management gets a lot trickier when you call a function that can > > call back into Racket. A GC can happen during the callback, and > > therefore during the dynamic extent of the foreign-function call, which > > can move arguments that were passed to the foreign function, for example. > > > > Would it be possible to provide a complete example? > > > > At Sat, 13 Sep 2014 22:45:28 +0700 (NOVT), "Evgeny Odegov" wrote: > >> Oh, I'm wrong. The last code is not equivalent to initial. > >> The equivalent code has this problem: > >> > >> (define result (make-hash)) > >> (define big-list (list)) > >> (define (callback dwTextID lpszInfoText lpvUser) > >> (if (equal? lpszInfoText "") > >> (set! big-list (append big-list (list dwTextID))) > >> (hash-update! result > >> lpszInfoText > >> (lambda (id-lst) > >> (define v (list dwTextID)) > >> (append id-lst v)) > >> '())) > >> #t) > >> > >> > >> The code with `cons' instead `append' works fine: > >> > >> (define result (make-hash)) > >> (define (callback dwTextID lpszInfoText lpvUser) > >> (hash-update! result > >> lpszInfoText > >> (lambda (id-lst) > >> (define new-id-lst (cons dwTextID id-lst)) > >> (unless (list? new-id-lst) > >> > >> (error "~v" new-id-lst)) > >> new-id-lst) > >> '()) > >> #t) > >> > >> > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > > From oev-racket at sibmail.com Mon Sep 15 04:04:12 2014 From: oev-racket at sibmail.com (Evgeny Odegov) Date: Mon, 15 Sep 2014 15:04:12 +0700 (NOVT) Subject: [racket] Some problem with hash-update! In-Reply-To: <20140915055811.D05D0650188@mail-svr1.cs.utah.edu> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> <58297.91.221.60.217.1410754072.squirrel@www.sibmail.com> <20140915055811.D05D0650188@mail-svr1.cs.utah.edu> Message-ID: <62737.91.221.60.217.1410768252.squirrel@www.sibmail.com> > I think that changing `_pointer` to `_DWORD` can't be the real answer, > since `_pointer` is at least as large as `_DWORD`. Facepalm. Of course, you're right! Somehow, I've thought that _pointer is twice shorter :) > But I agree that you should use `malloc`, and you should also supply > 'atomic-interior: > > (malloc _DWORD 'atomic-interior) > > The 'atomic-interior flag ensures that the allocated memory does not > move during an invocation of the callback. > It seems like I've got a wrong impression about #:atomic? parameter of `_fun` form. I thought it's intended to prevent such issues. > Along similar lines, I think you need to add > > #:malloc-mode 'atomic-interior > > to the declaration of `_CMN_ERROR`. > Thank you for the notes! So, as I see, `malloc' with 'atomic-inferior mode must be used, when a parameter is changed by foreign function. > You may need to copy the `filter` argument into non-moving memory, but > that's probably not an issue if it's always "". The parameter `lpszFilter` is not changed by `TXTEnumInfoText`. Is `_string/locale` enough in such case? What could you say about `_string/locale/len'? Is there something that I have not took into account? > > At Mon, 15 Sep 2014 11:07:52 +0700 (NOVT), "Evgeny Odegov" wrote: >> More complete example: >> http://pasterack.org/pastes/25901 >> >> I guess I've found reason of the problem. >> >> I think the problem was in that line: >> (define lpdwItems (make-bytes (ctype-sizeof _pointer) 0)) >> >> I've changed it to: >> (define lpdwItems (make-bytes (ctype-sizeof _DWORD) 0)) >> >> There is no visible problems now, but I doubt that applying `make-bytes' >> here is right. >> >> Should I use `malloc' in such cases? >> >> >> Anyway, sorry for the noise. >> >> >> > My best guess is that it's an issue with memory management, because >> > memory management gets a lot trickier when you call a function that >> can >> > call back into Racket. A GC can happen during the callback, and >> > therefore during the dynamic extent of the foreign-function call, >> which >> > can move arguments that were passed to the foreign function, for >> example. >> > >> > Would it be possible to provide a complete example? >> > >> > At Sat, 13 Sep 2014 22:45:28 +0700 (NOVT), "Evgeny Odegov" wrote: >> >> Oh, I'm wrong. The last code is not equivalent to initial. >> >> The equivalent code has this problem: >> >> >> >> (define result (make-hash)) >> >> (define big-list (list)) >> >> (define (callback dwTextID lpszInfoText lpvUser) >> >> (if (equal? lpszInfoText "") >> >> (set! big-list (append big-list (list dwTextID))) >> >> (hash-update! result >> >> lpszInfoText >> >> (lambda (id-lst) >> >> (define v (list dwTextID)) >> >> (append id-lst v)) >> >> '())) >> >> #t) >> >> >> >> >> >> The code with `cons' instead `append' works fine: >> >> >> >> (define result (make-hash)) >> >> (define (callback dwTextID lpszInfoText lpvUser) >> >> (hash-update! result >> >> lpszInfoText >> >> (lambda (id-lst) >> >> (define new-id-lst (cons dwTextID id-lst)) >> >> (unless (list? new-id-lst) >> >> >> >> (error "~v" new-id-lst)) >> >> new-id-lst) >> >> '()) >> >> #t) >> >> >> >> >> >> >> >> >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> > > From dbastos at toledo.com Mon Sep 15 09:20:30 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Mon, 15 Sep 2014 10:20:30 -0300 Subject: [racket] missing solution 20.1.1 ex:sem-funcs In-Reply-To: References: Message-ID: On Fri, Sep 12, 2014 at 6:43 PM, Matthias Felleisen wrote: > On Sep 12, 2014, at 4:40 PM, Daniel Bastos wrote: > > > Again, we start with (2) and apply a series of substitutions. > > > > (f f) > > = ( ) ;; since f is a > > = ( ) ;; since is a subset of > > > > However, ( ) is not by definition a value. It is an > > expression which may or may not /have/ a value. We know the > > definition of f, however, which tells us that it behaves like > > the identity function. So the evaluation of that ( ) > > yields a function, which is a value. We end with > > > > = > > > > Therefore (2) is a value > > Is there a difference between the statements > > "Daniel is a hat." > > and > > "Daniel has a hat." > > or do they really mean the same thing? > There's a difference. > In this spirit, is there a difference between the statement > > "(f f) is a value." > > and > > "(f f) has a value." > > or do they really mean the same thing? > There's a difference. The analogy is good. (I do remember having read this analogy in the book, though I can't seem to find it right now.) Here's my final rewrite. Feel free to scrutinize it. (BTW, thanks for your attention.) Exercise 20.1.1. Assume the Definitions window in DrScheme contains (define (f x) x). Identify the values among the following expressions: (1) (cons f empty) (2) (f f) (3) (cons f (cons 10 (cons (f 10) empty))) Explain why they are values and why the remaining expressions are not values. Solution. A value is anything of the form = | | | empty | | (names of defined functions) | where is of the form = empty | (cons ). Now we start with (1) and apply a series of substitutions based on the definitions we have. (cons f empty) = (cons ) ;; since f is a = (cons ) ;; since empty is a = (cons ) ;; since is a subset of = ;; definition of = ;; definition of Therefore (1) is a value. Next we consider (2). Here's a relevant part of the grammar for (2). = | | ( ...) Start with (2)... (f f) = ( ) ;; since f is a = ( ) ;; since is a subset of Now ( ) is not by definition a value. Expressions may have values, but they're not values. (Daniel may have a hat, but Daniel is not a hat.) Therefore (2) is not a value. Now (3). (cons f (cons 10 (cons (f 10) empty))) = (cons (cons (cons ( ) ))) The whole expression depends on the application ( ), which may or may not have a value. Since we know f, we know it has a value, but it /is not/ a value. Therefore (3) is not a value. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dbastos at toledo.com Mon Sep 15 09:26:28 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Mon, 15 Sep 2014 10:26:28 -0300 Subject: [racket] missing solution 20.1.2 ex:syn-funcs In-Reply-To: <7E897494-BFBC-499C-B189-AFB890468E62@ccs.neu.edu> References: <7E897494-BFBC-499C-B189-AFB890468E62@ccs.neu.edu> Message-ID: On Mon, Sep 8, 2014 at 9:51 PM, Matthias Felleisen wrote: On Sep 2, 2014, at 12:05 PM, Daniel Bastos wrote: > > > Exercise 20.1.2. Argue why the following sentences are legal > > definitions: > > > > (define (f x) (x 10)) > > > > (define (f x) f) > > > > (define (f x y) (x 'a y 'b)) > > > > Solution. The relevant part of the grammar is the following. > > > > = (define ( ...) ) > > | (define ) > > | (define-struct ( ...)) > > > > (*) First definition > > > > The LHS is a list of , since we find f and x as members of the > > list and they're both variables. The RHS is a list consisting of a > > and a . > > Small correction. Let's not call (x 10) a list. It's an application. '(x > 10) would be a list and this one character is critical. > Indeed. Here's a full rewrite for completeness. (Thanks!) Exercise 20.1.2. Argue why the following sentences are legal definitions: (define (f x) (x 10)) (define (f x) f) (define (f x y) (x 'a y 'b)) Solution. The relevant part of the grammar is the following. = (define ( ...) ) | (define ) | (define-struct ( ...)) (*) First definition The LHS is a list of , since we find f and x as members of the list and they're both variables. The RHS is an application of the form ( ), which makes up an , satisfying the first form of . In other words, (define ( ) ( ) ( ) = (define ( ) ). Therefore it's a legal . (*) Second definition Same LHS as the previous, so we need only check the RHS which is a . is a valid form of , so we have (define ( ) ) = (define ( ) ). Therefore it's a legal . (*) Third definition The LHS is ( ), while the RHS is ( ), so we have (define ( ) ( )) = (define ( ) ( )) = (define ( ) ). Therefore it's a legal . -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Mon Sep 15 09:49:18 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 15 Sep 2014 09:49:18 -0400 Subject: [racket] missing solution 20.1.1 ex:sem-funcs In-Reply-To: References: Message-ID: Good. On Sep 15, 2014, at 9:20 AM, Daniel Bastos wrote: > On Fri, Sep 12, 2014 at 6:43 PM, > Matthias Felleisen wrote: > > > On Sep 12, 2014, at 4:40 PM, Daniel Bastos wrote: > > > Again, we start with (2) and apply a series of substitutions. > > > > (f f) > > = ( ) ;; since f is a > > = ( ) ;; since is a subset of > > > > However, ( ) is not by definition a value. It is an > > expression which may or may not /have/ a value. We know the > > definition of f, however, which tells us that it behaves like > > the identity function. So the evaluation of that ( ) > > yields a function, which is a value. We end with > > > > = > > > > Therefore (2) is a value > > Is there a difference between the statements > > "Daniel is a hat." > > and > > "Daniel has a hat." > > or do they really mean the same thing? > > There's a difference. > > In this spirit, is there a difference between the statement > > "(f f) is a value." > > and > > "(f f) has a value." > > or do they really mean the same thing? > > There's a difference. The analogy is good. (I do remember having read this analogy in the book, though I can't seem to find it right now.) > > Here's my final rewrite. Feel free to scrutinize it. (BTW, thanks for your attention.) > > Exercise 20.1.1. Assume the Definitions window in DrScheme contains > (define (f x) x). Identify the values among the following expressions: > > (1) (cons f empty) > (2) (f f) > (3) (cons f (cons 10 (cons (f 10) empty))) > > Explain why they are values and why the remaining expressions are not > values. > > Solution. A value is anything of the form > > = | | | empty | > | (names of defined functions) > | > > where is of the form > > = empty | (cons ). > > Now we start with (1) and apply a series of substitutions based on the > definitions we have. > > (cons f empty) > = (cons ) ;; since f is a > = (cons ) ;; since empty is a > = (cons ) ;; since is a subset of > = ;; definition of > = ;; definition of > > Therefore (1) is a value. > > Next we consider (2). Here's a relevant part of the grammar for (2). > > = > | > | ( ...) > > Start with (2)... > > (f f) > = ( ) ;; since f is a > = ( ) ;; since is a subset of > > Now ( ) is not by definition a value. Expressions may have > values, but they're not values. (Daniel may have a hat, but Daniel is > not a hat.) > > Therefore (2) is not a value. > > Now (3). > > (cons f (cons 10 (cons (f 10) empty))) > = (cons (cons (cons ( ) ))) > > The whole expression depends on the application ( ), > which may or may not have a value. Since we know f, we know it has a value, > but it /is not/ a value. > > Therefore (3) is not a value. From rudolphg1 at citadel.edu Mon Sep 15 13:50:10 2014 From: rudolphg1 at citadel.edu (George Rudolph) Date: Mon, 15 Sep 2014 17:50:10 +0000 Subject: [racket] How best to repeat a function call n times? Message-ID: <60998febf5a54dfab298d3604b0d415b@BLUPR01MB129.prod.exchangelabs.com> All, I am sure this question has been answered before, but I can't find it. Suppose I want to call some function, either built-in or user-defined, n number of times, and measure the total time it takes. Is there a more efficient or elegant way of doing this than passing the expression to a tail-recursive counting loop such as the following? (define (repeater sexpr count) (sexpr) (cond [(> count 0) (repeater sexpr (- count 1)) ]) ) George Rudolph Associate Professor of Computer Science Department of Mathematics and Computer Science 225 Thompson Hall The Citadel 171 Moultrie Street Charleston, SC 29409 843.953.5032 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 92 bytes Desc: image001.gif URL: From robby at eecs.northwestern.edu Mon Sep 15 13:53:26 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 15 Sep 2014 12:53:26 -0500 Subject: [racket] How best to repeat a function call n times? In-Reply-To: <60998febf5a54dfab298d3604b0d415b@BLUPR01MB129.prod.exchangelabs.com> References: <60998febf5a54dfab298d3604b0d415b@BLUPR01MB129.prod.exchangelabs.com> Message-ID: Not more efficient, but perhaps more readable: (define (repeater f count) (for ([x (in-range count)]) (f))) On Mon, Sep 15, 2014 at 12:50 PM, George Rudolph wrote: > All, > > I am sure this question has been answered before, but I can?t find it. > > Suppose I want to call some function, either built-in or user-defined, n > number of times, and measure the total time it takes. Is there a more > efficient or elegant way > > of doing this than passing the expression to a tail-recursive counting > loop such as the following? > > > > (define (repeater sexpr count) > > (sexpr) > > (cond > > [(> count 0) (repeater sexpr (- count 1)) ]) > > ) > > > > > > > > George Rudolph > > Associate Professor of Computer Science > > Department of Mathematics and Computer Science > > 225 Thompson Hall > > The Citadel > > 171 Moultrie Street > > Charleston, SC 29409 > > 843.953.5032 > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 92 bytes Desc: not available URL: From matthias at ccs.neu.edu Mon Sep 15 13:57:04 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 15 Sep 2014 13:57:04 -0400 Subject: [racket] How best to repeat a function call n times? In-Reply-To: <60998febf5a54dfab298d3604b0d415b@BLUPR01MB129.prod.exchangelabs.com> References: <60998febf5a54dfab298d3604b0d415b@BLUPR01MB129.prod.exchangelabs.com> Message-ID: Welcome to Racket v6.1.0.8. > (define (repeater f count) (for ((i (in-range count))) (f))) > (repeater (lambda () (displayln "hello world")) 10) hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world On Sep 15, 2014, at 1:50 PM, George Rudolph wrote: > All, > I am sure this question has been answered before, but I can?t find it. > Suppose I want to call some function, either built-in or user-defined, n number of times, and measure the total time it takes. Is there a more efficient or elegant way > of doing this than passing the expression to a tail-recursive counting loop such as the following? > > (define (repeater sexpr count) > (sexpr) > (cond > [(> count 0) (repeater sexpr (- count 1)) ]) > ) > > > > George Rudolph > Associate Professor of Computer Science > Department of Mathematics and Computer Science > 225 Thompson Hall > The Citadel > 171 Moultrie Street > Charleston, SC 29409 > 843.953.5032 > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mb at mbtype.com Mon Sep 15 16:38:00 2014 From: mb at mbtype.com (Matthew Butterick) Date: Mon, 15 Sep 2014 13:38:00 -0700 Subject: [racket] Can a #reader be used with (module ...) ? Message-ID: <54174E28.4000001@mbtype.com> I'm aware that `#lang name ...` is equivalent to `(module id name ...)`. But `#lang` automatically picks up a reader; `module` does not. Is there a way to attach a reader to the `module` form (the idea being that then, within the `module` expression, you could write using the native syntax of the #lang)? Studying the example in reader extensions (Guide ? 17.2), I found that this works, but I haven't figured out if it can be generalized: #lang racket/base (module inner racket/base '(#reader"five.rkt"23456)) (require 'inner) For instance, my current reader works in the REPL, like so: '#reader(submod pollen/main reader)Hello World But this doesn't work, because the reader, which operates in text mode, absorbs the closing parenthesis: #lang racket/base (module inner racket/base '#reader(submod pollen/main reader)Hello World ) From dbastos at toledo.com Mon Sep 15 16:48:08 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Mon, 15 Sep 2014 17:48:08 -0300 Subject: [racket] on reversing a list by way of sort Message-ID: Dear Racketeers, I was studying the exercise 20.2.4 of HtDP when I came up with this way of reversing lists. (Every element is a least element. Or greatest.) (define (f x y) true) (define (rev ls) (sort ls f)) Welcome to DrRacket, version 6.0.1 [3m]. Language: Intermediate Student; memory limit: 256 MB. > (rev (list 1 3 4)) (list 4 3 1) > (rev '(a b c d)) (list 'd 'c 'b 'a) > Now I'm feeling like an expert. (But my friends still call me Danewbie.) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dvanhorn at cs.umd.edu Mon Sep 15 16:53:50 2014 From: dvanhorn at cs.umd.edu (David Van Horn) Date: Mon, 15 Sep 2014 16:53:50 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: Message-ID: <541751DE.5050407@cs.umd.edu> I don't think you made enough examples. On 9/15/14, 4:48 PM, Daniel Bastos wrote: > Dear Racketeers, I was studying the exercise 20.2.4 of HtDP when I > came up with this way of reversing lists. (Every element is a least > element. Or greatest.) > > (define (f x y) true) > > (define (rev ls) (sort ls f)) > > Welcome to DrRacket, version 6.0.1 [3m]. Language: Intermediate > Student; memory limit: 256 MB. >> (rev (list 1 3 4)) > (list 4 3 1) >> (rev '(a b c d)) > (list 'd 'c 'b 'a) >> > > Now I'm feeling like an expert. (But my friends still call me > Danewbie.) > > > ____________________ Racket Users list: > http://lists.racket-lang.org/users > From dvanhorn at cs.umd.edu Mon Sep 15 17:05:01 2014 From: dvanhorn at cs.umd.edu (David Van Horn) Date: Mon, 15 Sep 2014 17:05:01 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: <541751DE.5050407@cs.umd.edu> References: <541751DE.5050407@cs.umd.edu> Message-ID: <5417547D.3060309@cs.umd.edu> On 9/15/14, 4:53 PM, David Van Horn wrote: > I don't think you made enough examples. Nope - my bad. Cute. Awful, but cute (and there could be correct implementations of sort that would break your rev). David From robby at eecs.northwestern.edu Mon Sep 15 17:16:02 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 15 Sep 2014 16:16:02 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: <5417547D.3060309@cs.umd.edu> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> Message-ID: Fritz Henglein has studied the problem "what is a sorting function?" that touches on this kind of thing. http://www.sciencedirect.com/science/article/pii/S1567832608001094 Robby On Monday, September 15, 2014, David Van Horn wrote: > On 9/15/14, 4:53 PM, David Van Horn wrote: > > I don't think you made enough examples. > > Nope - my bad. Cute. Awful, but cute (and there could be correct > implementations of sort that would break your rev). > > David > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mb at mbtype.com Mon Sep 15 21:57:51 2014 From: mb at mbtype.com (Matthew Butterick) Date: Mon, 15 Sep 2014 18:57:51 -0700 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> Message-ID: <5417991F.8020807@mbtype.com> Mike Bostock's visual demonstration of why naive sorting functions are false friends. As he and Henglein point out, transitivity of the comparator is essential. http://bost.ocks.org/mike/shuffle/compare.html On 09/15/14 2:16 PM, Robby Findler wrote: > Fritz Henglein has studied the problem "what is a sorting function?" > that touches on this kind of thing. > > http://www.sciencedirect.com/science/article/pii/S1567832608001094 > > > Robby > > On Monday, September 15, 2014, David Van Horn > wrote: > > On 9/15/14, 4:53 PM, David Van Horn wrote: > > I don't think you made enough examples. > > Nope - my bad. Cute. Awful, but cute (and there could be correct > implementations of sort that would break your rev). > > David > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From oev-racket at sibmail.com Mon Sep 15 23:43:24 2014 From: oev-racket at sibmail.com (Evgeny Odegov) Date: Tue, 16 Sep 2014 10:43:24 +0700 (NOVT) Subject: [racket] Some problem with hash-update! In-Reply-To: <20140915153217.CF4C165018C@mail-svr1.cs.utah.edu> References: <52456.79.136.149.232.1410618490.squirrel@www.sibmail.com> <52709.79.136.149.232.1410623128.squirrel@www.sibmail.com> <20140914124010.BD2A765019F@mail-svr1.cs.utah.edu> <58297.91.221.60.217.1410754072.squirrel@www.sibmail.com> <20140915055811.D05D0650188@mail-svr1.cs.utah.edu> <62737.91.221.60.217.1410768252.squirrel@www.sibmail.com> <20140915153217.CF4C165018C@mail-svr1.cs.utah.edu> Message-ID: <52591.91.221.60.217.1410839004.squirrel@www.sibmail.com> > Using `#:atomic? #t` disables Racket thread switches, but it doesn't > disable GC. > It's not so much about modification as referencing the memory --- > either reading or writing --- across a potential GC. Thank you! It's clear now. > Now that I look closely, I think you need the `bytes-copy!` code that > you have commented out. Otherwise, initializing a array will read past > the end of the allocated byte string. > > For example, > > (define-cstruct _foo ([a _int] > [b (_string/locale/len 10000000)])) > > (make-foo 0 "boo") > > crashes for me, because 10000000 is big enough that it reads past > allocated regions. That example works if I uncomment your `bytes-copy!` > use, which makes it return a byte string that is 10000000 bytes long. Good example. I commented those lines to experiment and forgot about them. Thank you for your help! From asumu at ccs.neu.edu Mon Sep 15 23:50:49 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Mon, 15 Sep 2014 23:50:49 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: <5417991F.8020807@mbtype.com> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> Message-ID: <20140916035049.GS21882@localhost> On 2014-09-15 18:57:51 -0700, Matthew Butterick wrote: > Mike Bostock's visual demonstration of why naive sorting functions are false > friends. As he and Henglein point out, transitivity of the comparator is > essential. > > http://bost.ocks.org/mike/shuffle/compare.html Thanks, that's really interesting. Also means that our implementation of `shuffle` in Racket stdlib is not great: (define (shuffle l) (sort l < #:key (?(_) (random)) #:cache-keys? #t)) (more prose on the algorithm here: http://bost.ocks.org/mike/algorithms/#shuffling) Cheers, Asumu From eric.n.dobson at gmail.com Tue Sep 16 00:24:53 2014 From: eric.n.dobson at gmail.com (Eric Dobson) Date: Mon, 15 Sep 2014 21:24:53 -0700 Subject: [racket] on reversing a list by way of sort In-Reply-To: <20140916035049.GS21882@localhost> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> Message-ID: On Mon, Sep 15, 2014 at 8:50 PM, Asumu Takikawa wrote: > On 2014-09-15 18:57:51 -0700, Matthew Butterick wrote: >> Mike Bostock's visual demonstration of why naive sorting functions are false >> friends. As he and Henglein point out, transitivity of the comparator is >> essential. >> >> http://bost.ocks.org/mike/shuffle/compare.html > > Thanks, that's really interesting. Also means that our implementation of > `shuffle` in Racket stdlib is not great: > > (define (shuffle l) > (sort l < #:key (?(_) (random)) #:cache-keys? #t)) > > (more prose on the algorithm here: http://bost.ocks.org/mike/algorithms/#shuffling) This is different than linked algorithm. This one assigns a random number from [0,1) to each element where the linked algorithm assigns a random pairwise ordering to each comparison. I don't think there is anything wrong from a correctness standpoint on the stdlib's algorithm. > > Cheers, > Asumu > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From asumu at ccs.neu.edu Tue Sep 16 00:34:55 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Tue, 16 Sep 2014 00:34:55 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> Message-ID: <20140916043455.GT21882@localhost> On 2014-09-15 21:24:53 -0700, Eric Dobson wrote: > This is different than linked algorithm. This one assigns a random > number from [0,1) to each element where the linked algorithm assigns a > random pairwise ordering to each comparison. > > I don't think there is anything wrong from a correctness standpoint on > the stdlib's algorithm. Ah, you're right. I actually tried visualizing Racket's shuffle using picts and didn't notice any streaks so I was puzzled. That explains it. Cheers, Asumu From mb at mbtype.com Tue Sep 16 00:40:19 2014 From: mb at mbtype.com (Matthew Butterick) Date: Mon, 15 Sep 2014 21:40:19 -0700 Subject: [racket] on reversing a list by way of sort In-Reply-To: <20140916035049.GS21882@localhost> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> Message-ID: <5417BF33.9070407@mbtype.com> Haha, yes I too checked Racket `shuffle` after I read that. But `shuffle` is mathematically sound. (Was I really surprised?) It doesn't use a random comparator. Rather, it assigns random *keys* to the elements and then uses a standard `<` comparator, which preserves transitivity (net of the nanoscopic chance of `random` returning the same key twice). I also verified this experimentally using Bostock's bias-correlation technique. Here's Racket `shuffle` on a 10-card deck, shuffled a million times (truly random shuffling will produce values close to zero): +0.0037 -0.0037 +0.0107 -0.0087 +0.0049 +0.0432 -0.0306 +0.0025 -0.0319 +0.0099 -0.0589 +0.0066 +0.0295 -0.0337 -0.0308 +0.0288 -0.0106 +0.0375 +0.0202 +0.0114 -0.0191 +0.0381 -0.0308 -0.017 +0.0608 -0.0609 +0.0183 +0.0037 -0.0037 +0.0106 -0.0025 -0.0232 -0.0135 -0.0166 -0.0127 -0.0104 +0.0444 -0.0087 +0.0275 +0.0157 +0.0537 -0.0114 -0.0138 +0.0029 +0.0281 -0.0264 -0.0369 +0.0237 -0.0051 -0.0148 +0.0075 +0.0254 -0.0128 +0.048 +0.0309 -0.0053 -0.0055 -0.046 -0.0183 -0.0239 +0.0211 +0.005 -0.0162 +0.0326 -0.0019 -0.0062 -0.0423 -0.0036 +0.0501 -0.0386 +0.027 +0.0228 -0.0327 -0.001 -0.0256 +0.013 +0.0005 +0.0203 -0.0157 -0.0086 -0.0039 -0.059 +0.0769 -0.0294 -0.0045 +0.0046 +0.0121 -0.0035 -0.0344 +0.0411 -0.0286 -0.0006 +0.0027 +0.0229 -0.0492 +0.0196 +0.0506 -0.0259 +0.0113 -0.0028 And here's the evil random-comparator shuffle, which you write thus: (sort l (?(a b) (< (random) 0.5)) #:cache-keys? #t) +5.5262 +5.3953 +0.2165 -4.1699 -6.8645 +5.3694 +5.3138 +0.2238 -4.1352 -6.8754 +5.3552 +5.5478 +0.2443 -4.1483 -6.8783 +5.2901 +5.3356 +0.3061 -4.1741 -6.8784 +4.0834 +4.0231 +1.1727 -3.128 -6.0845 +4.0658 +4.0908 +0.9624 -3.0706 -6.1151 +2.2696 +2.3085 +1.3081 -1.1473 -4.5383 +2.236 +2.1868 +1.2539 -1.3606 -4.5167 +0.2824 +0.2988 +1.0478 +0.3734 -1.7924 +0.264 +0.2866 +0.9759 +0.2977 -2.0342 -1.1146 -1.1627 +0.4308 +1.2617 +0.452 -0.885 -1.1186 +0.4888 +1.2433 +0.4043 -1.6973 -1.7075 -0.0871 +1.4717 +1.8591 -1.6837 -1.4007 -0.087 +1.4763 +1.8562 -2.9075 -2.945 +0.3826 +2.2916 +3.0588 -2.9184 -2.9246 +0.5772 +2.3114 +3.0739 -4.9106 -4.8946 -0.9329 +4.7021 +5.8784 -4.8757 -4.8899 -0.942 +4.9596 +5.9056 -6.8868 -6.8637 -3.7828 +2.493 +14.9097 -6.8625 -6.8798 -3.7591 +2.4522 +15.1798 QED On 09/15/14 8:50 PM, Asumu Takikawa wrote: > On 2014-09-15 18:57:51 -0700, Matthew Butterick wrote: >> Mike Bostock's visual demonstration of why naive sorting functions are false >> friends. As he and Henglein point out, transitivity of the comparator is >> essential. >> >> http://bost.ocks.org/mike/shuffle/compare.html > Thanks, that's really interesting. Also means that our implementation of > `shuffle` in Racket stdlib is not great: > > (define (shuffle l) > (sort l < #:key (?(_) (random)) #:cache-keys? #t)) > > (more prose on the algorithm here: http://bost.ocks.org/mike/algorithms/#shuffling) > > Cheers, > Asumu From mflatt at cs.utah.edu Tue Sep 16 01:01:09 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Tue, 16 Sep 2014 07:01:09 +0200 Subject: [racket] Can a #reader be used with (module ...) ? In-Reply-To: <54174E28.4000001@mbtype.com> References: <54174E28.4000001@mbtype.com> Message-ID: <20140916050114.0F7CB650192@mail-svr1.cs.utah.edu> There's not currently anything like `#reader` that would hide a closing parenthesis from the reader. I think you could make a new reader that recurs to `read` with an input port that stops consuming input from the original just before a closing parenthesis followed by an EOF --- maybe by peeking at all the input to determine a length to pass to `call-with-limited-input-port`. Assuming that the new reader is in `with-limited-port`, then #lang racket/base (module inner racket/base '#reader with-limited-port #reader (submod pollen/main reader) Hello World ) could work. Or you could build that port-limiting approach into a new reader in a `limited-reader` submodule that always chains to the sibling `reader` submodule: #lang racket/base (module inner racket/base '#reader(submod pollen/main limited-reader)Hello World ) At Mon, 15 Sep 2014 13:38:00 -0700, Matthew Butterick wrote: > I'm aware that `#lang name ...` is equivalent to `(module id name ...)`. > But `#lang` automatically picks up a reader; `module` does not. > > Is there a way to attach a reader to the `module` form (the idea being > that then, within the `module` expression, you could write using the > native syntax of the #lang)? > > Studying the example in reader extensions (Guide ? 17.2), I found that > this works, but I haven't figured out if it can be generalized: > > #lang racket/base > (module inner racket/base > '(#reader"five.rkt"23456)) > (require 'inner) > > For instance, my current reader works in the REPL, like so: > > '#reader(submod pollen/main reader)Hello World > > But this doesn't work, because the reader, which operates in text mode, > absorbs the closing parenthesis: > > #lang racket/base > (module inner racket/base > '#reader(submod pollen/main reader)Hello World > ) > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From sperber at deinprogramm.de Tue Sep 16 04:01:00 2014 From: sperber at deinprogramm.de (Michael Sperber) Date: Tue, 16 Sep 2014 10:01:00 +0200 Subject: [racket] BOB 2015 - 2nd Call for Contributions (Deadline Sep 30) Message-ID: Submissions on/using/reporting on Racket welcome! BOB Conference 2015 Berlin 23.1.2015 http://bobkonf.de/2015/ CALL FOR CONTRIBUTIONS English: http://bobkonf.de/2015/cfp.html German: http://bobkonf.de/2015/cfp.html Deadline: September 30, 2014 You drive advanced software engineering methods, implement ambitious architectures and are open to cutting-edge innovation? Attend this conference, meet people that share your goals, and get to know the best software tools and technologies available today. We strive to offer you a day full of new experiences and impressions that you can use to immediately improve your daily life as a software developer. If you share our vision and want to contribute, submit a proposal for a talk or tutorial! We are looking for talks about best-of-breed software technology, e.g.: - functional programming - reactive programming - micro-service architectures - persistent data structures and databases - ? everything really that isn?t mainstream, but you think should be. Presenters should provide the audience with information that is practically useful for software developers. This could take the form of e.g.: - experience reports - introductory talks on technical background - demos and how-tos We accept proposals for presentations of 45 minutes (40 minutes talk + 5 minutes questions), as well as 90 minute tutorials for beginners. The language of presentation should be either English or German. It should include (in your presentation language of choice): - an abstract of max. 1500 characters. - a short bio/cv - contact information (including at least email) - a list of 3-5 concrete ideas of how your work can be applied in a developer's daily life - additional material (websites, blogs, slides, videos of past presentations, ?) You can submit your proposal using the following form: https://docs.google.com/spreadsheet/viewform?formkey=dHJ0TjR1cEhUWmdBZFVITGVRVWN5VEE6MA - direct questions to bobkonf at active minus group dot de - proposal deadline: September 30, 2014 - notification: October 15, 2014 - program: October 2014, 2014 NOTE: The conference fee will be waived for presenters, but travel expenses will not be covered. Program Committee - Matthias Fischmann, zerobuzz UG - Matthias Neubauer, SICK AG - Michael Sperber, Active Group - Stefan Wehr, factis research Wissenschaftlicher Beirat - Annette Bieniusa, TU Kaiserslautern - Torsten Grust, Uni T?bingen - Peter Thiemann, Uni Freiburg From eli at barzilay.org Tue Sep 16 06:12:54 2014 From: eli at barzilay.org (Eli Barzilay) Date: Tue, 16 Sep 2014 06:12:54 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: <5417BF33.9070407@mbtype.com> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: On Tue, Sep 16, 2014 at 12:34 AM, Asumu Takikawa wrote: > > Ah, you're right. I actually tried visualizing Racket's shuffle using > picts and didn't notice any streaks so I was puzzled. That explains it. The equivalent of Racket's shuffle on that page is the "sort (random order)", except that their version depends on a continuous range of integers (which the visualization always does). On Tue, Sep 16, 2014 at 12:40 AM, Matthew Butterick wrote: > > And here's the evil random-comparator shuffle, which you write thus: (sort l > (?(a b) (< (random) 0.5)) #:cache-keys? #t) (There's no need for caching the keys here.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From robby at eecs.northwestern.edu Tue Sep 16 08:22:19 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Tue, 16 Sep 2014 07:22:19 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: <5417BF33.9070407@mbtype.com> References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: But is fisher-yates is linear time, right? (And probably more efficient in practice on larger lists, if not smaller.) Robby On Mon, Sep 15, 2014 at 11:40 PM, Matthew Butterick wrote: > Haha, yes I too checked Racket `shuffle` after I read that. But `shuffle` is > mathematically sound. (Was I really surprised?) It doesn't use a random > comparator. Rather, it assigns random *keys* to the elements and then uses a > standard `<` comparator, which preserves transitivity (net of the nanoscopic > chance of `random` returning the same key twice). > > I also verified this experimentally using Bostock's bias-correlation > technique. Here's Racket `shuffle` on a 10-card deck, shuffled a million > times (truly random shuffling will produce values close to zero): > > +0.0037 -0.0037 +0.0107 -0.0087 +0.0049 +0.0432 > -0.0306 +0.0025 -0.0319 +0.0099 > -0.0589 +0.0066 +0.0295 -0.0337 -0.0308 +0.0288 > -0.0106 +0.0375 +0.0202 +0.0114 > -0.0191 +0.0381 -0.0308 -0.017 +0.0608 -0.0609 > +0.0183 +0.0037 -0.0037 +0.0106 > -0.0025 -0.0232 -0.0135 -0.0166 -0.0127 -0.0104 > +0.0444 -0.0087 +0.0275 +0.0157 > +0.0537 -0.0114 -0.0138 +0.0029 +0.0281 -0.0264 > -0.0369 +0.0237 -0.0051 -0.0148 > +0.0075 +0.0254 -0.0128 +0.048 +0.0309 -0.0053 > -0.0055 -0.046 -0.0183 -0.0239 > +0.0211 +0.005 -0.0162 +0.0326 -0.0019 -0.0062 > -0.0423 -0.0036 +0.0501 -0.0386 > +0.027 +0.0228 -0.0327 -0.001 -0.0256 +0.013 +0.0005 > +0.0203 -0.0157 -0.0086 > -0.0039 -0.059 +0.0769 -0.0294 -0.0045 +0.0046 > +0.0121 -0.0035 -0.0344 +0.0411 > -0.0286 -0.0006 +0.0027 +0.0229 -0.0492 +0.0196 > +0.0506 -0.0259 +0.0113 -0.0028 > > And here's the evil random-comparator shuffle, which you write thus: (sort l > (?(a b) (< (random) 0.5)) #:cache-keys? #t) > > +5.5262 +5.3953 +0.2165 -4.1699 -6.8645 +5.3694 > +5.3138 +0.2238 -4.1352 -6.8754 > +5.3552 +5.5478 +0.2443 -4.1483 -6.8783 +5.2901 > +5.3356 +0.3061 -4.1741 -6.8784 > +4.0834 +4.0231 +1.1727 -3.128 -6.0845 +4.0658 > +4.0908 +0.9624 -3.0706 -6.1151 > +2.2696 +2.3085 +1.3081 -1.1473 -4.5383 +2.236 > +2.1868 +1.2539 -1.3606 -4.5167 > +0.2824 +0.2988 +1.0478 +0.3734 -1.7924 +0.264 > +0.2866 +0.9759 +0.2977 -2.0342 > -1.1146 -1.1627 +0.4308 +1.2617 +0.452 -0.885 > -1.1186 +0.4888 +1.2433 +0.4043 > -1.6973 -1.7075 -0.0871 +1.4717 +1.8591 -1.6837 > -1.4007 -0.087 +1.4763 +1.8562 > -2.9075 -2.945 +0.3826 +2.2916 +3.0588 -2.9184 > -2.9246 +0.5772 +2.3114 +3.0739 > -4.9106 -4.8946 -0.9329 +4.7021 +5.8784 -4.8757 > -4.8899 -0.942 +4.9596 +5.9056 > -6.8868 -6.8637 -3.7828 +2.493 +14.9097 -6.8625 > -6.8798 -3.7591 +2.4522 +15.1798 > > QED > > > > On 09/15/14 8:50 PM, Asumu Takikawa wrote: >> >> On 2014-09-15 18:57:51 -0700, Matthew Butterick wrote: >>> >>> Mike Bostock's visual demonstration of why naive sorting functions are >>> false >>> friends. As he and Henglein point out, transitivity of the comparator is >>> essential. >>> >>> http://bost.ocks.org/mike/shuffle/compare.html >> >> Thanks, that's really interesting. Also means that our implementation of >> `shuffle` in Racket stdlib is not great: >> >> (define (shuffle l) >> (sort l < #:key (?(_) (random)) #:cache-keys? #t)) >> >> (more prose on the algorithm here: >> http://bost.ocks.org/mike/algorithms/#shuffling) >> >> Cheers, >> Asumu > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From geoff at knauth.org Tue Sep 16 09:22:42 2014 From: geoff at knauth.org (Geoffrey S. Knauth) Date: Tue, 16 Sep 2014 09:22:42 -0400 Subject: [racket] pregexp to detect Japanese characters Message-ID: <1410873762.3653302.168100665.5BFF00B3@webmail.messagingengine.com> I'm writing a function to detect Japanese characters in a string. I found this page: [1]http://www.localizingjapan.com/blog/2012/01/20/regular-expre ssions-for-japanese-text/ So, for example, the example Perl regexp [\x{3041}-\x{3096}] would detect Hiragana characters (as would \p{Hiragana}). How do I express such a Unicode range with Racket regexps? I looked at the docs below and it wasn't obvious to me how to do it. In other languages there might be, for example, a \xnnnn or \uxxxx construct. [2]http://docs.racket-lang.org/reference/regexp.html#%28elem._% 28rxex._30%29%29 -- Geoffrey S. Knauth | http://knauth.org/gsk References 1. http://www.localizingjapan.com/blog/2012/01/20/regular-expressions-for-japanese-text/ 2. http://docs.racket-lang.org/reference/regexp.html#%28elem._%28rxex._30%29%29 -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Tue Sep 16 09:55:26 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Tue, 16 Sep 2014 08:55:26 -0500 Subject: [racket] OOPSLA/SPLASH early registration deadline approaching Message-ID: This is a reminder that the SPLASH Early Registration closes this week on Friday 19 September. http://2014.splashcon.org/attending/registration Also please don?t forget to reserve your hotel room at the Portland Marriott Waterfront. [1] ACM Conference on Systems, Programming, Languages, and Applications: Software for Humanity (SPLASH'14) Portland, Oregon, USA 20-24 October, 2014 http://www.splashcon.org http://twitter.com/splashcon http://www.facebook.com/SPLASHCon Sponsored by ACM SIGPLAN In cooperation with ACM SIGAda The ACM SIGPLAN conference on Systems, Programming, Languages and Applications: Software for Humanity (SPLASH) embraces all aspects of software construction and delivery to make it the premier conference at the intersection of programming, languages, and software engineering. [1] Why stay at the conference hotel? http://2014.splashcon.org/attending/accommodation From geoff at knauth.org Tue Sep 16 10:13:38 2014 From: geoff at knauth.org (Geoffrey S. Knauth) Date: Tue, 16 Sep 2014 10:13:38 -0400 Subject: [racket] pregexp to detect Japanese characters In-Reply-To: <1410873762.3653302.168100665.5BFF00B3@webmail.messagingengine.com> References: <1410873762.3653302.168100665.5BFF00B3@webmail.messagingengine.com> Message-ID: <10A07DD2-53D6-4C8E-9CAE-89AA320306A0@knauth.org> NEVER MIND. I figured it out: ; detects japanese characters ; contains-japanese-characters? str -> bool (define (contains-japanese-characters? s) (or (regexp-match #rx"[\u3041-\u3096]" s) ; Hiragana (regexp-match #rx"[\u30A0-\u30FF]" s) ; Katakana (Full Width) (regexp-match #rx"[\u3400-\u4DB5\u4E00-\u9FCB\uF900-\uFA6A]" s) ; Kanji (regexp-match #rx"[\u2E80-\u2FD5]" s) ; Kanji Radicals (regexp-match #rx"[\uFF5F-\uFF9F]" s) ; Katakana and Punctuation (Half Width) (regexp-match #rx"[\u3000-\u303F]" s) ; Japanese Symbols and Punctuation (regexp-match #rx"[\u31F0-\u31FF\u3220-\u3243\u3280-\u337F]" s) ; Misc. Japanese Symbols/Chars (regexp-match #rx"[\uFF01-\uFF5E]" s))) ; Alphanumeric and Punctuation (Full Width) On Sep 16, 2014, at 09:22 , Geoffrey S. Knauth wrote: > I'm writing a function to detect Japanese characters in a string. I found this page: > > http://www.localizingjapan.com/blog/2012/01/20/regular-expressions-for-japanese-text/ > > So, for example, the example Perl regexp [\x{3041}-\x{3096}] would detect Hiragana characters (as would \p{Hiragana}). How do I express such a Unicode range with Racket regexps? > > I looked at the docs below and it wasn't obvious to me how to do it. In other languages there might be, for example, a \xnnnn or \uxxxx construct. > > http://docs.racket-lang.org/reference/regexp.html#%28elem._%28rxex._30%29%29 > > -- > Geoffrey S. Knauth | http://knauth.org/gsk > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpavlov at ipa.nw.ru Tue Sep 16 17:12:38 2014 From: dpavlov at ipa.nw.ru (dpavlov at ipa.nw.ru) Date: Wed, 17 Sep 2014 01:12:38 +0400 Subject: [racket] Spreadsheet editor Message-ID: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> Hello, I have made a reusable version of my spreadsheet editor. Its capabilities are limited to the needs of my app, so not much: - Fixed number of columns with arbitrary labels, which can be changed while running. The number of columns does not scale well: 1000 is OK, while 100 000 is not. The width of the column is adjusted dynamically so that the column label is visible and all the visible cells are not cut. Otherwise, column width is not changeable. - Arbitrary number of rows with arbitrary labels. As many rows as you want. Rows can be added or removed while running. - Clickable buttons for columns and rows with arbitrary callbacks. - Editable (text-only, one-line) cells with arbitrary callbacks for displaying the cells or updating their contents. - Scrolling bars (well, sliders), also arrow keys and PgUp/PgDn should work. Here is the editor along with a demo: https://github.com/kugelblitz/spreadsheet-editor I see two issues currently: * During editing, text snip creates a white plate that extends outside the supposed borders of the snip. See [1] for details. * Racket GUI does not provide scroll bars that one can use independently from canvas or panel. I currently use sliders instead of scroll bars, but with slider, it is impossible to go up/down by exactly one point. Also, it is not possible to update the limits of the slider, so I have to re-create it when I add or remove a row from the table. I would love to hear any comments regarding those issues, or any other issues, or anything that draws your attention in the source code. [1] http://lists.racket-lang.org/users/archive/2014-September/064137.html From jab at math.brown.edu Tue Sep 16 19:06:59 2014 From: jab at math.brown.edu (jab at math.brown.edu) Date: Tue, 16 Sep 2014 19:06:59 -0400 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: Dear Racket Users, On Wed, Apr 16, 2014 at 4:45 PM, wrote: > I recently asked here about in-person Racket courses available this summer > which I could recommend to a student I've been tutoring. (Thanks again to > everyone who let me know about their courses so far.) > > To make this info easier to find, I'm wondering if the racket-lang.org > maintainers would be interested in publishing a canonical index of Racket > courses (both online and in-person) linked off the "Community" or > "Learning" sections on the homepage, and inviting the community to add to > it. > > (Similarly, linking to a canonical index of Racket meetup groups (? la > http://clojure.meetup.com/ and > https://wiki.python.org/moin/LocalUserGroups) would be great too. Google > turned up http://racket.meetup.com/ but 2 of the 3 results there are for > racket sports.) > > Thanks, and looking forward to knowing how to become better plugged into > the Racket community! > Didn't get any reply to this last April, so just thought I'd try again. In case anyone who'd want to reply just missed it! Wish I could join those of you in St. Louis this week. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Tue Sep 16 20:43:07 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Tue, 16 Sep 2014 20:43:07 -0400 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: You're right, we failed to follow up on the general part of your email. Do you imagine listing college courses such as Brown's 17, which uses DrRacket and the teaching languages? Or do you want Coursera courses that everyone can access? Do you want it all? now? :-) And yes, we should probably create a wiki like thing for such an effort or perhaps something like packages.racket-lang.org. I'll bring it up as we meet in St Louis -- Matthias On Sep 16, 2014, at 7:06 PM, jab at math.brown.edu wrote: > Dear Racket Users, > > > On Wed, Apr 16, 2014 at 4:45 PM, wrote: > I recently asked here about in-person Racket courses available this summer which I could recommend to a student I've been tutoring. (Thanks again to everyone who let me know about their courses so far.) > > To make this info easier to find, I'm wondering if the racket-lang.org maintainers would be interested in publishing a canonical index of Racket courses (both online and in-person) linked off the "Community" or "Learning" sections on the homepage, and inviting the community to add to it. > > (Similarly, linking to a canonical index of Racket meetup groups (? la http://clojure.meetup.com/ and https://wiki.python.org/moin/LocalUserGroups) would be great too. Google turned up http://racket.meetup.com/ but 2 of the 3 results there are for racket sports.) > > Thanks, and looking forward to knowing how to become better plugged into the Racket community! > > > Didn't get any reply to this last April, so just thought I'd try again. In case anyone who'd want to reply just missed it! Wish I could join those of you in St. Louis this week. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From eli at barzilay.org Tue Sep 16 21:22:27 2014 From: eli at barzilay.org (Eli Barzilay) Date: Tue, 16 Sep 2014 21:22:27 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: On Tue, Sep 16, 2014 at 8:22 AM, Robby Findler wrote: > But is fisher-yates is linear time, right? (And probably more > efficient in practice on larger lists, if not smaller.) Yes, but there are more considerations that I had when I did the simple version. In case anyone wants to tackle this, what I vaguely remember is: * FY is faster, but will require much more than a one-liner, since the list needs to be copied into a vector, then shuffled in-place, then copied back. I'm not saying that this will make it slower -- since sort is doing a vector round-trip anyway; it'll just make it much heavier than something that is not needed too often, and probably very rarely with big lists when the differene would matter. * Looking at the wikipedia page to refresh myself, there is also an "inside-out" algorithm that they say is better for creating a shuffled copy of the input vector. The nice thing in that is that it scans the source vector in sequence, which means that it could work well to use it, taking items from the list and putting them into an array that is then converted back into a list. * I vaguely remember something about the problem of using integer random numbers, which are usually the result of modulo (the WP page talks about it too). I think that there was some concern about that possibly leading to some bias in the result somehow. As a result, since I don't know enough about such issues, I used (random) which has the additional penalty of allocating floats. IOW, the nice thing about the current one-liner is that I didn't need to go too deep into considering such issues, allowing me to keep my ignorance while being relatively confident in the result not suffering from any bias. In any case, this is also a point to consider if anyone wants to implement FY. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From daniel.a.prager at gmail.com Tue Sep 16 23:08:22 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Tue, 16 Sep 2014 22:08:22 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: Here's a version of "inside-out" Fisher-Yates that should fit the bill: (define (fy-shuffle lst) (define v (list->vector lst)) (for/list ([n (in-range (length lst) 0 -1)]) (let* ([i (sub1 n)] [j (random n)] [v_j (vector-ref v j)]) (when (not (= i j)) (vector-set! v j (vector-ref v i))) v_j))) Dan On Tue, Sep 16, 2014 at 8:22 PM, Eli Barzilay wrote: > On Tue, Sep 16, 2014 at 8:22 AM, Robby Findler > wrote: > > But is fisher-yates is linear time, right? (And probably more > > efficient in practice on larger lists, if not smaller.) > > Yes, but there are more considerations that I had when I did the simple > version. In case anyone wants to tackle this, what I vaguely remember > is: > > * FY is faster, but will require much more than a one-liner, since the > list needs to be copied into a vector, then shuffled in-place, then > copied back. I'm not saying that this will make it slower -- since > sort is doing a vector round-trip anyway; it'll just make it much > heavier than something that is not needed too often, and probably very > rarely with big lists when the differene would matter. > > * Looking at the wikipedia page to refresh myself, there is also an > "inside-out" algorithm that they say is better for creating a shuffled > copy of the input vector. The nice thing in that is that it scans the > source vector in sequence, which means that it could work well to use > it, taking items from the list and putting them into an array that is > then converted back into a list. > > * I vaguely remember something about the problem of using integer random > numbers, which are usually the result of modulo (the WP page talks > about it too). I think that there was some concern about that > possibly leading to some bias in the result somehow. As a result, > since I don't know enough about such issues, I used (random) which has > the additional penalty of allocating floats. IOW, the nice thing > about the current one-liner is that I didn't need to go too deep into > considering such issues, allowing me to keep my ignorance while being > relatively confident in the result not suffering from any bias. > > In any case, this is also a point to consider if anyone wants to > implement FY. > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: > http://barzilay.org/ Maze is Life! > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- *Daniel Prager* Agile/Lean Coaching, Software Development and Leadership Startup: www.youpatch.com Twitter: @agilejitsu Blog: agile-jitsu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From neil at neilvandyke.org Tue Sep 16 23:31:29 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Tue, 16 Sep 2014 23:31:29 -0400 Subject: [racket] new Jr. Racket Developer job Message-ID: <54190091.80406@neilvandyke.org> I'm helping a colleague hire a smart junior-level Racket developer. The job spec is still being ironed-out, but a top candidate would be someone smart and responsible, and who has some experience with all of Racket, Java, and Python. More important than any particular languages/tools is the demonstrated capacity to grasp more than one programming paradigm. So, if you've done idiomatic programming in each of, say, Racket, SIMULA, and ALGOL, you'd still be a good candidate. Already knowing some Racket really helps you stand out, though. This is for a real full-time salaried job, with the usual benefits. Telecommuting is possible, and the office is in the Eastern NY state area (not NYC area). The company is not a startup nor a dotcom, and it is not all Google-exciting (no snack rooms, no plastic ball pools, no concierges). This is an established, stable, small-to-mid company, in a group that works on sober things like safety-critical process improvement. An official job posting will be made later, once details are figured out. But I'm testing the waters initially just on this Racket email list. So, if you're still reading this post to this Racket email list, and you're interested in this junior-level Racket developer position, then please feel free to email your resume to me now (in PDF or ASCII format), and I'll pass it along. BTW, the job is "junior" only in terms of professional Racket development experience, and in the challenge level of work needed right now. It's very much open to all ages, and diversity is also welcome in general at the company. Please *don't* re-post this elsewhere at this time; my email beep thanks you. Neil V. From eli at barzilay.org Wed Sep 17 00:01:45 2014 From: eli at barzilay.org (Eli Barzilay) Date: Wed, 17 Sep 2014 00:01:45 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: In Tue, Sep 16, 2014 at 11:08 PM, Daniel Prager wrote: > Here's a version of "inside-out" Fisher-Yates that should fit the bill: > > (define (fy-shuffle lst) > (define v (list->vector lst)) > (for/list ([n (in-range (length lst) 0 -1)]) > (let* ([i (sub1 n)] > [j (random n)] > [v_j (vector-ref v j)]) > (when (not (= i j)) > (vector-set! v j (vector-ref v i))) > v_j))) I was thinking more of a direct translation, which (I think) is easier to see that it's correct: (define (shuffle l) (define a (make-vector (length l))) (for ([x (in-list l)] [i (in-naturals)]) (define j (random (add1 i))) (unless (= j i) (vector-set! a i (vector-ref a j))) (vector-set! a j x)) (vector->list a)) But the issues from my last email are still there. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From daniel.a.prager at gmail.com Wed Sep 17 01:53:59 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Wed, 17 Sep 2014 00:53:59 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: Hi Eli I tried to squeeze out a little more efficiency, hopefully not at the expense of too much loss of clarity, but I'm not overly fussed which exact version of Fisher-Yates is (hopefully ;-) adopted. [Sorry for drawing you further in.] My take on your 3 points: 1. Fisher-Yates is only a few lines, so although not a one-liner, it seems reasonable to use it for the better space and time performance. 2. I agree that an inside-out version is more apt. 3. On my reading the final point is an issue if (random n) has problems like modulo bias, but if that's the case surely it is (random n) that needs fixing. Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: From mukeshtiwari.iiitm at gmail.com Wed Sep 17 02:04:19 2014 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Wed, 17 Sep 2014 11:34:19 +0530 Subject: [racket] Racket guide Message-ID: Dear Racket Users, I am learning racket and I found little bit misleading statement on guide [1]. It says that "*Both the my-length and my-map functions run in O(n) time for a list of length n.*". Technically this statement is correct but when I read below " *For a list with n elements, evaluation will stack up n (+ 1 ...) additions, and then finally add them up when the list is exhausted.You can avoid piling up additions by adding along the way. To accumulate a length this way, we need a function that takes both a list and the length of the list seen so far; the code below uses a local function iter that accumulates the length in an argument len*". so just curious, shouldn't it be "*Both the my-length and my-map functions run in O(n) space for a list of length n.*" ? -Mukesh Tiwari [1] http://docs.racket-lang.org/guide/Lists__Iteration__and_Recursion.html#%28part._tail-recursion%29 -------------- next part -------------- An HTML attachment was scrubbed... URL: From eli at barzilay.org Wed Sep 17 02:44:40 2014 From: eli at barzilay.org (Eli Barzilay) Date: Wed, 17 Sep 2014 02:44:40 -0400 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: On Wed, Sep 17, 2014 at 1:53 AM, Daniel Prager wrote: > > [Sorry for drawing you further in.] :) (Indeed, my main point is that all that random-number stuff is foreign to me...) > My take on your 3 points: > > Fisher-Yates is only a few lines, so although not a one-liner, it > seems reasonable to use it for the better space and time performance. (It's just time -- the space is the roughly same for both, since sorting will create an intermediate vector too.) > I agree that an inside-out version is more apt. > On my reading the final point is an issue if (random n) has problems > like modulo bias, but if that's the case surely it is (random n) that > needs fixing. It goes into all kinds of arguments that are exactly in that area that I'm trying to avoid -- but IIUC, it's hard to avoid module-biases, and the FY use of `random' is particularly nasty since it uses all modulos in the range of the number of items. See also the point that the WP page makes about the size of the random number generator state, and how it limits the number of different permutations that can be generated. It looks to me like Racket's state is made of 6 fixnums => 2^192 states, which still doesn't cover all of the permutations of 52 cards. I have no idea if this is correct, if some bias reduces the number of permutations, or whether all of this is something to worry about... -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From daniel.a.prager at gmail.com Wed Sep 17 08:29:46 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Wed, 17 Sep 2014 07:29:46 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: Modulo bias is easy enough to correct by checking and occasional re-sampling. It's explained nicely in the following article: http://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/ Let's *deliberately* generate some modulo bias in Racket by simulating a low largest random number: (define (biased-random RAND-MAX n) (modulo (random (add1 RAND-MAX)) 3)) (define (check-bias method [n 10000]) (define sample (for/list ([i n]) (method 4 3))) (for ([i (in-range 3)]) (displayln (~a i " " (~a (real->decimal-string (* 100.0 (/ (count (? (j) (= i j)) sample) n)) 1) "%"))))) > (check-bias biased-random) 0 38.3% 1 41.0% 2 20.7% Remove the generated bias by rejecting some "high" values: (define (unbiased-random RAND-MAX n) (define excess (add1 (modulo RAND-MAX n))) (define limit (- RAND-MAX excess)) (define (in-limit m) (if (<= m limit) m (in-limit (random (add1 RAND-MAX))))) (modulo (in-limit (random (add1 RAND-MAX))) n)) > (check-bias unbiased-random) 0 33.9% 1 33.8% 2 32.4% Conclusion: We should be ok regarding modulo bias provided (random n) uses a rejection strategy along these lines. If not, it's quite fixable. Dan On Wed, Sep 17, 2014 at 1:44 AM, Eli Barzilay wrote: > On Wed, Sep 17, 2014 at 1:53 AM, Daniel Prager > wrote: > > > > [Sorry for drawing you further in.] > > :) (Indeed, my main point is that all that random-number stuff is > foreign to me...) > > > > My take on your 3 points: > > > > Fisher-Yates is only a few lines, so although not a one-liner, it > > seems reasonable to use it for the better space and time performance. > > (It's just time -- the space is the roughly same for both, since sorting > will create an intermediate vector too.) > > > I agree that an inside-out version is more apt. > > On my reading the final point is an issue if (random n) has problems > > like modulo bias, but if that's the case surely it is (random n) that > > needs fixing. > > It goes into all kinds of arguments that are exactly in that area that > I'm trying to avoid -- but IIUC, it's hard to avoid module-biases, and > the FY use of `random' is particularly nasty since it uses all modulos > in the range of the number of items. See also the point that the WP > page makes about the size of the random number generator state, and how > it limits the number of different permutations that can be generated. > It looks to me like Racket's state is made of 6 fixnums => 2^192 states, > which still doesn't cover all of the permutations of 52 cards. I have > no idea if this is correct, if some bias reduces the number of > permutations, or whether all of this is something to worry about... > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: > http://barzilay.org/ Maze is Life! > -- *Daniel Prager* Agile/Lean Coaching, Software Development and Leadership Startup: www.youpatch.com Twitter: @agilejitsu Blog: agile-jitsu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Wed Sep 17 10:14:46 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Wed, 17 Sep 2014 09:14:46 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: There was a bunch of work done to improve the random number generation algorithms used internally a while back, but if you wanted to have a look at them again, that would be most welcome. Here is a at least part of the code: https://github.com/plt/racket/blob/master/racket/src/racket/src/random.inc Robby On Wed, Sep 17, 2014 at 7:29 AM, Daniel Prager wrote: > Modulo bias is easy enough to correct by checking and occasional > re-sampling. It's explained nicely in the following article: > http://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/ > > Let's *deliberately* generate some modulo bias in Racket by simulating a low > largest random number: > > (define (biased-random RAND-MAX n) > (modulo (random (add1 RAND-MAX)) 3)) > > > (define (check-bias method [n 10000]) > (define sample (for/list ([i n]) (method 4 3))) > > (for ([i (in-range 3)]) > (displayln > (~a i " " (~a (real->decimal-string > (* 100.0 (/ (count (? (j) (= i j)) sample) n)) > 1) "%"))))) > >> (check-bias biased-random) > 0 38.3% > 1 41.0% > 2 20.7% > > Remove the generated bias by rejecting some "high" values: > > > (define (unbiased-random RAND-MAX n) > (define excess (add1 (modulo RAND-MAX n))) > (define limit (- RAND-MAX excess)) > (define (in-limit m) > (if (<= m limit) m (in-limit (random (add1 RAND-MAX))))) > (modulo (in-limit (random (add1 RAND-MAX))) n)) > > >> (check-bias unbiased-random) > 0 33.9% > 1 33.8% > 2 32.4% > > Conclusion: We should be ok regarding modulo bias provided (random n) uses a > rejection strategy along these lines. If not, it's quite fixable. > > Dan > > On Wed, Sep 17, 2014 at 1:44 AM, Eli Barzilay wrote: >> >> On Wed, Sep 17, 2014 at 1:53 AM, Daniel Prager >> wrote: >> > >> > [Sorry for drawing you further in.] >> >> :) (Indeed, my main point is that all that random-number stuff is >> foreign to me...) >> >> >> > My take on your 3 points: >> > >> > Fisher-Yates is only a few lines, so although not a one-liner, it >> > seems reasonable to use it for the better space and time performance. >> >> (It's just time -- the space is the roughly same for both, since sorting >> will create an intermediate vector too.) >> >> > I agree that an inside-out version is more apt. >> > On my reading the final point is an issue if (random n) has problems >> > like modulo bias, but if that's the case surely it is (random n) that >> > needs fixing. >> >> It goes into all kinds of arguments that are exactly in that area that >> I'm trying to avoid -- but IIUC, it's hard to avoid module-biases, and >> the FY use of `random' is particularly nasty since it uses all modulos >> in the range of the number of items. See also the point that the WP >> page makes about the size of the random number generator state, and how >> it limits the number of different permutations that can be generated. >> It looks to me like Racket's state is made of 6 fixnums => 2^192 states, >> which still doesn't cover all of the permutations of 52 cards. I have >> no idea if this is correct, if some bias reduces the number of >> permutations, or whether all of this is something to worry about... >> >> -- >> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: >> http://barzilay.org/ Maze is Life! > > > > > -- > Daniel Prager > Agile/Lean Coaching, Software Development and Leadership > Startup: www.youpatch.com > Twitter: @agilejitsu > Blog: agile-jitsu.blogspot.com > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From samth at cs.indiana.edu Wed Sep 17 10:51:19 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Wed, 17 Sep 2014 10:51:19 -0400 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: I've now created a wiki page for this, with some initial content: https://github.com/plt/racket/wiki/Courses-using-Racket If you teach (or know of) a course using Racket/HtDP/etc, please add it there. Sam On Tue, Sep 16, 2014 at 8:43 PM, Matthias Felleisen wrote: > > You're right, we failed to follow up on the general part of your email. > > Do you imagine listing college courses such as Brown's 17, which uses > DrRacket and the teaching languages? Or do you want Coursera courses that > everyone can access? Do you want it all? now? :-) > > And yes, we should probably create a wiki like thing for such an effort or > perhaps something like packages.racket-lang.org. I'll bring it up as we meet > in St Louis > > -- Matthias > > > > > > On Sep 16, 2014, at 7:06 PM, jab at math.brown.edu wrote: > > Dear Racket Users, > > > On Wed, Apr 16, 2014 at 4:45 PM, wrote: >> >> I recently asked here about in-person Racket courses available this summer >> which I could recommend to a student I've been tutoring. (Thanks again to >> everyone who let me know about their courses so far.) >> >> To make this info easier to find, I'm wondering if the racket-lang.org >> maintainers would be interested in publishing a canonical index of Racket >> courses (both online and in-person) linked off the "Community" or "Learning" >> sections on the homepage, and inviting the community to add to it. >> >> (Similarly, linking to a canonical index of Racket meetup groups (? la >> http://clojure.meetup.com/ and https://wiki.python.org/moin/LocalUserGroups) >> would be great too. Google turned up http://racket.meetup.com/ but 2 of the >> 3 results there are for racket sports.) >> >> Thanks, and looking forward to knowing how to become better plugged into >> the Racket community! > > > > Didn't get any reply to this last April, so just thought I'd try again. In > case anyone who'd want to reply just missed it! Wish I could join those of > you in St. Louis this week. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From kalimehtar at mail.ru Wed Sep 17 12:59:15 2014 From: kalimehtar at mail.ru (=?UTF-8?B?Um9tYW4gS2xvY2hrb3Y=?=) Date: Wed, 17 Sep 2014 20:59:15 +0400 Subject: [racket] =?utf-8?q?Exception_decorator=2E_is_it_possible=3F?= Message-ID: <1410973155.471904896@f186.i.mail.ru> I'm writeing a parser. So I want to see in parser exception what happend and when (not only where). (define (parse-item item) ? ?(with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message (format "At item ~a\n~a" item (exn-message e))])))]) ? ? ? ? ?....)) But this way I lose all exception types. Is there a way to change exception message, saving its type, except long copy/paste like (with-handlers ([exn:fail:contract:arity? (raise (struct-copy exn:fail:contract:arity ...))] ? ? ? ? ? ? ? ? ? ? ? ? ?[exn:fil:contract? (raise?(struct-copy exn:fail:contract ...))] ? ? ? ? ? ? ? ? ? ? ? ? ?...) ? ?...) ? -- Roman Klochkov -------------- next part -------------- An HTML attachment was scrubbed... URL: From jensaxel at soegaard.net Wed Sep 17 13:37:47 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Wed, 17 Sep 2014 19:37:47 +0200 Subject: [racket] Spreadsheet editor In-Reply-To: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> References: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> Message-ID: Nice work! > I see two issues currently: > > * During editing, text snip creates a white plate that > extends outside the supposed borders of the snip. > See [1] for details. > > * Racket GUI does not provide scroll bars that one can > use independently from canvas or panel. I currently > use sliders instead of scroll bars, but with slider, > it is impossible to go up/down by exactly one point. > Also, it is not possible to update the limits of the > slider, so I have to re-create it when I add or remove > a row from the table. > > I would love to hear any comments regarding those issues, > or any other issues, or anything that draws your > attention in the source code. The first issue is very apparent. I am -- Jens Axel S?gaard From m4burns at uwaterloo.ca Wed Sep 17 14:15:17 2014 From: m4burns at uwaterloo.ca (Marc Burns) Date: Wed, 17 Sep 2014 14:15:17 -0400 Subject: [racket] Exception decorator. is it possible? In-Reply-To: <1410973155.471904896@f186.i.mail.ru> References: <1410973155.471904896@f186.i.mail.ru> Message-ID: <20140917181517.GA18713@happierface> It's not generally possible to edit the message contained in an exception. However, you can add information to the program's stack using continuation marks. Here's an example: (define my-cont-mark-key (gensym)) (define (parse-item item) (with-continuation-mark my-cont-mark-key item ...)) (with-handlers ([exn? (lambda(e) ((error-display-handler) (format "Parser exception at item ~a:\n~a" (first (continuation-mark-set->list (exn-continuation-marks e) my-cont-mark-key)) (exn-message e)) e))]) (parse-item start-item)) The exception captures the continuation marks installed when it is thrown. You can extract the information you added to the stack with these marks in the exception handler. On Wed, Sep 17, 2014 at 08:59:15PM +0400, Roman Klochkov wrote: > I'm writeing a parser. > So I want to see in parser exception what happend and when (not only where). > > (define (parse-item item) > ?? ??(with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message (format "At item ~a\n~a" item (exn-message e))])))]) > ?? ?? ?? ?? ??....)) > > But this way I lose all exception types. Is there a way to change exception message, saving its type, except long copy/paste like > (with-handlers ([exn:fail:contract:arity? (raise (struct-copy exn:fail:contract:arity ...))] > ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??[exn:fil:contract? (raise??(struct-copy exn:fail:contract ...))] > ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??...) > ?? ??...) > > ? > > -- > Roman Klochkov > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dvanhorn at cs.umd.edu Wed Sep 17 16:41:52 2014 From: dvanhorn at cs.umd.edu (David Van Horn) Date: Wed, 17 Sep 2014 16:41:52 -0400 Subject: [racket] frtime Message-ID: <5419F210.3090606@cs.umd.edu> This program is less flashy than it used to be: #lang frtime seconds Is FrTime still supported? Is there a way to get the old behavior of being, well, reactive? David From dpavlov at ipa.nw.ru Wed Sep 17 16:48:47 2014 From: dpavlov at ipa.nw.ru (dpavlov at ipa.nw.ru) Date: Thu, 18 Sep 2014 00:48:47 +0400 Subject: [racket] Spreadsheet editor In-Reply-To: References: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> Message-ID: <7e6737e7c1eb72dc9801e548b44ab112@ipa.nw.ru> Jens, > Nice work! Thanks! > The first issue is very apparent. I am You most probably sent an unfinished message, did you notice that? Regards, Dmitry From jensaxel at soegaard.net Wed Sep 17 16:51:07 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Wed, 17 Sep 2014 22:51:07 +0200 Subject: [racket] Spreadsheet editor In-Reply-To: <7e6737e7c1eb72dc9801e548b44ab112@ipa.nw.ru> References: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> <7e6737e7c1eb72dc9801e548b44ab112@ipa.nw.ru> Message-ID: Hi, Gmail had a temporary problem. It should have said, that I don't know of way to fix it. /Jens Axel 2014-09-17 22:48 GMT+02:00 : > Jens, > >> Nice work! > > > Thanks! > >> The first issue is very apparent. I am > > > You most probably sent an unfinished message, did you notice that? > > > Regards, > > Dmitry > -- -- Jens Axel S?gaard From jay.mccarthy at gmail.com Wed Sep 17 17:06:27 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Wed, 17 Sep 2014 17:06:27 -0400 Subject: [racket] frtime In-Reply-To: <5419F210.3090606@cs.umd.edu> References: <5419F210.3090606@cs.umd.edu> Message-ID: That program never did what you were hoping for. The program that we demo had you choose "FrTime" from the "Choose a Language..." dialog. The difference is that the language level can include its snip code inside DrRacket and get its GUI to update. #langs cannot do that at all. Robby and I have talked many times about how to allow it, but it is unclear how to do it safely. As an aside, the real demo is currently broken for a different reason, that I think is related to the undefined change. I'll look into it. Jay On Wed, Sep 17, 2014 at 4:41 PM, David Van Horn wrote: > This program is less flashy than it used to be: > > #lang frtime > seconds > > Is FrTime still supported? Is there a way to get the old behavior of > being, well, reactive? > > David > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From matthias at ccs.neu.edu Wed Sep 17 14:49:41 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed, 17 Sep 2014 14:49:41 -0400 Subject: [racket] Racket guide In-Reply-To: References: Message-ID: On Sep 17, 2014, at 2:04 AM, mukesh tiwari wrote: > Dear Racket Users, > I am learning racket and I found little bit misleading statement on guide [1]. It says that "Both the my-length and my-map functions run in O(n) time for a list of length n.". Technically this statement is correct but when I read below > > "For a list with n elements, evaluation will stack up n (+ 1 ...) additions, and then finally add them up when the list is exhausted. > > You can avoid piling up additions by adding along the way. To accumulate a length this way, we need a function that takes both a list and the length of the list seen so far; the code below uses a local function iter that accumulates the length in an argument len". > > so just curious, shouldn't it be "Both the my-length and my-map functions run in O(n) space for a list of length n." ? > That's correct for straightforward versions of these functions. -- Matthias -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.a.prager at gmail.com Wed Sep 17 23:38:33 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Wed, 17 Sep 2014 22:38:33 -0500 Subject: [racket] on reversing a list by way of sort In-Reply-To: References: <541751DE.5050407@cs.umd.edu> <5417547D.3060309@cs.umd.edu> <5417991F.8020807@mbtype.com> <20140916035049.GS21882@localhost> <5417BF33.9070407@mbtype.com> Message-ID: I've done some testing of the built-in (random n) and I haven't been able to detect evidence of modulo bias. Of course absence of evidence isn't evidence of absence! More generally though, this is an interesting case (at least to me) of the trade-offs between efficiency, clarity, concision, cost of learning about a specialised area as well as arguments from theory vs empirical assessment. Dan On Wed, Sep 17, 2014 at 9:14 AM, Robby Findler wrote: > There was a bunch of work done to improve the random number generation > algorithms used internally a while back, but if you wanted to have a > look at them again, that would be most welcome. > > Here is a at least part of the code: > > https://github.com/plt/racket/blob/master/racket/src/racket/src/random.inc > > Robby > > On Wed, Sep 17, 2014 at 7:29 AM, Daniel Prager > wrote: > > Modulo bias is easy enough to correct by checking and occasional > > re-sampling. It's explained nicely in the following article: > > > http://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/ > > > > Let's *deliberately* generate some modulo bias in Racket by simulating a > low > > largest random number: > > > > (define (biased-random RAND-MAX n) > > (modulo (random (add1 RAND-MAX)) 3)) > > > > > > (define (check-bias method [n 10000]) > > (define sample (for/list ([i n]) (method 4 3))) > > > > (for ([i (in-range 3)]) > > (displayln > > (~a i " " (~a (real->decimal-string > > (* 100.0 (/ (count (? (j) (= i j)) sample) n)) > > 1) "%"))))) > > > >> (check-bias biased-random) > > 0 38.3% > > 1 41.0% > > 2 20.7% > > > > Remove the generated bias by rejecting some "high" values: > > > > > > (define (unbiased-random RAND-MAX n) > > (define excess (add1 (modulo RAND-MAX n))) > > (define limit (- RAND-MAX excess)) > > (define (in-limit m) > > (if (<= m limit) m (in-limit (random (add1 RAND-MAX))))) > > (modulo (in-limit (random (add1 RAND-MAX))) n)) > > > > > >> (check-bias unbiased-random) > > 0 33.9% > > 1 33.8% > > 2 32.4% > > > > Conclusion: We should be ok regarding modulo bias provided (random n) > uses a > > rejection strategy along these lines. If not, it's quite fixable. > > > > Dan > > > > On Wed, Sep 17, 2014 at 1:44 AM, Eli Barzilay wrote: > >> > >> On Wed, Sep 17, 2014 at 1:53 AM, Daniel Prager > >> wrote: > >> > > >> > [Sorry for drawing you further in.] > >> > >> :) (Indeed, my main point is that all that random-number stuff is > >> foreign to me...) > >> > >> > >> > My take on your 3 points: > >> > > >> > Fisher-Yates is only a few lines, so although not a one-liner, it > >> > seems reasonable to use it for the better space and time performance. > >> > >> (It's just time -- the space is the roughly same for both, since sorting > >> will create an intermediate vector too.) > >> > >> > I agree that an inside-out version is more apt. > >> > On my reading the final point is an issue if (random n) has problems > >> > like modulo bias, but if that's the case surely it is (random n) that > >> > needs fixing. > >> > >> It goes into all kinds of arguments that are exactly in that area that > >> I'm trying to avoid -- but IIUC, it's hard to avoid module-biases, and > >> the FY use of `random' is particularly nasty since it uses all modulos > >> in the range of the number of items. See also the point that the WP > >> page makes about the size of the random number generator state, and how > >> it limits the number of different permutations that can be generated. > >> It looks to me like Racket's state is made of 6 fixnums => 2^192 states, > >> which still doesn't cover all of the permutations of 52 cards. I have > >> no idea if this is correct, if some bias reduces the number of > >> permutations, or whether all of this is something to worry about... > >> > >> -- > >> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: > >> http://barzilay.org/ Maze is > Life! > > > > > > > > > > -- > > Daniel Prager > > Agile/Lean Coaching, Software Development and Leadership > > Startup: www.youpatch.com > > Twitter: @agilejitsu > > Blog: agile-jitsu.blogspot.com > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -- *Daniel Prager* Agile/Lean Coaching, Software Development and Leadership Startup: www.youpatch.com Twitter: @agilejitsu Blog: agile-jitsu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kalimehtar at mail.ru Thu Sep 18 01:19:40 2014 From: kalimehtar at mail.ru (=?UTF-8?B?Um9tYW4gS2xvY2hrb3Y=?=) Date: Thu, 18 Sep 2014 09:19:40 +0400 Subject: [racket] =?utf-8?q?Exception_decorator=2E_is_it_possible=3F?= In-Reply-To: <20140917181517.GA18713@happierface> References: <1410973155.471904896@f186.i.mail.ru> <20140917181517.GA18713@happierface> Message-ID: <1411017579.96049017@f396.i.mail.ru> Thank you. Yet one question^ is it possible to control, what will be in stacktrace. Because, I have (macro generated)? (class base object% ? ?(define/public (write stream) ? ? ? ?(write-value l1 stream field1) ? ? ? ?(write-value l1 stream field2) ? ? ? ?(write-value l1 stream field3) ? ? ? ?...)) Where l1 -- function, that takes its param and it to bytestream. (class derived base ? (define/override (write stream) ? ? ?(super write stream))) Then I have in stacktrace?(super write stream), and then instantly body of l1. But no string "(write-value l1 stream field2)" where I could see, what field caouse error. Is it possible to add it to stacktrace? Or how Racket decides, what expressions will be in stacktrace? Wed, 17 Sep 2014 14:15:17 -0400 ?? Marc Burns : >It's not generally possible to edit the message contained in an >exception. However, you can add information to the program's stack using >continuation marks. Here's an example: > >(define my-cont-mark-key (gensym)) > >(define (parse-item item) >??(with-continuation-mark my-cont-mark-key item >????...)) > >(with-handlers >??([exn? (lambda(e) >???????????((error-display-handler) >????????????(format "Parser exception at item ~a:\n~a" >????????????????????(first >??????????????????????(continuation-mark-set->list >????????????????????????(exn-continuation-marks e) >????????????????????????my-cont-mark-key)) >????????????????????(exn-message e)) >????????????e))]) >??(parse-item start-item)) > >The exception captures the continuation marks installed when it is >thrown. You can extract the information you added to the stack with >these marks in the exception handler. > >On Wed, Sep 17, 2014 at 08:59:15PM +0400, Roman Klochkov wrote: >> I'm writeing a parser. >> So I want to see in parser exception what happend and when (not only where). >> >> (define (parse-item item) >> ?? ??(with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message (format "At item ~a\n~a" item (exn-message e))])))]) >> ?? ?? ?? ?? ??....)) >> >> But this way I lose all exception types. Is there a way to change exception message, saving its type, except long copy/paste like >> (with-handlers ([exn:fail:contract:arity? (raise (struct-copy exn:fail:contract:arity ...))] >> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??[exn:fil:contract? (raise??(struct-copy exn:fail:contract ...))] >> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??...) >> ?? ??...) >> >> ? >> >> -- >> Roman Klochkov > >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > -- Roman Klochkov -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Thu Sep 18 08:18:15 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Thu, 18 Sep 2014 07:18:15 -0500 Subject: [racket] Text snip bleaches canvas space that does not belong to it In-Reply-To: <540DF2A3.5020707@ipa.nw.ru> References: <540DF2A3.5020707@ipa.nw.ru> Message-ID: <20140918121816.EAF12650194@mail-svr1.cs.utah.edu> The drawing model for editors is that an editor is allowed to draw directly to the canvas, without going through `on-paint`, and typically updating only a part of the canvas. To draw a background behind the editor content, the intent is that you use `on-paint` at the editor level (i.e., in `pasteboard%`). It's called both before and after the editor content is drawn. At Mon, 08 Sep 2014 22:17:07 +0400, Dmitry Pavlov wrote: > Hello, > > I need a text snip on a canvas that paints itself strictly in some defined WxH > bounds. > I need no interactive moving or resizing, only interactive editing. > Here is a code I have come up with, which also displays a window with the snip > and a grid. > The grid facilitates the visual check of the text snip bounds. > > (require racket/gui > racket/draw) > > (define my-pasteboard% > (class pasteboard% > (super-new) > (define/augment (can-select? snip on?) > #f) > (define/augment (can-interactive-move? snip) > #f) > (define/augment (can-interactive-resize? snip) > #f))) > > (define frame (new frame% (label "Test"))) > (define pasteboard (new my-pasteboard%)) > > (define my-canvas% > (class editor-canvas% > (super-new) > (define/override (on-paint) > (super on-paint) > (define dc (send this get-dc)) > ;; Draw a 10x10 grid with cell size 20x20 pixels > (for ((x (in-range 10))) (send dc draw-line (* x 20) 0 (* x 20) 200)) > (for ((y (in-range 10))) (send dc draw-line 0 (* y 20) 200 (* y 20))) > ))) > > (define editor-canvas > (new my-canvas% > (editor pasteboard) > (vertical-inset 0) (horizontal-inset 0) > (parent frame) > (style '(no-border no-hscroll no-vscroll)))) > > (send frame resize 200 200) > (send frame show #t) > > (define text-obj (new text%)) > (send text-obj insert "Hello" 0) > (define text-snip (new editor-snip% > (editor text-obj) > (left-margin 0) (right-margin 0) (top-margin 0) > (bottom-margin 0) > (left-inset 0) (right-inset 0) (top-inset 0) > (bottom-inset 0) > (with-border? #f) > (min-width 40) > (max-width 40) > (min-height 20) > (max-height 20))) > > (send pasteboard insert text-snip 40 60) > (send pasteboard set-caret-owner text-snip) > > > When I click on the snip in the window and try to add a "!" character after > the "Hello" text, I get this: > > http://imgur.com/cikwlqh > > It is obvious that the text snip (or something associated with it) > expanded its supposed area of rendering by 3-4 pixels in all directions. > And if I do silly things, like pressing "Enter", things get even worse. > Can that be avoided somehow? > > > Best regards, > > Dmitry > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dpavlov at ipa.nw.ru Thu Sep 18 11:22:40 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Thu, 18 Sep 2014 19:22:40 +0400 Subject: [racket] slider initial value is unexpectedly zero when min-value = max-value Message-ID: <541AF8C0.2040901@ipa.nw.ru> Hello, The title says it all, but here is also a code snip: (require racket/gui) (define frame (new frame% (label "test"))) (define slider (new slider% (label "") (parent frame) (min-value 1) (max-value 1))) (display (send slider get-value)) It prints "0", and this is a sign of violation of the invariant min-value <= init-value <= max-value. Passing (init-value 1) does not help. Best regards, Dmitry From dpavlov at ipa.nw.ru Thu Sep 18 11:25:13 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Thu, 18 Sep 2014 19:25:13 +0400 Subject: [racket] Spreadsheet editor In-Reply-To: References: <6bc0c4456cc37557ac97f5e8ea2bed2f@ipa.nw.ru> <7e6737e7c1eb72dc9801e548b44ab112@ipa.nw.ru> Message-ID: <541AF959.7050800@ipa.nw.ru> > It should have said, that I don't know of way to fix it. I just fixed it and committed to github. Matthew, thank you for the answer which you gave in the original thread! Regards, Dmitry From alexander at knauth.org Thu Sep 18 16:37:10 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Thu, 18 Sep 2014 16:37:10 -0400 Subject: [racket] filters and the type of partition Message-ID: Is there any way for a predicate-ish thing to do something like this: #lang typed/racket (: vectorof-real? : [(U Number (Vectorof Real)) -> Boolean : #:+ (Vectorof Real) #:- Number]) (define (vectorof-real? x) (vector? x)) Because this works: (let ([x : (U Number (Vectorof Real)) #(1 2 3)]) (if (vector? x) (ann x (Vectorof Real)) (ann x Number))) And also I noticed the types for the functions filter and partition are: > filter - : (All (a b) (case-> (-> (-> a Any : #:+ b) (Listof a) (Listof b)) (-> (-> a Any) (Listof a) (Listof a)))) # > partition - : (All (a b) (case-> (-> (-> a Any) (Listof a) (values (Listof a) (Listof a))) (-> (-> Any Boolean : a) (Listof b) (values (Listof a) (Listof b))))) # For the filter function, the predicate only has to accept the type a for both cases and can return Any for both cases. Is there any reason why the second case of partition doesn?t do that? And is there a reason why it doesn?t use #:+ for the filter? The current type for partition wouldn?t allow me to use my vectorof-real? as the predicate even if it did work, right? But filter would? From ameliastahlman at gmail.com Wed Sep 10 14:40:03 2014 From: ameliastahlman at gmail.com (Amy Stahlman) Date: Wed, 10 Sep 2014 13:40:03 -0500 Subject: [racket] (no subject) Message-ID: I've been working on a program that uses "init-auto-scrollbars" and I noticed that when the window is resized it actually changes the size of the virtual canvas along with the literal canvas instead of just resizing the scrollbar and changing the size of the literal canvas. Here's an example that shows this: *(require racket/gui)(define frame (new frame% [label "Example"] [width 300] [height 300]))(define canv (new canvas% [parent frame] [style '(vscroll hscroll)] [paint-callback (lambda (canvas dc)(send dc draw-ellipse 0 0 500 500))]))(send frame show #t)(send canv init-auto-scrollbars 500 500 0.0 0.0)* Resize the window, making it large enough to show the entire ellipse; notice how the scrollbar's relative size doesn't change, and there is blank space at the bottom. Is this by design or some kind of bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: From samth at cs.indiana.edu Fri Sep 19 10:40:05 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Fri, 19 Sep 2014 10:40:05 -0400 Subject: [racket] filters and the type of partition In-Reply-To: References: Message-ID: I think your first function ought to type check, and that it doesn't is a bug. Second, `partition` could be relaxed in the way you say, and could use #:+ as well. Sam On Thu, Sep 18, 2014 at 4:37 PM, Alexander D. Knauth wrote: > Is there any way for a predicate-ish thing to do something like this: > #lang typed/racket > (: vectorof-real? : [(U Number (Vectorof Real)) > -> Boolean : > #:+ (Vectorof Real) > #:- Number]) > (define (vectorof-real? x) > (vector? x)) > > Because this works: > (let ([x : (U Number (Vectorof Real)) #(1 2 3)]) > (if (vector? x) > (ann x (Vectorof Real)) > (ann x Number))) > > And also I noticed the types for the functions filter and partition are: > > filter > - : (All (a b) > (case-> > (-> (-> a Any : #:+ b) (Listof a) (Listof b)) > (-> (-> a Any) (Listof a) (Listof a)))) > # > > partition > - : (All (a b) > (case-> > (-> (-> a Any) (Listof a) (values (Listof a) (Listof a))) > (-> (-> Any Boolean : a) (Listof b) (values (Listof a) (Listof b))))) > # > > For the filter function, the predicate only has to accept the type a for both cases and can return Any for both cases. Is there any reason why the second case of partition doesn?t do that? And is there a reason why it doesn?t use #:+ for the filter? > > The current type for partition wouldn?t allow me to use my vectorof-real? as the predicate even if it did work, right? But filter would? > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From dpavlov at ipa.nw.ru Fri Sep 19 12:01:26 2014 From: dpavlov at ipa.nw.ru (Dmitry Pavlov) Date: Fri, 19 Sep 2014 20:01:26 +0400 Subject: [racket] Extending DrRacket with non-text tabs Message-ID: <541C5356.90502@ipa.nw.ru> Hello, I recently wrote a spreadsheet editor in Racket [1]. Now I am considering a crazy idea to use it within DrRacket natively, not as a separate app. The most fantastic scenario would be me running the spreadsheet editor(s) in DrRacket tab(s), started by opening files with a certain extension via DrRacket's "Open" dialog. Is that possible? If yes, is it [2] where I should be looking? Do any manuals or examples exist for that? Because I hardly understand where to start when it comes to extending DrRacket. If the most fantastic scenario is not possible (I do not really know), maybe I can open my spreadsheet editor(s) in separate windows by pressing a custom button on the DrRacket's tool panel, or choosing a custom menu item? What would you, experienced Racketeers, do if you were in my place? Thanks. [1] https://github.com/kugelblitz/spreadsheet-editor [2] http://docs.racket-lang.org/tools/drracket_get_extend.html Regards, Dmitry From jackhfirth at gmail.com Fri Sep 19 17:41:31 2014 From: jackhfirth at gmail.com (Jack Firth) Date: Fri, 19 Sep 2014 14:41:31 -0700 Subject: [racket] Provide transformers Message-ID: I've been looking into how to design a macro that would specify tests in a provide transformer, for example something like (provide (test-pred-out some-integer integer?)) I'd like that to expand to: (provide some-integer) (module+ test (check-pred integer? some-integer)) >From what I can gather from the reference, normally provide forms are done with define-provide-syntax, but that macro doesn't let me splice anything into the module body. The reference mentions provide pre-transformers, and says: "A provide pre-transformer is applied as part of the first phase of a module?s expansion. Since it is used in the first phase, a provide pre-transformer can use functions such as syntax-local-lift-expression to introduce expressions and definitions in the enclosing module." So it sounds like what I want is definitely possible, but I have no idea how to actually *do* it. Does anyone have some simple well-explained examples to guide me in the right direction? -------------- next part -------------- An HTML attachment was scrubbed... URL: From asumu at ccs.neu.edu Sat Sep 20 00:51:11 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Sat, 20 Sep 2014 00:51:11 -0400 Subject: [racket] RacketCon live video Message-ID: <20140920045111.GI21882@localhost> Hi all, We are planning to air a RacketCon live stream again this year via Google Hangouts. Barring any technical difficulties, we'll have the stream up tomorrow at this link: https://plus.google.com/events/co9ghndpkko2q2p9jcd17a0fr1g The program is here: http://con.racket-lang.org/ Last year there was a cap on stream length, so we may have to switch to a new stream partway through. We'll send out a new link if we have to do that. Cheers, Asumu From leif at leifandersen.net Sat Sep 20 10:31:29 2014 From: leif at leifandersen.net (Leif Andersen) Date: Sat, 20 Sep 2014 09:31:29 -0500 Subject: [racket] RacketCon live video In-Reply-To: <20140920045111.GI21882@localhost> References: <20140920045111.GI21882@localhost> Message-ID: Hello all, The feed has started. Again, the feed is here: https://plus.google.com/events/co9ghndpkko2q2p9jcd17a0fr1g And the program is here: http://con.racket-lang.org/ ~Leif Andersen On Fri, Sep 19, 2014 at 11:51 PM, Asumu Takikawa wrote: > Hi all, > > We are planning to air a RacketCon live stream again this year via > Google Hangouts. Barring any technical difficulties, we'll have the > stream up tomorrow at this link: > > https://plus.google.com/events/co9ghndpkko2q2p9jcd17a0fr1g > > The program is here: > > http://con.racket-lang.org/ > > Last year there was a cap on stream length, so we may have to switch to > a new stream partway through. We'll send out a new link if we have to do > that. > > Cheers, > Asumu > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From asumu at ccs.neu.edu Sat Sep 20 13:25:55 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Sat, 20 Sep 2014 13:25:55 -0400 Subject: [racket] RacketCon live video In-Reply-To: <20140920045111.GI21882@localhost> References: <20140920045111.GI21882@localhost> Message-ID: <20140920172555.GK21882@localhost> On 2014-09-20 00:51:11 -0400, Asumu Takikawa wrote: > Last year there was a cap on stream length, so we may have to switch to > a new stream partway through. We'll send out a new link if we have to do > that. We'll be putting up Part 2 of the stream here: https://plus.google.com/events/crsu3iegmu73htksd9l6l8pfek8 We restart after the lunch break at 1:40PM Central Time. Cheers, Asumu From asumu at ccs.neu.edu Sat Sep 20 14:33:00 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Sat, 20 Sep 2014 14:33:00 -0400 Subject: [racket] RacketCon live video In-Reply-To: <20140920172555.GK21882@localhost> References: <20140920045111.GI21882@localhost> <20140920172555.GK21882@localhost> Message-ID: <20140920183300.GL21882@localhost> On 2014-09-20 13:25:55 -0400, Asumu Takikawa wrote: > We'll be putting up Part 2 of the stream here: > > https://plus.google.com/events/crsu3iegmu73htksd9l6l8pfek8 The stream is live again at the new link. The talks will resume in ~10 minutes at 1:40PM Central. Cheers, Asumu From daniel.a.prager at gmail.com Sun Sep 21 00:52:15 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Sat, 20 Sep 2014 23:52:15 -0500 Subject: [racket] Rendering the PLT symbol in Racket? Message-ID: There was interest following my talk at RacketCon in a www.youpatch.com quilt pattern featuring the PLT symbol (file:///Users/dan/Documents/plt.svg). I was having a play with youpatch.com by standard means, to put together a commemorative pattern, but I think I can do a cleaner job given access to Racket code that generates the image. Can anyone point me to, or send me the code? Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: From lysseus at gmail.com Sun Sep 21 01:47:21 2014 From: lysseus at gmail.com (Kevin Forchione) Date: Sat, 20 Sep 2014 22:47:21 -0700 Subject: [racket] ->i contract question Message-ID: <7D717570-D4F1-4F93-A6D8-70A981189839@gmail.com> Hi guys, Is there a syntax for dependent-range that would allow 0 or more values to be specified? The documentation appears to describe only a specified number of values. Is there an analogue to list of and non-empty-listof? -Kevin From spencerflorence at gmail.com Sun Sep 21 12:21:44 2014 From: spencerflorence at gmail.com (Spencer florence) Date: Sun, 21 Sep 2014 09:21:44 -0700 (PDT) Subject: [racket] Provide transformers In-Reply-To: References: Message-ID: <1411316503678.d5b8e301@Nodemailer> I think the way i have seen this done is to use a macro at the top level instead of a provide transformer. for example define/provide-test-suite from rackunit probably works a little like (define/provide-test-suite tests blah blah ?) => (begin? ? ?(provide tests) ? ?(define tests (test-suite blah blah blah ?)) So maybe you could make a provide/test-pred form? On Fri, Sep 19, 2014 at 4:42 PM, Jack Firth wrote: > I've been looking into how to design a macro that would specify tests in a > provide transformer, for example something like > (provide (test-pred-out some-integer integer?)) > I'd like that to expand to: > (provide some-integer) > (module+ test > (check-pred integer? some-integer)) > From what I can gather from the reference, normally provide forms are done > with define-provide-syntax, but that macro doesn't let me splice anything > into the module body. The reference mentions provide pre-transformers, and > says: > "A provide pre-transformer is applied as part of the first phase of a > module?s expansion. Since it is used in the first phase, a provide > pre-transformer can use functions such as syntax-local-lift-expression to > introduce expressions and definitions in the enclosing module." > So it sounds like what I want is definitely possible, but I have no idea > how to actually *do* it. Does anyone have some simple well-explained > examples to guide me in the right direction? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarcane at gmail.com Sun Sep 21 17:12:37 2014 From: jarcane at gmail.com (J Arcane) Date: Mon, 22 Sep 2014 00:12:37 +0300 Subject: [racket] Hosting the try-racket REPL. Message-ID: Greetings, For some time now, it's bothered me a bit that Racket doesn't have an online REPL currently hosted anywhere. There's one written here: https://github.com/voila/try-racket But no one's hosted it anywhere. So I took it upon myself to fix that. I've purchased try-racket.org and a basic DigitalOcean droplet to host it on, but I've hit a snag: I can't get it to run. It runs more or less without trouble on my personal FreeBSD box, but on my Debian 7 droplet I waded through countless dependency issues until finally I reached what seems to be this same error: http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 Presuming that perhaps this was in someway trying to run Racket in an actual GUI window whether I wanted it to or not, I attempted to run it as --script, but this just quits silently instead, leaving no servlet behind either. Any ideas what I might be doing wrong? or have I hit a proper bug? (IME it's usually the former ... ) John Berry http://jarcane.github.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Sun Sep 21 19:31:01 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 21 Sep 2014 19:31:01 -0400 Subject: [racket] define-type #:omit-define-syntaxes across different modules Message-ID: <2F4CD703-EEB1-4BE4-9CE3-62D87615D462@knauth.org> An HTML attachment was scrubbed... URL: From m4burns at csclub.uwaterloo.ca Sun Sep 21 19:00:02 2014 From: m4burns at csclub.uwaterloo.ca (Marc Burns) Date: Sun, 21 Sep 2014 19:00:02 -0400 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: Message-ID: <20140921230002.GD29774@happierface> The culprit is the slideshow/code module loaded into the sandbox evaluator. Requiring slideshow/code attempts to establish an X server connection. On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: > Greetings, > > For some time now, it's bothered me a bit that Racket doesn't have an > online REPL currently hosted anywhere. There's one written here: > https://github.com/voila/try-racket > > But no one's hosted it anywhere. So I took it upon myself to fix that. I've > purchased try-racket.org and a basic DigitalOcean droplet to host it on, > but I've hit a snag: I can't get it to run. > > It runs more or less without trouble on my personal FreeBSD box, but on my > Debian 7 droplet I waded through countless dependency issues until finally > I reached what seems to be this same error: > > http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 > > Presuming that perhaps this was in someway trying to run Racket in an > actual GUI window whether I wanted it to or not, I attempted to run it as > --script, but this just quits silently instead, leaving no servlet behind > either. > > Any ideas what I might be doing wrong? or have I hit a proper bug? (IME > it's usually the former ... ) > > John Berry > http://jarcane.github.com > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From alexander at knauth.org Sun Sep 21 19:59:01 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 21 Sep 2014 19:59:01 -0400 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: References: Message-ID: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> I tried it with the images in the email, but it was too big, so here it is just links. I think there was something on the list about this before, and I found these again from that: http://docs.racket-lang.org/images/Logos.html?q=plt-logo#%28def._%28%28lib._images%2Flogos..rkt%29._plt-logo%29%29 (require images/logos) (plt-logo) and also http://docs.racket-lang.org/draw/overview.html?q=racket%2Fdraw#%28part._.Drawing_.Paths%29 (down a little bit) On Sep 21, 2014, at 12:52 AM, Daniel Prager wrote: > There was interest following my talk at RacketCon in a www.youpatch.com quilt pattern featuring the PLT symbol (file:///Users/dan/Documents/plt.svg). > > I was having a play with youpatch.com by standard means, to put together a commemorative pattern, but I think I can do a cleaner job given access to Racket code that generates the image. > > Can anyone point me to, or send me the code? > > > Dan > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Sun Sep 21 21:02:10 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Sun, 21 Sep 2014 20:02:10 -0500 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: <20140921230002.GD29774@happierface> References: <20140921230002.GD29774@happierface> Message-ID: Maybe you can use slideshow/code-pict instead? Robby On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns wrote: > The culprit is the slideshow/code module loaded into the sandbox > evaluator. Requiring slideshow/code attempts to establish an X server > connection. > > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: >> Greetings, >> >> For some time now, it's bothered me a bit that Racket doesn't have an >> online REPL currently hosted anywhere. There's one written here: >> https://github.com/voila/try-racket >> >> But no one's hosted it anywhere. So I took it upon myself to fix that. I've >> purchased try-racket.org and a basic DigitalOcean droplet to host it on, >> but I've hit a snag: I can't get it to run. >> >> It runs more or less without trouble on my personal FreeBSD box, but on my >> Debian 7 droplet I waded through countless dependency issues until finally >> I reached what seems to be this same error: >> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 >> >> Presuming that perhaps this was in someway trying to run Racket in an >> actual GUI window whether I wanted it to or not, I attempted to run it as >> --script, but this just quits silently instead, leaving no servlet behind >> either. >> >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME >> it's usually the former ... ) >> >> John Berry >> http://jarcane.github.com > >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From daniel.a.prager at gmail.com Sun Sep 21 21:09:23 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Sun, 21 Sep 2014 18:09:23 -0700 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: References: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> Message-ID: Thanks Alexander & John On further examination I'm not sure that direct-drawing particularly helps me, but I appreciate the references (and the history). I'll make sure that there's a nice effect for the design: just bear with me, I'm not quite satisfied with what can be currently be achieved. Dan On Sun, Sep 21, 2014 at 5:52 PM, John Clements wrote: > There are a whole bunch of ways of answering this question; you might want > Neil?s fantastic ray-traced version, or just the simple paths. In case it?s > helpful, here?s the original postscript file generated by Shriram, Robby, > and Matthew. Oh, wait, here?s the comment from the file: > > %%Title: PLT Lambda > %%Creator: Matthew, then Shriram, finally Robby > %%CreationDate: June 24, 1997 > %%For: PLT > > (NB: Apple Mail tries to render this as an image, pretty badly. Save the > attachment to read it.) > > > > On Sep 21, 2014, at 4:59 PM, Alexander D. Knauth > wrote: > > > I tried it with the images in the email, but it was too big, so here it > is just links. > > I think there was something on the list about this before, and I found > these again from that: > > > http://docs.racket-lang.org/images/Logos.html?q=plt-logo#%28def._%28%28lib._images%2Flogos..rkt%29._plt-logo%29%29 > > (require images/logos) > > (plt-logo) > > and also > > > http://docs.racket-lang.org/draw/overview.html?q=racket%2Fdraw#%28part._.Drawing_.Paths%29 > (down a little bit) > > > > > > On Sep 21, 2014, at 12:52 AM, Daniel Prager > wrote: > > > >> There was interest following my talk at RacketCon in a www.youpatch.com > quilt pattern featuring the PLT symbol > (file:///Users/dan/Documents/plt.svg). > >> > >> I was having a play with youpatch.com by standard means, to put > together a commemorative pattern, but I think I can do a cleaner job given > access to Racket code that generates the image. > >> > >> Can anyone point me to, or send me the code? > >> > >> > >> Dan > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -- *Daniel Prager* Agile/Lean Coaching, Software Development and Leadership Startup: www.youpatch.com Twitter: @agilejitsu Blog: agile-jitsu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Sun Sep 21 21:13:50 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Sun, 21 Sep 2014 20:13:50 -0500 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: References: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> Message-ID: There is some racket code, but it just duplicates the ps code, drawing directly into a dc. (This can be lifted into a pict, via 'dc'.) If that would be helpful, I can supply it. Robby On Sun, Sep 21, 2014 at 8:09 PM, Daniel Prager wrote: > Thanks Alexander & John > > On further examination I'm not sure that direct-drawing particularly helps > me, but I appreciate the references (and the history). > > I'll make sure that there's a nice effect for the design: just bear with me, > I'm not quite satisfied with what can be currently be achieved. > > Dan > > On Sun, Sep 21, 2014 at 5:52 PM, John Clements > wrote: >> >> There are a whole bunch of ways of answering this question; you might want >> Neil?s fantastic ray-traced version, or just the simple paths. In case it?s >> helpful, here?s the original postscript file generated by Shriram, Robby, >> and Matthew. Oh, wait, here?s the comment from the file: >> >> %%Title: PLT Lambda >> %%Creator: Matthew, then Shriram, finally Robby >> %%CreationDate: June 24, 1997 >> %%For: PLT >> >> (NB: Apple Mail tries to render this as an image, pretty badly. Save the >> attachment to read it.) >> >> >> >> >> On Sep 21, 2014, at 4:59 PM, Alexander D. Knauth >> wrote: >> >> > I tried it with the images in the email, but it was too big, so here it >> > is just links. >> > I think there was something on the list about this before, and I found >> > these again from that: >> > >> > http://docs.racket-lang.org/images/Logos.html?q=plt-logo#%28def._%28%28lib._images%2Flogos..rkt%29._plt-logo%29%29 >> > (require images/logos) >> > (plt-logo) >> > and also >> > >> > http://docs.racket-lang.org/draw/overview.html?q=racket%2Fdraw#%28part._.Drawing_.Paths%29 >> > (down a little bit) >> > >> > >> > On Sep 21, 2014, at 12:52 AM, Daniel Prager >> > wrote: >> > >> >> There was interest following my talk at RacketCon in a www.youpatch.com >> >> quilt pattern featuring the PLT symbol >> >> (file:///Users/dan/Documents/plt.svg). >> >> >> >> I was having a play with youpatch.com by standard means, to put >> >> together a commemorative pattern, but I think I can do a cleaner job given >> >> access to Racket code that generates the image. >> >> >> >> Can anyone point me to, or send me the code? >> >> >> >> >> >> Dan >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> >> > > > > -- > Daniel Prager > Agile/Lean Coaching, Software Development and Leadership > Startup: www.youpatch.com > Twitter: @agilejitsu > Blog: agile-jitsu.blogspot.com > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From daniel.a.prager at gmail.com Sun Sep 21 21:30:00 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Sun, 21 Sep 2014 18:30:00 -0700 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: References: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> Message-ID: Thanks Robby That may be useful. FYI: I'm biting the bullet and trying to introduce a "good" triangular rendering to reduce the jaggedness of curves (which are common in images like the simple PLT logo) and while I've almost got something that almost works from a sampled image, I'm not there yet. Dan On Sun, Sep 21, 2014 at 6:13 PM, Robby Findler wrote: > There is some racket code, but it just duplicates the ps code, drawing > directly into a dc. (This can be lifted into a pict, via 'dc'.) If > that would be helpful, I can supply it. > > Robby > > > On Sun, Sep 21, 2014 at 8:09 PM, Daniel Prager > wrote: > > Thanks Alexander & John > > > > On further examination I'm not sure that direct-drawing particularly > helps > > me, but I appreciate the references (and the history). > > > > I'll make sure that there's a nice effect for the design: just bear with > me, > > I'm not quite satisfied with what can be currently be achieved. > > > > Dan > > > > On Sun, Sep 21, 2014 at 5:52 PM, John Clements < > clements at brinckerhoff.org> > > wrote: > >> > >> There are a whole bunch of ways of answering this question; you might > want > >> Neil?s fantastic ray-traced version, or just the simple paths. In case > it?s > >> helpful, here?s the original postscript file generated by Shriram, > Robby, > >> and Matthew. Oh, wait, here?s the comment from the file: > >> > >> %%Title: PLT Lambda > >> %%Creator: Matthew, then Shriram, finally Robby > >> %%CreationDate: June 24, 1997 > >> %%For: PLT > >> > >> (NB: Apple Mail tries to render this as an image, pretty badly. Save the > >> attachment to read it.) > >> > >> > >> > >> > >> On Sep 21, 2014, at 4:59 PM, Alexander D. Knauth > >> wrote: > >> > >> > I tried it with the images in the email, but it was too big, so here > it > >> > is just links. > >> > I think there was something on the list about this before, and I found > >> > these again from that: > >> > > >> > > http://docs.racket-lang.org/images/Logos.html?q=plt-logo#%28def._%28%28lib._images%2Flogos..rkt%29._plt-logo%29%29 > >> > (require images/logos) > >> > (plt-logo) > >> > and also > >> > > >> > > http://docs.racket-lang.org/draw/overview.html?q=racket%2Fdraw#%28part._.Drawing_.Paths%29 > >> > (down a little bit) > >> > > >> > > >> > On Sep 21, 2014, at 12:52 AM, Daniel Prager < > daniel.a.prager at gmail.com> > >> > wrote: > >> > > >> >> There was interest following my talk at RacketCon in a > www.youpatch.com > >> >> quilt pattern featuring the PLT symbol > >> >> (file:///Users/dan/Documents/plt.svg). > >> >> > >> >> I was having a play with youpatch.com by standard means, to put > >> >> together a commemorative pattern, but I think I can do a cleaner job > given > >> >> access to Racket code that generates the image. > >> >> > >> >> Can anyone point me to, or send me the code? > >> >> > >> >> > >> >> Dan > >> >> ____________________ > >> >> Racket Users list: > >> >> http://lists.racket-lang.org/users > >> > ____________________ > >> > Racket Users list: > >> > http://lists.racket-lang.org/users > >> > >> > > > > > > > > -- > > Daniel Prager > > Agile/Lean Coaching, Software Development and Leadership > > Startup: www.youpatch.com > > Twitter: @agilejitsu > > Blog: agile-jitsu.blogspot.com > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -- *Daniel Prager* Agile/Lean Coaching, Software Development and Leadership Startup: www.youpatch.com Twitter: @agilejitsu Blog: agile-jitsu.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarcane at gmail.com Mon Sep 22 01:17:35 2014 From: jarcane at gmail.com (J Arcane) Date: Mon, 22 Sep 2014 08:17:35 +0300 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> Message-ID: Hmm. Alright, replacing the calls to slideshow with calls directly to pict, as well as commenting out the racket/gui/base calls successfully gets the code to run without X. However, something about how it converts the picts for web isn't working, so instead of a neat little circle, for instance, I get "(pict '(prog # wrote: > Maybe you can use slideshow/code-pict instead? > > Robby > > On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns > wrote: > > The culprit is the slideshow/code module loaded into the sandbox > > evaluator. Requiring slideshow/code attempts to establish an X server > > connection. > > > > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: > >> Greetings, > >> > >> For some time now, it's bothered me a bit that Racket doesn't have an > >> online REPL currently hosted anywhere. There's one written here: > >> https://github.com/voila/try-racket > >> > >> But no one's hosted it anywhere. So I took it upon myself to fix that. > I've > >> purchased try-racket.org and a basic DigitalOcean droplet to host it > on, > >> but I've hit a snag: I can't get it to run. > >> > >> It runs more or less without trouble on my personal FreeBSD box, but on > my > >> Debian 7 droplet I waded through countless dependency issues until > finally > >> I reached what seems to be this same error: > >> > >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 > >> > >> Presuming that perhaps this was in someway trying to run Racket in an > >> actual GUI window whether I wanted it to or not, I attempted to run it > as > >> --script, but this just quits silently instead, leaving no servlet > behind > >> either. > >> > >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME > >> it's usually the former ... ) > >> > >> John Berry > >> http://jarcane.github.com > > > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fractallyte at csi.com Mon Sep 22 02:28:28 2014 From: fractallyte at csi.com (Amir Ansari) Date: Mon, 22 Sep 2014 07:28:28 +0100 Subject: [racket] Hosting the try-racket REPL. Message-ID: <20140922072828.01b2011be8962eda327b3dfa@csi.com> Have you tried Xvfb (http://en.wikipedia.org/wiki/Xvfb), a virtual X server? It runs headlessly, sidesteps the whole issue of having to fork the code... Amir From daniel.a.prager at gmail.com Mon Sep 22 02:29:21 2014 From: daniel.a.prager at gmail.com (Daniel Prager) Date: Sun, 21 Sep 2014 23:29:21 -0700 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: References: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> Message-ID: This is what's achievable based on the simpler design with www.youpatch.com right now (shown at medium resolution). As you can see, this kind of image leads to heaps of "stair-casing". I think it would be much nicer to smooth out the jaggies. I'm experimenting with adding a facility to do this with some post-processing. This leads to the following effect: It will take me a little while to incorporate this into the PDF instructional output (I'll estimate order of weeks, depending on my other activities) . So, what do *you* think of the difference in aesthetic quality? For those who are keen to have their very own PLT quilt, is this improvement worth the additional wait? Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PLT-Logo-Triangles.png Type: image/png Size: 10493 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: plt-logo-squares.png Type: image/png Size: 2692 bytes Desc: not available URL: From neil at neilvandyke.org Mon Sep 22 02:52:30 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Mon, 22 Sep 2014 02:52:30 -0400 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: <20140922072828.01b2011be8962eda327b3dfa@csi.com> References: <20140922072828.01b2011be8962eda327b3dfa@csi.com> Message-ID: <541FC72E.2090207@neilvandyke.org> Amir Ansari wrote at 09/22/2014 02:28 AM: > Have you tried Xvfb (http://en.wikipedia.org/wiki/Xvfb), a virtual X server? It runs headlessly, sidesteps the whole issue of having to fork the code... > I have no idea whether "xvfb" is the best way without looking closely at a particular case, but I've seen "xvfb" work in the past on production servers. (Not for Racket, but for some R statistics tool that touched the X server, so that the tool could be used off-the-shelf, rather than maintaining a modified fork of the tool source.) If you do this, just be write your startup and shutdown scripts to be resilient and stable (e.g., wrt available ports/sockets at the time, and to shut down cleanly, and so there are no race conditions or conflicts between multiple simultaneous users), and secure (e.g., ensure that it won't accidentally listen on a public network interface, and that an attacker can't synthesize operations to the xvfb to escalate privileges or DoS, and that the xvfb can't be used to leak data between users). Neil V. From jarcane at gmail.com Mon Sep 22 02:54:52 2014 From: jarcane at gmail.com (J Arcane) Date: Mon, 22 Sep 2014 09:54:52 +0300 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: <20140922072828.01b2011be8962eda327b3dfa@csi.com> References: <20140922072828.01b2011be8962eda327b3dfa@csi.com> Message-ID: I had not actually heard of Xvfb before now, but that could be a good solution. I balk at using full X11 with only 512MB of RAM, but that could be enough to satisfy the original code's expectations. I will have to experiment with it. On Mon, Sep 22, 2014 at 9:28 AM, Amir Ansari wrote: > Have you tried Xvfb (http://en.wikipedia.org/wiki/Xvfb), a virtual X > server? It runs headlessly, sidesteps the whole issue of having to fork the > code... > > Amir > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarcane at gmail.com Mon Sep 22 03:11:25 2014 From: jarcane at gmail.com (J Arcane) Date: Mon, 22 Sep 2014 10:11:25 +0300 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: <541FC72E.2090207@neilvandyke.org> References: <20140922072828.01b2011be8962eda327b3dfa@csi.com> <541FC72E.2090207@neilvandyke.org> Message-ID: That does sound an awful headache for something that otherwise doesn't seem to be using X for anything other than dependency expectations. It seems like there should be a non-X-dependent way to do it. On Mon, Sep 22, 2014 at 9:52 AM, Neil Van Dyke wrote: > Amir Ansari wrote at 09/22/2014 02:28 AM: > >> Have you tried Xvfb (http://en.wikipedia.org/wiki/Xvfb), a virtual X >> server? It runs headlessly, sidesteps the whole issue of having to fork the >> code... >> >> > I have no idea whether "xvfb" is the best way without looking closely at a > particular case, but I've seen "xvfb" work in the past on production > servers. (Not for Racket, but for some R statistics tool that touched the > X server, so that the tool could be used off-the-shelf, rather than > maintaining a modified fork of the tool source.) > > If you do this, just be write your startup and shutdown scripts to be > resilient and stable (e.g., wrt available ports/sockets at the time, and to > shut down cleanly, and so there are no race conditions or conflicts between > multiple simultaneous users), and secure (e.g., ensure that it won't > accidentally listen on a public network interface, and that an attacker > can't synthesize operations to the xvfb to escalate privileges or DoS, and > that the xvfb can't be used to leak data between users). > > Neil V. > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fractallyte at csi.com Mon Sep 22 05:06:38 2014 From: fractallyte at csi.com (Amir Ansari) Date: Mon, 22 Sep 2014 10:06:38 +0100 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140922072828.01b2011be8962eda327b3dfa@csi.com> <541FC72E.2090207@neilvandyke.org> Message-ID: <20140922100638.8456bcb8d777504e45ae738f@csi.com> If you run it inside a BSD jail, that should take care of a lot of the possible issues... But you're right, of course. It should be able to run without X. On Mon, 22 Sep 2014 10:11:25 +0300 J Arcane wrote: > That does sound an awful headache for something that otherwise doesn't seem > to be using X for anything other than dependency expectations. It seems > like there should be a non-X-dependent way to do it. From neil at neilvandyke.org Mon Sep 22 05:09:27 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Mon, 22 Sep 2014 05:09:27 -0400 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140922072828.01b2011be8962eda327b3dfa@csi.com> Message-ID: <541FE747.7070403@neilvandyke.org> J Arcane wrote at 09/22/2014 02:54 AM: > I had not actually heard of Xvfb before now, but that could be a good > solution. I balk at using full X11 with only 512MB of RAM, but that > could be enough to satisfy the original code's expectations. I will > have to experiment with it. Side comment: I wouldn't worry too much about the memory requirements of an X11 server daemon (we used to run X11 and everything else on 16MB engineering workstations fine, and universities would sometimes run X on 4MB workstations with megapixel displays, even without local swap.) The X11 daemon on my computer right here is using only 3MB virtual memory total, and I have some server-intensive apps like Firefox running against it, on two heads. (It's mostly only the modern ``desktop environments'' that tend to be bloatware (e.g. even a decade ago with those, the little clock panel applet was reporting as 50MB RSS), but a plain X11 server daemon itself can be pretty small. A lot of the early development of the desktop environments you're using now was by smart-but-inexperienced 20yos who were tossed into the deep end, under 20yo managers who were trying to start a company. With some noteworthy exceptions. Since then, the desktop environments seem to have been evolved by often more-experienced people, and improved, but the desktop environments weren't built with the great architectures and practices from the start, which tends to be a technical and cultural burden for a very long time. And developers have usually been targeting contemporary PC desktop hardware, when several gigabytes of RAM can be assumed, except for occasional forays into devices that are battery-powered and/or are intended to be ultra-cheap to manufacture.) Neil V. From alexander at knauth.org Mon Sep 22 06:57:44 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Mon, 22 Sep 2014 06:57:44 -0400 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> Message-ID: <1F89AEEA-021A-44E8-A5BE-F7257E11AC93@knauth.org> On Sep 22, 2014, at 1:17 AM, J Arcane wrote: > > I've set up a fork here: https://github.com/jarcane/try-racket > I'm still working on getting the DNS set properly though, so no try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ but I haven't figured out how to get try-racket.org to go there yet. Can you get it to give a newline if the parens don?t match yet, so for example: > (for/list ([i (in-range 4)]) eval:1:0: read: expected a `)' to close `(' context...: /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:113:0: default-sandbox-reader /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:536:0: input->code /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:856:14 /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:379:0: call-with-limits /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:475:0: call-with-custodian-shutdown /usr/share/racket/collects/racket/private/more-scheme.rkt:147:2: call-with-break-parameterization /usr/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:837:5: loop > > > > wrote: > Maybe you can use slideshow/code-pict instead? > > Robby > > On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns wrote: > > The culprit is the slideshow/code module loaded into the sandbox > > evaluator. Requiring slideshow/code attempts to establish an X server > > connection. > > > > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: > >> Greetings, > >> > >> For some time now, it's bothered me a bit that Racket doesn't have an > >> online REPL currently hosted anywhere. There's one written here: > >> https://github.com/voila/try-racket > >> > >> But no one's hosted it anywhere. So I took it upon myself to fix that. I've > >> purchased try-racket.org and a basic DigitalOcean droplet to host it on, > >> but I've hit a snag: I can't get it to run. > >> > >> It runs more or less without trouble on my personal FreeBSD box, but on my > >> Debian 7 droplet I waded through countless dependency issues until finally > >> I reached what seems to be this same error: > >> > >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 > >> > >> Presuming that perhaps this was in someway trying to run Racket in an > >> actual GUI window whether I wanted it to or not, I attempted to run it as > >> --script, but this just quits silently instead, leaving no servlet behind > >> either. > >> > >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME > >> it's usually the former ... ) > >> > >> John Berry > >> http://jarcane.github.com > > > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Mon Sep 22 08:30:56 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 22 Sep 2014 07:30:56 -0500 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> Message-ID: Pict should be making them just the same and they should convert fine even if the GUI libraries aren't yet required. For example: Welcome to Racket v6.1.0.8. > (require file/convertible pict) > (convertible? (disk 1)) #t > (convert (disk 1) 'png-bytes) #"\211PNG\r\n\32\n\0\0\0\rIHDR\0\0\0\1\0\0\0\1\b\6\0\0\0\37\25\304\211\0\0\0\rIDAT\b\231c```8\2\0\0\311\0\305\336\357!\202\0\0\0\0IEND\256B`\202" But, that said, it may be easiest to get X going, because people who submit programs can easily run into this problem too. Robby On Mon, Sep 22, 2014 at 12:17 AM, J Arcane wrote: > Hmm. > > Alright, replacing the calls to slideshow with calls directly to pict, as > well as commenting out the racket/gui/base calls successfully gets the code > to run without X. > > However, something about how it converts the picts for web isn't working, so > instead of a neat little circle, for instance, I get "(pict '(prog > # > I suspect this is probably something to do with a difference in behavior in > how images are converted by the server, which does a convertible? test and > then runs: > (run-code ev `(bytes-append #"data:image/png;base64," > (base64-encode (convert ,res 'png-bytes) #""))) > > At an idiot's guess, something is different about how pict is making the > images, so convertible? is #f and the code just prints the (pict '(prog... > stuff. > > I've set up a fork here: https://github.com/jarcane/try-racket > I'm still working on getting the DNS set properly though, so no > try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ but > I haven't figured out how to get try-racket.org to go there yet. > > > wrote: >> >> Maybe you can use slideshow/code-pict instead? >> >> Robby >> >> On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns >> wrote: >> > The culprit is the slideshow/code module loaded into the sandbox >> > evaluator. Requiring slideshow/code attempts to establish an X server >> > connection. >> > >> > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: >> >> Greetings, >> >> >> >> For some time now, it's bothered me a bit that Racket doesn't have an >> >> online REPL currently hosted anywhere. There's one written here: >> >> https://github.com/voila/try-racket >> >> >> >> But no one's hosted it anywhere. So I took it upon myself to fix that. >> >> I've >> >> purchased try-racket.org and a basic DigitalOcean droplet to host it >> >> on, >> >> but I've hit a snag: I can't get it to run. >> >> >> >> It runs more or less without trouble on my personal FreeBSD box, but on >> >> my >> >> Debian 7 droplet I waded through countless dependency issues until >> >> finally >> >> I reached what seems to be this same error: >> >> >> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 >> >> >> >> Presuming that perhaps this was in someway trying to run Racket in an >> >> actual GUI window whether I wanted it to or not, I attempted to run it >> >> as >> >> --script, but this just quits silently instead, leaving no servlet >> >> behind >> >> either. >> >> >> >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME >> >> it's usually the former ... ) >> >> >> >> John Berry >> >> http://jarcane.github.com >> > >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users > > From jay.mccarthy at gmail.com Mon Sep 22 09:14:21 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Mon, 22 Sep 2014 09:14:21 -0400 Subject: [racket] ->i contract question In-Reply-To: <7D717570-D4F1-4F93-A6D8-70A981189839@gmail.com> References: <7D717570-D4F1-4F93-A6D8-70A981189839@gmail.com> Message-ID: As far as I can tell, there is no contract form that allows treating the values returned as a list. Here is how you could implement one if you wanted: http://pasterack.org/pastes/46111 Maybe Robby has an opinion about whether this should be done in racket/contract Jay On Sun, Sep 21, 2014 at 1:47 AM, Kevin Forchione wrote: > Hi guys, > Is there a syntax for dependent-range that would allow 0 or more values to be specified? The documentation appears to describe only a specified number of values. Is there an analogue to list of and non-empty-listof? > > -Kevin > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From jay.mccarthy at gmail.com Mon Sep 22 09:24:53 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Mon, 22 Sep 2014 09:24:53 -0400 Subject: [racket] Provide transformers In-Reply-To: References: Message-ID: Is this what you are looking for? #lang racket/base (require (for-syntax racket/base syntax/parse racket/provide-transform)) (define-syntax test-pred-out (make-provide-pre-transformer (? (stx _) (syntax-parse stx [(_ b:id p:expr) (syntax-local-lift-module-end-declaration #'(module+ test (if (p b) (printf "It passed.\n") (printf "It didn't pass.\n")))) (syntax/loc stx b)])))) ;; Example (define some-integer "17") (define some-other-integer 17) (provide (test-pred-out some-integer integer?) (test-pred-out some-other-integer integer?)) On Fri, Sep 19, 2014 at 5:41 PM, Jack Firth wrote: > I've been looking into how to design a macro that would specify tests in a > provide transformer, for example something like > > (provide (test-pred-out some-integer integer?)) > > I'd like that to expand to: > > (provide some-integer) > (module+ test > (check-pred integer? some-integer)) > > From what I can gather from the reference, normally provide forms are done > with define-provide-syntax, but that macro doesn't let me splice anything > into the module body. The reference mentions provide pre-transformers, and > says: > > "A provide pre-transformer is applied as part of the first phase of a > module?s expansion. Since it is used in the first phase, a provide > pre-transformer can use functions such as syntax-local-lift-expression to > introduce expressions and definitions in the enclosing module." > > So it sounds like what I want is definitely possible, but I have no idea how > to actually do it. Does anyone have some simple well-explained examples to > guide me in the right direction? > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- Jay McCarthy 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&C 64:33 From robby at eecs.northwestern.edu Mon Sep 22 10:01:53 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 22 Sep 2014 09:01:53 -0500 Subject: [racket] ->i contract question In-Reply-To: References: <7D717570-D4F1-4F93-A6D8-70A981189839@gmail.com> Message-ID: Turning things back and forth between values and lists is not something that our apis and our runtime infrastructure really encourages. So I'd say that the first thing to try would be to either fix the number of values returned from the function or to start programming with lists instead. If that doesn't work, then it is certainly possible to make function contract combinators that implicitly do the call-with-values like that and then list you specify the range contract kind of like how you specify the #:rest contract. I'd be happy to help guide someone who wanted to try to use the contract library to attempt that. It would be a good exercise to learn about contracts and macros, no doubt! Robby On Mon, Sep 22, 2014 at 8:14 AM, Jay McCarthy wrote: > As far as I can tell, there is no contract form that allows treating > the values returned as a list. Here is how you could implement one if > you wanted: > > http://pasterack.org/pastes/46111 > > Maybe Robby has an opinion about whether this should be done in racket/contract > > Jay > > On Sun, Sep 21, 2014 at 1:47 AM, Kevin Forchione wrote: >> Hi guys, >> Is there a syntax for dependent-range that would allow 0 or more values to be specified? The documentation appears to describe only a specified number of values. Is there an analogue to list of and non-empty-listof? >> >> -Kevin >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > -- > Jay McCarthy > 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&C 64:33 > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From lysseus at gmail.com Mon Sep 22 12:05:00 2014 From: lysseus at gmail.com (Kevin Forchione) Date: Mon, 22 Sep 2014 09:05:00 -0700 Subject: [racket] keyword-apply questions Message-ID: Hi guys, Apparently, with a desire to use keywords more in functions, I?ll have to wrap my head around keyword-apply better. Two questions I have are: 1. Why must the kw-lst be sorted in keyword kw-arg ?) After playing around a bit all of the following are equivalent: (define (bar #:x x #:y y #:z z u v . w) (list x y z u v w)) (keyword-apply bar '() '() '(6 7 8 9 10) #:x 3 #:y 4 #:z 5) (keyword-apply bar '(#:x #:y #:z) '(3 4 5) '(6 7 8 9 10)) (keyword-apply bar #:x 3 #:y 4 #:z 5 '() '() '(6 7 8 9 10)) (keyword-apply bar #:z 5 #:y 4 #:x 3 '() '() '(6 7 8 9 10)) (keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) '(6 7 8 9 10)) (keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) 6 7 '(8 9 10)) So it appears that ordering of keywords is only mandatory in the kw-lst. What?s the advantage to using the kw-lst/kw-val-lst? If those lists are primarily built using automation, rather than by hand, then question #1 is probably explained by the idea that the automation is expected to sort the keywords prior to the call? -Kevin From lysseus at gmail.com Mon Sep 22 14:24:18 2014 From: lysseus at gmail.com (Kevin Forchione) Date: Mon, 22 Sep 2014 11:24:18 -0700 Subject: [racket] keyword-apply questions In-Reply-To: References: Message-ID: On Sep 22, 2014, at 9:05 AM, Kevin Forchione wrote: > Hi guys, > Apparently, with a desire to use keywords more in functions, I?ll have to wrap my head around keyword-apply better. Two questions I have are: > > 1. Why must the kw-lst be sorted in keyword > 2. The reference says: > > (keyword-apply proc > kw-lst > kw-val-lst > v ? > lst > #: kw-arg ?) > > After playing around a bit all of the following are equivalent: > > (define (bar #:x x #:y y #:z z u v . w) (list x y z u v w)) > > (keyword-apply bar '() '() '(6 7 8 9 10) #:x 3 #:y 4 #:z 5) > (keyword-apply bar '(#:x #:y #:z) '(3 4 5) '(6 7 8 9 10)) > (keyword-apply bar #:x 3 #:y 4 #:z 5 '() '() '(6 7 8 9 10)) > (keyword-apply bar #:z 5 #:y 4 #:x 3 '() '() '(6 7 8 9 10)) > (keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) '(6 7 8 9 10)) > (keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) 6 7 '(8 9 10)) > > So it appears that ordering of keywords is only mandatory in the kw-lst. What?s the advantage to using the kw-lst/kw-val-lst? If those lists are primarily built using automation, rather than by hand, then question #1 is probably explained by the idea that the automation is expected to sort the keywords prior to the call? > > -Kevin Hmmm? ok, looks like the kws-lst and kvs-lst serve the similar function as common lisp?s &allow-other-keys, which allows passing keyword/keyword values as arguments to functions not directly defining them. -Kevin From martindemello at gmail.com Mon Sep 22 14:49:55 2014 From: martindemello at gmail.com (Martin DeMello) Date: Mon, 22 Sep 2014 11:49:55 -0700 Subject: [racket] is anyone using racket to generate animated diagrams? Message-ID: I was looking through http://en.wikipedia.org/wiki/User:LucasVB/Gallery (generated, according to the author, with a combination of php and libgd), and wondered if anyone was doing similar stuff in racket. I'd love to see code samples if so. martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Mon Sep 22 15:05:27 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Mon, 22 Sep 2014 15:05:27 -0400 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> Message-ID: J and I chatted a little and he got his DNS working and also I added http://try.racket-lang.org/ as an alias for it. In general, the Racket team is willing to give out subdomains of r-l.org for projects that would like them, so they don't have to buy their own DNS addresses. Just email the list or one of us directly to ask. Jay On Mon, Sep 22, 2014 at 1:17 AM, J Arcane wrote: > Hmm. > > Alright, replacing the calls to slideshow with calls directly to pict, as > well as commenting out the racket/gui/base calls successfully gets the code > to run without X. > > However, something about how it converts the picts for web isn't working, so > instead of a neat little circle, for instance, I get "(pict '(prog > # > I suspect this is probably something to do with a difference in behavior in > how images are converted by the server, which does a convertible? test and > then runs: > (run-code ev `(bytes-append #"data:image/png;base64," > (base64-encode (convert ,res 'png-bytes) #""))) > > At an idiot's guess, something is different about how pict is making the > images, so convertible? is #f and the code just prints the (pict '(prog... > stuff. > > I've set up a fork here: https://github.com/jarcane/try-racket > I'm still working on getting the DNS set properly though, so no > try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ but > I haven't figured out how to get try-racket.org to go there yet. > > > wrote: >> >> Maybe you can use slideshow/code-pict instead? >> >> Robby >> >> On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns >> wrote: >> > The culprit is the slideshow/code module loaded into the sandbox >> > evaluator. Requiring slideshow/code attempts to establish an X server >> > connection. >> > >> > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: >> >> Greetings, >> >> >> >> For some time now, it's bothered me a bit that Racket doesn't have an >> >> online REPL currently hosted anywhere. There's one written here: >> >> https://github.com/voila/try-racket >> >> >> >> But no one's hosted it anywhere. So I took it upon myself to fix that. >> >> I've >> >> purchased try-racket.org and a basic DigitalOcean droplet to host it >> >> on, >> >> but I've hit a snag: I can't get it to run. >> >> >> >> It runs more or less without trouble on my personal FreeBSD box, but on >> >> my >> >> Debian 7 droplet I waded through countless dependency issues until >> >> finally >> >> I reached what seems to be this same error: >> >> >> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=12465 >> >> >> >> Presuming that perhaps this was in someway trying to run Racket in an >> >> actual GUI window whether I wanted it to or not, I attempted to run it >> >> as >> >> --script, but this just quits silently instead, leaving no servlet >> >> behind >> >> either. >> >> >> >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME >> >> it's usually the former ... ) >> >> >> >> John Berry >> >> http://jarcane.github.com >> > >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- Jay McCarthy 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&C 64:33 From jensaxel at soegaard.net Mon Sep 22 15:44:51 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Mon, 22 Sep 2014 21:44:51 +0200 Subject: [racket] is anyone using racket to generate animated diagrams? In-Reply-To: References: Message-ID: Hi Martin, As an example I implemented the standing wave animation. The MetaPict package is available through the package system. Use the package manager in DrRacket to install install it. The run the program below in DrRacket to see a standing wave. The documentation of the MetaPict package is here: http://soegaard.github.io/docs/metapict/metapict.html Enjoy, Jens Axel #lang racket (require metapict metapict/graph (only-in 2htdp/universe animate) (only-in 2htdp/image freeze)) (set-curve-pict-size 400 100) ; size 400 x 100 pixels ; red-circle : point -> pict ; red disk with center in the point p drawn with black periphery (define (red-circle p) (def c (circle p 0.1)) (draw (color "red" (fill c)) ; red, filled circle c)) ; black outline (define N 100) ; number of frames in the animation (define (f m) ; The function to graph at time t is cos(?t)*sin(kx), where t is in [0;2pi]. ; First we convert the frame number to time: (define t (* 2 pi (/ (remainder m N) N))) (define ? 1) ; angular frequency (define k 1) ; wave number ; The actual function to graph (? (x) (* (cos (* ? t)) (sin (* k x))))) (define (animation-frame m) (with-window (window/aspect -0.2 (+ (* 4 pi) 0.2) ; x in [-0.1, 4pi+0.1] -1.2) ; y in [-0.1, 1.1] (pict->bitmap ; animate needs bitmaps (draw ; graph the function f from 0 to 4pi (graph (f m) 0 (* 4 pi)) ; five red dots at the nodes (0,0), (pi,0), ... (for/draw ([n 5]) (red-circle (pt (* n pi) 0))))))) ; animate them! (animate animation-frame) 2014-09-22 20:49 GMT+02:00 Martin DeMello : > I was looking through http://en.wikipedia.org/wiki/User:LucasVB/Gallery > (generated, according to the author, with a combination of php and libgd), > and wondered if anyone was doing similar stuff in racket. I'd love to see > code samples if so. > > martin > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- -- Jens Axel S?gaard From martindemello at gmail.com Mon Sep 22 16:06:54 2014 From: martindemello at gmail.com (Martin DeMello) Date: Mon, 22 Sep 2014 13:06:54 -0700 Subject: [racket] is anyone using racket to generate animated diagrams? In-Reply-To: References: Message-ID: Thanks, metapict looks great! martin On Mon, Sep 22, 2014 at 12:44 PM, Jens Axel S?gaard wrote: > Hi Martin, > > As an example I implemented the standing wave animation. > > The MetaPict package is available through the package system. > Use the package manager in DrRacket to install install it. > The run the program below in DrRacket to see a standing wave. > > The documentation of the MetaPict package is here: > http://soegaard.github.io/docs/metapict/metapict.html > > Enjoy, > Jens Axel > > #lang racket > (require metapict > metapict/graph > (only-in 2htdp/universe animate) > (only-in 2htdp/image freeze)) > > (set-curve-pict-size 400 100) ; size 400 x 100 pixels > > ; red-circle : point -> pict > ; red disk with center in the point p drawn with black periphery > (define (red-circle p) > (def c (circle p 0.1)) > (draw (color "red" (fill c)) ; red, filled circle > c)) ; black outline > > > (define N 100) ; number of frames in the animation > (define (f m) > ; The function to graph at time t is cos(?t)*sin(kx), where t is in > [0;2pi]. > ; First we convert the frame number to time: > (define t (* 2 pi (/ (remainder m N) N))) > (define ? 1) ; angular frequency > (define k 1) ; wave number > ; The actual function to graph > (? (x) (* (cos (* ? t)) (sin (* k x))))) > > > (define (animation-frame m) > (with-window (window/aspect -0.2 (+ (* 4 pi) 0.2) ; x in [-0.1, 4pi+0.1] > -1.2) ; y in [-0.1, 1.1] > (pict->bitmap ; animate needs bitmaps > (draw > ; graph the function f from 0 to 4pi > (graph (f m) 0 (* 4 pi)) > ; five red dots at the nodes (0,0), (pi,0), ... > (for/draw ([n 5]) > (red-circle (pt (* n pi) 0))))))) > > ; animate them! > (animate animation-frame) > > > > 2014-09-22 20:49 GMT+02:00 Martin DeMello : > > I was looking through http://en.wikipedia.org/wiki/User:LucasVB/Gallery > > (generated, according to the author, with a combination of php and > libgd), > > and wondered if anyone was doing similar stuff in racket. I'd love to see > > code samples if so. > > > > martin > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > > > > -- > -- > Jens Axel S?gaard > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsgrahamus at yahoo.com Mon Sep 22 17:11:25 2014 From: jsgrahamus at yahoo.com (Steve Graham) Date: Mon, 22 Sep 2014 14:11:25 -0700 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> Message-ID: <1411420285.72632.YahooMailNeo@web121405.mail.ne1.yahoo.com> I get errors when trying to type in a multi-line function. Am I doing something wrong? ________________________________ From: Jay McCarthy To: J Arcane Cc: Racket Users ; Robby Findler ; Marc Burns Sent: Monday, September 22, 2014 12:05 PM Subject: Re: [racket] Hosting the try-racket REPL. J and I chatted a little and he got his DNS working and also I added http://try.racket-lang.org/ as an alias for it. In general, the Racket team is willing to give out subdomains of r-l.org for projects that would like them, so they don't have to buy their own DNS addresses. Just email the list or one of us directly to ask. Jay On Mon, Sep 22, 2014 at 1:17 AM, J Arcane wrote: > Hmm. > > Alright, replacing the calls to slideshow with calls directly to pict, as > well as commenting out the racket/gui/base calls successfully gets the code > to run without X. > > However, something about how it converts the picts for web isn't working, so > instead of a neat little circle, for instance, I get "(pict '(prog > # > I suspect this is probably something to do with a difference in behavior in > how images are converted by the server, which does a convertible? test and > then runs: > (run-code ev `(bytes-append #"data:image/png;base64," > (base64-encode (convert ,res 'png-bytes) #""))) > > At an idiot's guess, something is different about how pict is making the > images, so convertible? is #f and the code just prints the (pict '(prog... > stuff. > > I've set up a fork here: https://github.com/jarcane/try-racket > I'm still working on getting the DNS set properly though, so no > try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ but > I haven't figured out how to get try-racket.org to go there yet. > > > wrote: >> >> Maybe you can use slideshow/code-pict instead? >> >> Robby >> >> On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns >> wrote: >> > The culprit is the slideshow/code module loaded into the sandbox >> > evaluator. Requiring slideshow/code attempts to establish an X server >> > connection. >> > >> > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: >> >> Greetings, >> >> >> >> For some time now, it's bothered me a bit that Racket doesn't have an >> >> online REPL currently hosted anywhere. There's one written here: >> >> https://github.com/voila/try-racket >> >> >> >> But no one's hosted it anywhere. So I took it upon myself to fix that. >> >> I've >> >> purchased try-racket.org and a basic DigitalOcean droplet to host it >> >> on, >> >> but I've hit a snag: I can't get it to run. >> >> >> >> It runs more or less without trouble on my personal FreeBSD box, but on >> >> my >> >> Debian 7 droplet I waded through countless dependency issues until >> >> finally >> >> I reached what seems to be this same error: >> >> >> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail?=12465 >> >> >> >> Presuming that perhaps this was in someway trying to run Racket in an >> >> actual GUI window whether I wanted it to or not, I attempted to run it >> >> as >> >> --script, but this just quits silently instead, leaving no servlet >> >> behind >> >> either. >> >> >> >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME >> >> it's usually the former ... ) >> >> >> >> John Berry >> >> http://jarcane.github.com >> > >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- Jay McCarthy 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&C 64:33 ____________________ Racket Users list: http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From clements at brinckerhoff.org Sun Sep 21 20:52:56 2014 From: clements at brinckerhoff.org (John Clements) Date: Sun, 21 Sep 2014 17:52:56 -0700 Subject: [racket] Rendering the PLT symbol in Racket? In-Reply-To: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> References: <989C0D02-3EED-40CB-8DB6-E4B36B6DFC4C@knauth.org> Message-ID: There are a whole bunch of ways of answering this question; you might want Neil?s fantastic ray-traced version, or just the simple paths. In case it?s helpful, here?s the original postscript file generated by Shriram, Robby, and Matthew. Oh, wait, here?s the comment from the file: %%Title: PLT Lambda %%Creator: Matthew, then Shriram, finally Robby %%CreationDate: June 24, 1997 %%For: PLT (NB: Apple Mail tries to render this as an image, pretty badly. Save the attachment to read it.) -------------- next part -------------- A non-text attachment was scrubbed... Name: plt.ps Type: image/ps Size: 1899 bytes Desc: not available URL: -------------- next part -------------- On Sep 21, 2014, at 4:59 PM, Alexander D. Knauth wrote: > I tried it with the images in the email, but it was too big, so here it is just links. > I think there was something on the list about this before, and I found these again from that: > http://docs.racket-lang.org/images/Logos.html?q=plt-logo#%28def._%28%28lib._images%2Flogos..rkt%29._plt-logo%29%29 > (require images/logos) > (plt-logo) > and also > http://docs.racket-lang.org/draw/overview.html?q=racket%2Fdraw#%28part._.Drawing_.Paths%29 (down a little bit) > > > On Sep 21, 2014, at 12:52 AM, Daniel Prager wrote: > >> There was interest following my talk at RacketCon in a www.youpatch.com quilt pattern featuring the PLT symbol (file:///Users/dan/Documents/plt.svg). >> >> I was having a play with youpatch.com by standard means, to put together a commemorative pattern, but I think I can do a cleaner job given access to Racket code that generates the image. >> >> Can anyone point me to, or send me the code? >> >> >> Dan >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From jarcane at gmail.com Tue Sep 23 00:35:44 2014 From: jarcane at gmail.com (J Arcane) Date: Tue, 23 Sep 2014 07:35:44 +0300 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: <1411420285.72632.YahooMailNeo@web121405.mail.ne1.yahoo.com> References: <20140921230002.GD29774@happierface> <1411420285.72632.YahooMailNeo@web121405.mail.ne1.yahoo.com> Message-ID: It's a known issue. Alex Knauth has submitted a rough solution to my fork of it; I'll get it merged and pushed to the server shortly. On Tue, Sep 23, 2014 at 12:11 AM, Steve Graham wrote: > I get errors when trying to type in a multi-line function. Am I doing > something wrong? > > ------------------------------ > *From:* Jay McCarthy > *To:* J Arcane > *Cc:* Racket Users ; Robby Findler < > robby at eecs.northwestern.edu>; Marc Burns > *Sent:* Monday, September 22, 2014 12:05 PM > *Subject:* Re: [racket] Hosting the try-racket REPL. > > J and I chatted a little and he got his DNS working and also I added > > http://try.racket-lang.org/ > > as an alias for it. > > In general, the Racket team is willing to give out subdomains of > r-l.org for projects that would like them, so they don't have to buy > their own DNS addresses. Just email the list or one of us directly to > ask. > > Jay > > On Mon, Sep 22, 2014 at 1:17 AM, J Arcane wrote: > > Hmm. > > > > Alright, replacing the calls to slideshow with calls directly to pict, as > > well as commenting out the racket/gui/base calls successfully gets the > code > > to run without X. > > > > However, something about how it converts the picts for web isn't > working, so > > instead of a neat little circle, for instance, I get "(pict '(prog > > # > > > I suspect this is probably something to do with a difference in behavior > in > > how images are converted by the server, which does a convertible? test > and > > then runs: > > (run-code ev `(bytes-append #"data:image/png;base64," > > (base64-encode (convert ,res 'png-bytes) #""))) > > > > At an idiot's guess, something is different about how pict is making the > > images, so convertible? is #f and the code just prints the (pict > '(prog... > > stuff. > > > > I've set up a fork here: https://github.com/jarcane/try-racket > > I'm still working on getting the DNS set properly though, so no > > try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ > but > > I haven't figured out how to get try-racket.org to go there yet. > > > > > > wrote: > >> > >> Maybe you can use slideshow/code-pict instead? > >> > >> Robby > >> > >> On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns < > m4burns at csclub.uwaterloo.ca> > >> wrote: > >> > The culprit is the slideshow/code module loaded into the sandbox > >> > evaluator. Requiring slideshow/code attempts to establish an X server > >> > connection. > >> > > >> > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: > >> >> Greetings, > >> >> > >> >> For some time now, it's bothered me a bit that Racket doesn't have an > >> >> online REPL currently hosted anywhere. There's one written here: > >> >> https://github.com/voila/try-racket > >> >> > >> >> But no one's hosted it anywhere. So I took it upon myself to fix > that. > >> >> I've > >> >> purchased try-racket.org and a basic DigitalOcean droplet to host it > >> >> on, > >> >> but I've hit a snag: I can't get it to run. > >> >> > >> >> It runs more or less without trouble on my personal FreeBSD box, but > on > >> >> my > >> >> Debian 7 droplet I waded through countless dependency issues until > >> >> finally > >> >> I reached what seems to be this same error: > >> >> > >> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail?=12465 > > > >> >> > >> >> Presuming that perhaps this was in someway trying to run Racket in an > >> >> actual GUI window whether I wanted it to or not, I attempted to run > it > >> >> as > >> >> --script, but this just quits silently instead, leaving no servlet > >> >> behind > >> >> either. > >> >> > >> >> Any ideas what I might be doing wrong? or have I hit a proper bug? > (IME > >> >> it's usually the former ... ) > >> >> > >> >> John Berry > >> >> http://jarcane.github.com > >> > > >> >> ____________________ > >> >> Racket Users list: > >> >> http://lists.racket-lang.org/users > >> > > >> > ____________________ > >> > Racket Users list: > >> > http://lists.racket-lang.org/users > > > > > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > > > > -- > Jay McCarthy > 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&C 64:33 > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Tue Sep 23 16:42:24 2014 From: gneuner2 at comcast.net (George Neuner) Date: Tue, 23 Sep 2014 16:42:24 -0400 Subject: [racket] web server: module servlets Message-ID: <5421DB30.3030803@comcast.net> Hi, I'm using 6.0.1 and I have a couple of questions regarding module servlets. I'm new to the server side of Racket so please be gentle. 1) Is there any way to speed up initial servlet loading? Even for a very simple servlet (does nothing, canned response for testing) several seconds elapse before it responds to the browser. I tried compiling it to bytecode with raco, but having the ./compiled/.zo file available doesn't seem to make any noticeable difference. I know the bytecode still is JIT'd before execution, but I thought eliminating the source compile step would have helped more. Does a web server require the .zo file to be in a different location than ./compiled? Or does it not deal with bytecode files at all? 2) Debugging module servlets is a pain due to having to stop/restart the server. Is there some clever way to force the server to unload a particular servlet but keep running? I thought about starting the listener in a thread, but I can't figure how to get at either the thread or the custodian from within a servlet. Would listener termination have to be done from a hardcoded function at the top level? Apologies if these questions are stupid. Thanks, George From jay.mccarthy at gmail.com Tue Sep 23 18:04:58 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Tue, 23 Sep 2014 18:04:58 -0400 Subject: [racket] web server: module servlets In-Reply-To: <5421DB30.3030803@comcast.net> References: <5421DB30.3030803@comcast.net> Message-ID: On Tue, Sep 23, 2014 at 4:42 PM, George Neuner wrote: > Hi, > > I'm using 6.0.1 and I have a couple of questions regarding module > servlets. I'm new to the server side of Racket so please be gentle. > > > 1) Is there any way to speed up initial servlet loading? Even for a > very simple servlet (does nothing, canned response for testing) > several seconds elapse before it responds to the browser. I tried > compiling it to bytecode with raco, but having the ./compiled/.zo file > available doesn't seem to make any noticeable difference. I know the > bytecode still is JIT'd before execution, but I thought eliminating > the source compile step would have helped more. > > Does a web server require the .zo file to be in a different location > than ./compiled? Or does it not deal with bytecode files at all? > This is why I recommend that new users use serve/servlet, which is much faster because it does not use namespaces or live loading. > 2) Debugging module servlets is a pain due to having to stop/restart > the server. Is there some clever way to force the server to unload a > particular servlet but keep running? > > I thought about starting the listener in a thread, but I can't figure > how to get at either the thread or the custodian from within a > servlet. Would listener termination have to be done from a hardcoded > function at the top level? Doing this pretty much requires not following my advice in question 1, but the default server (used by the command line tool) allows you to go to "/conf/refresh-servlets" and unload/reload all the servlet code. The way that you would know that is by following the link from the command-line docs http://docs.racket-lang.org/web-server/run.html#%28part._command-line-tools%29 to the web-server@ unit which is the implementation of the dispatch sequence the command-line tool uses: http://docs.racket-lang.org/web-server-internal/Web_Servers.html#%28def._%28%28lib._web-server%2Fweb-server-unit..rkt%29._web-server~40%29%29 > > Apologies if these questions are stupid. > > Thanks, > George > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From jsgrahamus at yahoo.com Tue Sep 23 20:32:23 2014 From: jsgrahamus at yahoo.com (Steve Graham) Date: Tue, 23 Sep 2014 17:32:23 -0700 Subject: [racket] Hosting the try-racket REPL. In-Reply-To: References: <20140921230002.GD29774@happierface> <1411420285.72632.YahooMailNeo@web121405.mail.ne1.yahoo.com> Message-ID: <1411518743.40110.YahooMailNeo@web121406.mail.ne1.yahoo.com> Thanks. ________________________________ From: J Arcane To: Steve Graham Cc: Racket Users Sent: Monday, September 22, 2014 9:35 PM Subject: Re: [racket] Hosting the try-racket REPL. It's a known issue. Alex Knauth has submitted a rough solution to my fork of it; I'll get it merged and pushed to the server shortly. On Tue, Sep 23, 2014 at 12:11 AM, Steve Graham wrote: > > >I get errors when trying to type in a multi-line function. Am I doing something wrong? > > > > >________________________________ > From: Jay McCarthy >To: J Arcane >Cc: Racket Users ; Robby Findler ; Marc Burns >Sent: Monday, September 22, 2014 12:05 PM >Subject: Re: [racket] Hosting the try-racket REPL. > > >J and I chatted a little and he got his DNS working and also I added > >http://try.racket-lang.org/ > >as an alias for it. > >In general, the Racket team is willing to give out subdomains of >r-l.org for projects that would like them, so they don't have to buy >their own DNS addresses. Just email the list or one of us directly to >ask. > >Jay > >On Mon, Sep 22, 2014 at 1:17 AM, J Arcane wrote: >> Hmm. >> >> Alright, replacing the calls to slideshow with calls directly to pict, as >> well as commenting out the racket/gui/base calls successfully gets the code >> to run without X. >> >> However, something about how it converts the picts for web isn't working, so >> instead of a neat little circle, for instance, I get "(pict '(prog >> #> >> I suspect this is probably something to do with a difference in behavior in >> how images are converted by the server, which does a convertible? test and >> then runs: >> (run-code ev `(bytes-append #"data:image/png;base64," >> (base64-encode (convert ,res 'png-bytes) #""))) >> >> At an idiot's guess, something is different about how pict is making the >> images, so convertible? is #f and the code just prints the (pict '(prog... >> stuff. >> >> I've set up a fork here: https://github.com/jarcane/try-racket >> I'm still working on getting the DNS set properly though, so no >> try-racket.org yet; the servlet is public at http://104.131.18.192:8000/ but >> I haven't figured out how to get try-racket.org to go there yet. >> >> >> wrote: >>> >>> Maybe you can use slideshow/code-pict instead? >>> >>> Robby >>> >>> On Sun, Sep 21, 2014 at 6:00 PM, Marc Burns >>> wrote: >>> > The culprit is the slideshow/code module loaded into the sandbox >>> > evaluator. Requiring slideshow/code attempts to establish an X server >>> > connection. >>> > >>> > On Mon, Sep 22, 2014 at 12:12:37AM +0300, J Arcane wrote: >>> >> Greetings, >>> >> >>> >> For some time now, it's bothered me a bit that Racket doesn't have an >>> >> online REPL currently hosted anywhere. There's one written here: >>> >> https://github.com/voila/try-racket >>> >> >>> >> But no one's hosted it anywhere. So I took it upon myself to fix that. >>> >> I've >>> >> purchased try-racket.org and a basic DigitalOcean droplet to host it >>> >> on, >>> >> but I've hit a snag: I can't get it to run. >>> >> >>> >> It runs more or less without trouble on my personal FreeBSD box, but on >>> >> my >>> >> Debian 7 droplet I waded through countless dependency issues until >>> >> finally >>> >> I reached what seems to be this same error: >>> >> >>> >> http://bugs.racket-lang.org/query/?cmd=view%20audit-trail?=12465 > >>> >> >>> >> Presuming that perhaps this was in someway trying to run Racket in an >>> >> actual GUI window whether I wanted it to or not, I attempted to run it >>> >> as >>> >> --script, but this just quits silently instead, leaving no servlet >>> >> behind >>> >> either. >>> >> >>> >> Any ideas what I might be doing wrong? or have I hit a proper bug? (IME >>> >> it's usually the former ... ) >>> >> >>> >> John Berry >>> >> http://jarcane.github.com >>> > >>> >> ____________________ >>> >> Racket Users list: >>> >> http://lists.racket-lang.org/users >>> > >>> > ____________________ >>> > Racket Users list: >>> > http://lists.racket-lang.org/users >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > > > >-- >Jay McCarthy >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&C 64:33 > > > > >____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > >____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Tue Sep 23 21:19:41 2014 From: gneuner2 at comcast.net (George Neuner) Date: Tue, 23 Sep 2014 21:19:41 -0400 Subject: [racket] web server: module servlets In-Reply-To: References: <5421DB30.3030803@comcast.net> Message-ID: <54221C2D.9020109@comcast.net> Hi Jay, On 9/23/2014 6:04 PM, Jay McCarthy wrote: > On Tue, Sep 23, 2014 at 4:42 PM, George Neuner wrote: > > > > 1) Is there any way to speed up initial [module] servlet loading? > > This is why I recommend that new users use serve/servlet, which is > much faster because it does not use namespaces or live loading. That's an option for a finished application ... if a web application ever really can be said to be finished ... but it's tough when you're developing. I guess the question is "where is all the time spent"? Loading required modules from the library I suppose? Not really knowing much about Racket's internals he naively asks: Could a server pre-load the commonly used webserver modules and make them available to new module servlets, or does the custodian implementation make doing that difficult/impossible? > > 2) Debugging module servlets is a pain due to having to stop/restart > > the server. Is there some clever way to force the server to unload a > > particular servlet but keep running? > > Doing this pretty much requires not following my advice in question 1, > but the default server (used by the command line tool) allows you to > go to "/conf/refresh-servlets" and unload/reload all the servlet code. That might help. Does unloading & reloading affect a stateless servlet that isn't been changed? More to the point, can you stop/restart the server and continue a stateless servlet? My application so far is based on stateful servlets and AJAX ... stateful mainly because it's easier for me to understand. Currently there is little use of continuations, but some planned functionality will use them extensively and it certainly would help if debugging didn't always mean starting over setting up conditions in the application. George -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Tue Sep 23 22:03:38 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Tue, 23 Sep 2014 22:03:38 -0400 Subject: [racket] web server: module servlets In-Reply-To: <54221C2D.9020109@comcast.net> References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> Message-ID: On Tue, Sep 23, 2014 at 9:19 PM, George Neuner wrote: > Hi Jay, > > On 9/23/2014 6:04 PM, Jay McCarthy wrote: > > On Tue, Sep 23, 2014 at 4:42 PM, George Neuner wrote: >> >> 1) Is there any way to speed up initial [module] servlet loading? > > This is why I recommend that new users use serve/servlet, which is > much faster because it does not use namespaces or live loading. > > > That's an option for a finished application ... if a web application ever > really can > be said to be finished ... but it's tough when you're developing. Hi George, The command-line tool is basically deprecated and only provided for backwards compatibility. There is a huge amount that it can't do at all and it hasn't been the primary way that we recommend using the Web server for a very long time. > I guess the question is "where is all the time spent"? Loading required > modules > from the library I suppose? Yes. > Not really knowing much about Racket's internals he naively asks: Could a > server > pre-load the commonly used webserver modules and make them available > to new module servlets, or does the custodian implementation make doing that > difficult/impossible? This is the purpose of the make-servlet-namespace argument of configuration-table->web-config@ but there is no option in the configuration file for that argument. http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 >> 2) Debugging module servlets is a pain due to having to stop/restart >> the server. Is there some clever way to force the server to unload a >> particular servlet but keep running? > > Doing this pretty much requires not following my advice in question 1, > but the default server (used by the command line tool) allows you to > go to "/conf/refresh-servlets" and unload/reload all the servlet code. > > > That might help. Does unloading & reloading affect a stateless servlet that > isn't > been changed? More to the point, can you stop/restart the server and > continue > a stateless servlet? Yes, that's the goal of stateless servlets :) > My application so far is based on stateful servlets and AJAX ... stateful > mainly because > it's easier for me to understand. Currently there is little use of > continuations, but > some planned functionality will use them extensively and it certainly would > help if > debugging didn't always mean starting over setting up conditions in the > application. This comment/question is related to questions 4 and 5 from the FAQ: http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 -- Jay McCarthy 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&C 64:33 From gustavo at oma.org.ar Tue Sep 23 23:22:28 2014 From: gustavo at oma.org.ar (Gustavo Massaccesi) Date: Wed, 24 Sep 2014 00:22:28 -0300 Subject: [racket] Exception decorator. is it possible? In-Reply-To: <1410973155.471904896@f186.i.mail.ru> References: <1410973155.471904896@f186.i.mail.ru> Message-ID: This code works, but it needs a lot more of error checking. It uses that all the built-in exceptions are transparent and that all of them inherit from exn, so the first field is the message. ;--- #lang racket (define (copy-struct/new-first str first) (define-values (str-struct-info _) (struct-info str)) (define str-maker (struct-type-make-constructor str-struct-info)) (apply str-maker first (cdr (cdr (vector->list (struct->vector str)))))) (define (parse-item item) (with-handlers ([exn? (lambda (e) (raise (copy-struct/new-first e (format "At item ~a\n~a" item (exn-message e)))))]) (cons 1 2 3) ;==> cons: arity mismatch; #;(/ 1 0) ;==> /: division by zero )) (parse-item "Hello") ;--- Gustavo On Wed, Sep 17, 2014 at 1:59 PM, Roman Klochkov wrote: > I'm writeing a parser. > So I want to see in parser exception what happend and when (not only where). > > (define (parse-item item) > (with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message > (format "At item ~a\n~a" item (exn-message e))])))]) > ....)) > > But this way I lose all exception types. Is there a way to change exception > message, saving its type, except long copy/paste like > (with-handlers ([exn:fail:contract:arity? (raise (struct-copy > exn:fail:contract:arity ...))] > [exn:fil:contract? (raise (struct-copy > exn:fail:contract ...))] > ...) > ...) > > ? > > -- > Roman Klochkov > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From dtp at mindstory.com Wed Sep 24 00:29:09 2014 From: dtp at mindstory.com (David T. Pierson) Date: Wed, 24 Sep 2014 00:29:09 -0400 Subject: [racket] ranking items by their appearance in sets Message-ID: <1411532547.17822%dtp@mindstory.com> Hi all, Given a list of sets of symbols, I want to rank the symbols based on how many sets they appear in. I prefer to be completely functional. Below are 2 different implementations I came up with, with tests. I'm looking for criticism in any aspect, but most importantly I'm wondering whether there is a simpler implementation. Thanks. David ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #lang racket (require rackunit) (define (rank-set-elements/1 list-of-sets) (define list-of-lists (map set->list list-of-sets)) (define flat-list (flatten list-of-lists)) (define sorted-flat-list (sort flat-list symbol #:key cdr)) (define (rank-set-elements/2 list-of-sets) (define hash-of-item-frequencies (for*/fold ([frequencies (hash)]) ([a-set list-of-sets] [sym a-set]) (hash-update frequencies sym add1 0))) (define list-of-item-frequency-pairs (hash->list hash-of-item-frequencies)) (sort list-of-item-frequency-pairs > #:key cdr)) (define input (shuffle (map list->set '((a) (a b) (a b c) (a b c d) (a b c d e))))) (define expected '((a . 5) (b . 4) (c . 3) (d . 2) (e . 1))) (check-equal? (rank-set-elements/1 '()) '()) (check-equal? (rank-set-elements/1 input) expected) (check-equal? (rank-set-elements/2 '()) '()) (check-equal? (rank-set-elements/2 input) expected) From kalimehtar at mail.ru Wed Sep 24 07:50:45 2014 From: kalimehtar at mail.ru (=?UTF-8?B?Um9tYW4gS2xvY2hrb3Y=?=) Date: Wed, 24 Sep 2014 15:50:45 +0400 Subject: [racket] =?utf-8?q?Exception_decorator=2E_is_it_possible=3F?= In-Reply-To: References: <1410973155.471904896@f186.i.mail.ru> Message-ID: <1411559445.443202175@f436.i.mail.ru> Thank you very much! I didn't find struct-info function. This is enough for my needs. Wed, 24 Sep 2014 00:22:28 -0300 ?? Gustavo Massaccesi : > This code works, but it needs a lot more of error checking. > > It uses that all the built-in exceptions are transparent and that all > of them inherit from exn, so the first field is the message. > > ;--- > #lang racket > > (define (copy-struct/new-first str first) > (define-values (str-struct-info _) (struct-info str)) > (define str-maker (struct-type-make-constructor str-struct-info)) > (apply str-maker first (cdr (cdr (vector->list (struct->vector str)))))) > > (define (parse-item item) > (with-handlers ([exn? (lambda (e) (raise (copy-struct/new-first e > (format "At item ~a\n~a" item (exn-message e)))))]) > (cons 1 2 3) ;==> cons: arity mismatch; > #;(/ 1 0) ;==> /: division by zero > )) > > (parse-item "Hello") > ;--- > > Gustavo > > > > > On Wed, Sep 17, 2014 at 1:59 PM, Roman Klochkov wrote: > > I'm writeing a parser. > > So I want to see in parser exception what happend and when (not only where). > > > > (define (parse-item item) > > (with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message > > (format "At item ~a\n~a" item (exn-message e))])))]) > > ....)) > > > > But this way I lose all exception types. Is there a way to change exception > > message, saving its type, except long copy/paste like > > (with-handlers ([exn:fail:contract:arity? (raise (struct-copy > > exn:fail:contract:arity ...))] > > [exn:fil:contract? (raise (struct-copy > > exn:fail:contract ...))] > > ...) > > ...) > > > > ? > > > > -- > > Roman Klochkov > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -- Roman Klochkov From matthias at ccs.neu.edu Wed Sep 24 10:44:45 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Wed, 24 Sep 2014 10:44:45 -0400 Subject: [racket] ranking items by their appearance in sets In-Reply-To: <1411532547.17822%dtp@mindstory.com> References: <1411532547.17822%dtp@mindstory.com> Message-ID: <7081BD31-40BE-4648-8890-E4006F8B157D@ccs.neu.edu> On Sep 24, 2014, at 12:29 AM, David T. Pierson wrote: > I'm looking for criticism in any aspect, Style: Here is my rewrite with style suggestions. I liked to have a single point that tests all versions of a function when I conduct such design experiments. I also want to have all my test code in the test submodule so that it doesn't get deployed. That's why I am using a syntactic abstraction that unfolds into a submodule rather than a function that calls things. Performance: I have not checked their performance but I cannot imagine the first version to be performant. See my annotations. My choice: Your second version is what I would have written. #lang racket (module+ test (require rackunit)) ;; --------------------------------------------------------------------------------------------------- ;; [Listof [Setof Symbol]] -> [Listof [Cons Symbol Natural]] ;; rank the elements of the given sets based on how many sets they appear in ;; version 1 (define (rank-set-elements/1 list-of-sets) ;; n is number of symbols in sets (define list-of-lists (map set->list list-of-sets)) ;; O(n) (define flat-list (flatten list-of-lists)) ;; allocates a lot ;; I would have fused the next two lines and possibly all four (define sorted-flat-list (sort flat-list symbol #:key cdr)) ;; version 2 [[ that's the version I would have written ]] (define (rank-set-elements/2 list-of-sets) (define hash-of-item-frequencies (for*/fold ([frequencies (hash)]) ([a-set list-of-sets] [sym a-set]) (hash-update frequencies sym add1 0))) ;; I would fuse the next two lines (define list-of-item-frequency-pairs (hash->list hash-of-item-frequencies)) (sort list-of-item-frequency-pairs > #:key cdr)) ;; unit tests < (define-syntax-rule (test rank) ;; => (module+ test (define input (shuffle (map list->set '((a) (a b) (a b c) (a b c d) (a b c d e))))) (define expected '((a . 5) (b . 4) (c . 3) (d . 2) (e . 1))) (check-equal? (rank '()) '()) (check-equal? (rank input) expected))) (test rank-set-elements/1) (test rank-set-elements/2) From terefv at ltu.sld.cu Wed Sep 24 22:35:49 2014 From: terefv at ltu.sld.cu (Alejandro Zamora) Date: Wed, 24 Sep 2014 22:35:49 -0400 Subject: [racket] macro question Message-ID: <20140924223549.7f15c912@alejandro-H61H2-CM> Hi Racket people: I have a (maybe too simple) question: How I create one macro like this (but using define-macro & R5RS language only)?: (vars sym var-cant val-of-vars) Example: (vars id 5 null) -> (prog (define id1 null) (define id2 null) (define id3 null) (define id4 null) (define id5 null)) -- Nunca digas nunca, di mejor: gracias, permiso, disculpe. Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ From dtp at mindstory.com Wed Sep 24 23:07:13 2014 From: dtp at mindstory.com (David T. Pierson) Date: Wed, 24 Sep 2014 23:07:13 -0400 Subject: [racket] ranking items by their appearance in sets In-Reply-To: <7081BD31-40BE-4648-8890-E4006F8B157D@ccs.neu.edu> References: <1411532547.17822%dtp@mindstory.com> <7081BD31-40BE-4648-8890-E4006F8B157D@ccs.neu.edu> Message-ID: <1411613699.19584%dtp@mindstory.com> On Wed, Sep 24, 2014 at 10:44:45AM -0400, Matthias Felleisen wrote: > Style: Here is my rewrite with style suggestions. I liked to have a > single point that tests all versions of a function when I conduct such > design experiments. I also want to have all my test code in the test > submodule so that it doesn't get deployed. That's why I am using a > syntactic abstraction that unfolds into a submodule rather than a > function that calls things. Thanks for the style suggestions. I am reminded I need to reread the style guide. > Performance: I have not checked their performance but I cannot imagine > the first version to be performant. See my annotations. Good point. I had put performance out of my mind because my real data is relatively small and I just wanted to play a bit with the methods, but I definitely appreciate the notes. > My choice: Your second version is what I would have written. Glad to know I was on the right track. Thank you. David From ckkashyap at gmail.com Thu Sep 25 02:17:57 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Thu, 25 Sep 2014 11:47:57 +0530 Subject: [racket] Switching from editor to repl Message-ID: Hi, I am new to racket (but am really excited by the idea - everything is a program) - need a quick help with Dr Racket - What's the keyboard shortcut to switch between editor and repl? I got to know from a video on youtube that I could use C-e to toggle the repl visibility but not able to find out how to get to the rpl using the keyboard. Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Thu Sep 25 02:33:55 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Thu, 25 Sep 2014 02:33:55 -0400 Subject: [racket] Switching from editor to repl In-Reply-To: References: Message-ID: I use C-e and C-d to do this and I just hit it twice, once hides the side and the second shows it and focuses it. On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: > Hi, > I am new to racket (but am really excited by the idea - everything is a > program) - need a quick help with Dr Racket - > > What's the keyboard shortcut to switch between editor and repl? > > I got to know from a video on youtube that I could use C-e to toggle the > repl visibility but not able to find out how to get to the rpl using the > keyboard. > Regards, > Kashyap > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- Jay McCarthy 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&C 64:33 From ckkashyap at gmail.com Thu Sep 25 03:43:58 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Thu, 25 Sep 2014 13:13:58 +0530 Subject: [racket] Switching from editor to repl In-Reply-To: References: Message-ID: C-d works for me ... thanks Jay. I was wondering though if I could've found this out in the documentation somewhere. I could not find it in the guide/google. Regards, Kashyap On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy wrote: > I use C-e and C-d to do this and I just hit it twice, once hides the > side and the second shows it and focuses it. > > On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: > > Hi, > > I am new to racket (but am really excited by the idea - everything is a > > program) - need a quick help with Dr Racket - > > > > What's the keyboard shortcut to switch between editor and repl? > > > > I got to know from a video on youtube that I could use C-e to toggle the > > repl visibility but not able to find out how to get to the rpl using the > > keyboard. > > Regards, > > Kashyap > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > > > > -- > Jay McCarthy > 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&C 64:33 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Thu Sep 25 08:56:53 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Thu, 25 Sep 2014 07:56:53 -0500 Subject: [racket] Switching from editor to repl In-Reply-To: References: Message-ID: The guide focuses on the language, not the DrRacket IDE. This is a link to the IDE docs that has a list of keyboard shortcuts. You might also try looking at the menu items; things are a little more discoverable that way too. http://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html hth, Robby On Thu, Sep 25, 2014 at 2:43 AM, C K Kashyap wrote: > C-d works for me ... thanks Jay. > I was wondering though if I could've found this out in the documentation > somewhere. I could not find it in the guide/google. > > Regards, > Kashyap > > On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy > wrote: >> >> I use C-e and C-d to do this and I just hit it twice, once hides the >> side and the second shows it and focuses it. >> >> On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: >> > Hi, >> > I am new to racket (but am really excited by the idea - everything is a >> > program) - need a quick help with Dr Racket - >> > >> > What's the keyboard shortcut to switch between editor and repl? >> > >> > I got to know from a video on youtube that I could use C-e to toggle the >> > repl visibility but not able to find out how to get to the rpl using the >> > keyboard. >> > Regards, >> > Kashyap >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > >> >> >> >> -- >> Jay McCarthy >> 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&C 64:33 > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From jarcane at gmail.com Thu Sep 25 09:52:47 2014 From: jarcane at gmail.com (J Arcane) Date: Thu, 25 Sep 2014 16:52:47 +0300 Subject: [racket] Unquoting a variable without unquoting its contents? Message-ID: http://try-racket.org continues to splutter to life, but there's still something of a glaring error in that it doesn't really like list or quote at all. AlexKnauth has narrowed the problem down here: https://github.com/jarcane/try-racket/issues/4#issuecomment-56751603 It seems that unquoting a variable does funny things to the variable's contents when they contain a bare quoted list or symbol, so we get weird results and errors. Quotes get lost, and then the eval finds itself looking at mangled forms. The best I can think of to do is maybe make a simple macro rather than using quasiquote? Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Thu Sep 25 10:17:49 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Thu, 25 Sep 2014 10:17:49 -0400 Subject: [racket] macro question In-Reply-To: <20140924223549.7f15c912@alejandro-H61H2-CM> References: <20140924223549.7f15c912@alejandro-H61H2-CM> Message-ID: I won't answer the question about R5RS, but in Racket you can do this fairly succinctly: #lang racket/base (require (for-syntax racket/base racket/syntax)) (define-syntax (vars stx) (syntax-case stx () [(_ id count val) (with-syntax ([(id_i ...) (for/list ([i (in-range 1 (add1 (syntax->datum #'count)))]) (format-id #'id "~a~a" #'id i))]) (syntax/loc stx (begin (define id_i val) ...)))])) (vars id 5 null) (vector id1 id2 id3 id4 id5) 2014-09-24 22:35 GMT-04:00 Alejandro Zamora : > Hi Racket people: > I have a (maybe too simple) question: > How I create one macro like this (but using define-macro & > R5RS language only)?: > > (vars sym var-cant val-of-vars) > > Example: > (vars id 5 null) -> (prog (define id1 null) > (define id2 null) > (define id3 null) > (define id4 null) > (define id5 null)) > > -- > Nunca digas nunca, di mejor: gracias, permiso, disculpe. > > Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From terefv at ltu.sld.cu Thu Sep 25 10:49:15 2014 From: terefv at ltu.sld.cu (Alejandro Zamora) Date: Thu, 25 Sep 2014 10:49:15 -0400 Subject: [racket] macro question In-Reply-To: References: <20140924223549.7f15c912@alejandro-H61H2-CM> Message-ID: <20140925104915.59291dc0@alejandro-H61H2-CM> Thanks Jay!! nice solution!! I'm asking for define-macro & R5RS because I'm trying to use one R5RS Embedded Scheme Interpreter on Python that have only define-macro construction for make macros and I want to use it. greetings! El Thu, 25 Sep 2014 10:17:49 -0400 Jay McCarthy escribi?: > I won't answer the question about R5RS, but in Racket you can do this > fairly succinctly: > > #lang racket/base > (require (for-syntax racket/base > racket/syntax)) > > (define-syntax (vars stx) > (syntax-case stx () > [(_ id count val) > (with-syntax > ([(id_i ...) > (for/list ([i (in-range 1 (add1 (syntax->datum #'count)))]) > (format-id #'id "~a~a" #'id i))]) > (syntax/loc stx > (begin (define id_i val) > ...)))])) > > (vars id 5 null) > > (vector id1 id2 id3 id4 id5) > > 2014-09-24 22:35 GMT-04:00 Alejandro Zamora : > > Hi Racket people: > > I have a (maybe too simple) question: > > How I create one macro like this (but using define-macro & > > R5RS language only)?: > > > > (vars sym var-cant val-of-vars) > > > > Example: > > (vars id 5 null) -> (prog (define id1 null) > > (define id2 null) > > (define id3 null) > > (define id4 null) > > (define id5 null)) > > > > -- > > Nunca digas nunca, di mejor: gracias, permiso, disculpe. > > > > Este mensaje le ha llegado mediante el servicio de correo > > electronico que ofrece Infomed para respaldar el cumplimiento de > > las misiones del Sistema Nacional de Salud. La persona que envia > > este correo asume el compromiso de usar el servicio a tales fines y > > cumplir con las regulaciones establecidas > > > > Infomed: http://www.sld.cu/ > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -- Nunca digas nunca, di mejor: gracias, permiso, disculpe. Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ From dbastos at toledo.com Thu Sep 25 12:48:05 2014 From: dbastos at toledo.com (Daniel Bastos) Date: Thu, 25 Sep 2014 13:48:05 -0300 Subject: [racket] htdp: exercise 21.1.3 Message-ID: The solution is missing, but I thought of exposing this one here so that it gets scrutinized before sending it to Robby Findler. ;; Exercise 21.1.3. Define natural-f, which is the abstraction of the ;; following two functions: ;; ;; ;; copy : N X -> (listof X) ;; ;; to create a list that contains ;; ;; obj n times ;; (define (copy n obj) ;; (cond ;; [(zero? n) empty] ;; [else (cons obj ;; (copy (sub1 n) obj))])) ;; ;; ;; n-adder : N number -> number ;; ;; to add n to x using ;; ;; (+ 1 ...) only ;; (define (n-adder n x) ;; (cond ;; [(zero? n) x] ;; [else (+ 1 ;; (n-adder (sub1 n) x))])) ;; ;; Don't forget to test natural-f. Also use natural-f to define ;; n-multiplier, which consumes n and x and produces n times x with ;; additions only. Use the examples to formulate a contract. ;; ;; Hint: The two function differ more than, say, the functions sum and ;; product in exercise 21.1.2. In particular, the base case in one ;; instance is a argument of the function, where in the other it is just ;; a constant value. ;; ;; (*) Solution ;; ;; After following the design recipe for abstraction, we get natural-f as ;; shown below. To write the contract, let's first only consider copy, ;; then we consider only n-adder and then we consider both. ;; ;; ;; natural-f-copy: Nat X (X (listof X) -> (listof X)) (listof X) -> (listof X) ;; ;; natural-f-adder: Nat number (number number -> number) number -> number ;; ;; The contract for natural-f-adder is more specific than ;; natural-f-copy. The difference between these is that in the first, two ;; different types are involved --- X and (listof X). Therefore, (listof ;; X) works as another variable, so let's call it Y in the final version. ;; natural-f: Nat X (X Y -> Y) Y -> Y (define (natural-f n x f init) (cond [(zero? n) init] [else (f x (natural-f (sub1 n) x f init))])) ;; (*) Tests ;; Let's use two different types in copy, say symbol and then number. (check-expect (copy 3 'a) '(a a a)) (check-expect (natural-f 3 'a cons empty) (copy 3 'a)) (check-expect (copy 0 'a) empty) (check-expect (natural-f 0 'a cons empty) (copy 0 'a)) (check-expect (copy 3 1) (list 1 1 1)) (check-expect (natural-f 3 1 cons empty) (copy 3 1)) ;; For n-adder, let's make sure to test different init-values. (check-expect (n-adder 3 3.14) 6.14) (check-expect (natural-f 3 1 + 3.14) (n-adder 3 3.14)) (check-expect (n-adder 3 1) 4) (check-expect (natural-f 3 1 + 1) (n-adder 3 1)) (check-expect (n-adder 3 2) 5) (check-expect (natural-f 3 1 + 2) (n-adder 3 2)) -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Thu Sep 25 12:51:56 2014 From: gneuner2 at comcast.net (George Neuner) Date: Thu, 25 Sep 2014 12:51:56 -0400 Subject: [racket] web server: module servlets In-Reply-To: References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> Message-ID: <5424482C.1030901@comcast.net> Hi Jay, On 9/23/2014 10:03 PM, Jay McCarthy wrote: > The command-line tool is basically deprecated and only provided for > backwards compatibility. There is a huge amount that it can't do at > all and it hasn't been the primary way that we recommend using the Web > server for a very long time. I'm not using the plt-web-server app - I created a minimal application that set up the environment: directories, ports, etc. and a start function that just returns a 404 if called. My server sits behind Apache and only handles servlets, which I would like to be demand load modules so they can be added to and updated easily. That's why I am interested in being able to unload servlets on command, though not necessarily all of them at once (although that also is helpful). > > Not really knowing much about Racket's internals he naively asks: > >Coulda server pre-load the commonly used webserver modules and make > >themavailableto new module servlets, or does the custodian > >implementation make doing thatdifficult/impossible? > > This is the purpose of the make-servlet-namespace argument of > configuration-table->web-config@ but there is no option in the > configuration file for that argument. > > http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 The namespace facility seems designed more for user written modules than for library modules. My analysis may be off-base as I have very little experience working directly with custodians, but it seems that when a dynamic servlet is first loaded, its custodian spends a lot of additional time (re)loading library modules that already exist in other custodians. [ Though I can't tell exactly what's happening, I can see a lot of disk activity when I think I'm loading a 5KB servlet. ] Reasonably I would have expected that after loading/linking the first servlet, the libraries common to the servlets would be already in memory. But loading additional servlets is no quicker [ and causes a similar disk hit ] so clearly I don't understand what is happening internally with the custodians. If a Racket library is deliberately put into the servlet-namespace, does that streamline linking? > > My application so far is based on stateful servlets and AJAX ... stateful > > mainly because it's easier for me to understand. Currently there is > >little use ofcontinuations, but some planned functionality will use them > > extensively and it certainly wouldhelp if debugging didn't always mean > >starting over setting up conditions in theapplication. > > This comment/question is related to questions 4 and 5 from the FAQ: > > http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 That link leads to a "troubleshooting" page 8-). I didn't consider the issue to be a "problem" per se - I already knew that restarting a stateful servlet would lose saved state. Most of my existing servlets are one-shots that don't save any state, but they are written using the stateful language. Only a few use continuations and not extensively (so far). I was just thinking ahead to stuff that will need to use continuations more extensively. Thanks for putting up with my questions. George -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Thu Sep 25 13:02:00 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Thu, 25 Sep 2014 13:02:00 -0400 Subject: [racket] ANN: DOS, Delimited-continuation-based Operating-system Simulator Message-ID: I've just released the game architecture library I talked about in part 2 of my RacketCon talk. The big picture of this library is to make World-style programs more compositional by (a) using continuations to hide the internal state (including control state) of components and (b) using environments as a standard monoid-based inter-component communication channel. A monoid is used to ensure that the components can be evaluated in any order. Despite assumptions some have about continuations and pure functional programming, it is incredibly efficient and can run at 60FPS, as demonstrated in get-bonus. You can get it with raco pkg install dos And you can try out the demo with racket -l dos/examples/win The demo source is a bare 39 lines: https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt and I provide the non-DOS version for comparison: https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt The core library has a mere 36 lines: https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt -- Jay McCarthy 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&C 64:33 From jay.mccarthy at gmail.com Thu Sep 25 13:04:44 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Thu, 25 Sep 2014 13:04:44 -0400 Subject: [racket] web server: module servlets In-Reply-To: <5424482C.1030901@comcast.net> References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> <5424482C.1030901@comcast.net> Message-ID: On Thu, Sep 25, 2014 at 12:51 PM, George Neuner wrote: > Hi Jay, > > On 9/23/2014 10:03 PM, Jay McCarthy wrote: > > The command-line tool is basically deprecated and only provided for > backwards compatibility. There is a huge amount that it can't do at > all and it hasn't been the primary way that we recommend using the Web > server for a very long time. > > > I'm not using the plt-web-server app - I created a minimal application that > set up the environment: directories, ports, etc. and a start function that > just returns a 404 if called. My server sits behind Apache and only handles > servlets, which I would like to be demand load modules so they can be added > to and updated easily. That's why I am interested in being able to unload > servlets on command, though not necessarily all of them at once (although > that also is helpful). > > >> Not really knowing much about Racket's internals he naively asks: >> Could a server pre-load the commonly used webserver modules and make >> them available to new module servlets, or does the custodian >> implementation make doing that difficult/impossible? > > This is the purpose of the make-servlet-namespace argument of > configuration-table->web-config@ but there is no option in the > configuration file for that argument. > > http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 > > > The namespace facility seems designed more for user written modules than for > library modules. > > My analysis may be off-base as I have very little experience working > directly with custodians, but it seems that when a dynamic servlet is first > loaded, its custodian spends a lot of additional time (re)loading library > modules that already exist in other custodians. [ Though I can't tell > exactly what's happening, I can see a lot of disk activity when I think I'm > loading a 5KB servlet. ] Reasonably I would have expected that after > loading/linking the first servlet, the libraries common to the servlets > would be already in memory. But loading additional servlets is no quicker [ > and causes a similar disk hit ] so clearly I don't understand what is > happening internally with the custodians. > > If a Racket library is deliberately put into the servlet-namespace, does > that streamline linking? > Your assumption about the purpose of this is not correct. Anything in the servlet-namespace will be shared between all servlets, and thus not loaded per-servlet. >> My application so far is based on stateful servlets and AJAX ... stateful >> mainly because it's easier for me to understand. Currently there is >> little use of continuations, but some planned functionality will use them >> extensively and it certainly would help if debugging didn't always mean >> starting over setting up conditions in the application. > > This comment/question is related to questions 4 and 5 from the FAQ: > > http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 > > > That link leads to a "troubleshooting" page 8-). I didn't consider the > issue to be a "problem" per se - I already knew that restarting a stateful > servlet would lose saved state. Most of my existing servlets are one-shots > that don't save any state, but they are written using the stateful language. > Only a few use continuations and not extensively (so far). I was just > thinking ahead to stuff that will need to use continuations more > extensively. > > Thanks for putting up with my questions. > George > -- Jay McCarthy 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&C 64:33 From fweytjens.android at gmail.com Thu Sep 25 16:19:51 2014 From: fweytjens.android at gmail.com (Frank Weytjens) Date: Thu, 25 Sep 2014 22:19:51 +0200 Subject: [racket] My DrRacket on Linux doesn't evaluate a thing Message-ID: Hi, My DrRacket doesn't evaluate any expression. Here is a link to my bug report Any suggestions? Thanks, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Thu Sep 25 16:34:09 2014 From: gneuner2 at comcast.net (George Neuner) Date: Thu, 25 Sep 2014 16:34:09 -0400 Subject: [racket] web server: module servlets In-Reply-To: References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> <5424482C.1030901@comcast.net> Message-ID: <54247C41.1030408@comcast.net> Hi Jay, On 9/25/2014 1:04 PM, Jay McCarthy wrote: > > If a Racket library is deliberately put into the servlet-namespace, does > > that streamline linking? > > Your assumption about the purpose of this is not correct. Anything in > the servlet-namespace will be shared between all servlets, and thus > not loaded per-servlet. I think you misunderstood my question, but you may have answered it anyway. What I really was asking was whether each custodian was having to individually load common Racket libraries [ web-server/*, net/*, etc. ] for a new servlet rather than all servlet custodians sharing libraries that are already loaded. Or, if not actually "loading" the libraries, then having to go to disk to check dependencies. So if I create a shared servlet namespace and put, e.g., "web-server/servlet" into it, would that in any way speed up starting a new dynamically loaded servlet? George -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Thu Sep 25 17:07:49 2014 From: gneuner2 at comcast.net (George Neuner) Date: Thu, 25 Sep 2014 17:07:49 -0400 Subject: [racket] Off Topic: Anybody reading this via news.gmane.org? In-Reply-To: References: Message-ID: <54248425.90509@comcast.net> Just wondering if anyone else reads this list via gmane and also is having problems? I follow several lists via gmane and a few days ago all my posts started being rejected - no authorization email, just an immediate "you are not allowed to post" error. Then 2 days ago, I also lost read access to all the lists - attempts get "480 Read access denied". I can ping the NNTP server but I can't connect to it. I have sent a couple of emails to gmane's adminstrator but so far I haven't gotten any response. Gmane is an open service that doesn't require accounts, so I am uncertain how I suddenly could be denied reading privilege ... even to post it only requires that you be subscribed to the particular list. I can't think of any reason my address would be black-listed ... unless, of course, all of comcast.net has been black-listed. Thanks, George From neil at neilvandyke.org Thu Sep 25 17:26:12 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Thu, 25 Sep 2014 17:26:12 -0400 Subject: [racket] Off Topic: Anybody reading this via news.gmane.org? In-Reply-To: <54248425.90509@comcast.net> References: <54248425.90509@comcast.net> Message-ID: <54248874.80201@neilvandyke.org> You can check your IP addr against the list at "http://gmane.org/denied.php". Neil V. From mflatt at cs.utah.edu Thu Sep 25 17:57:20 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Thu, 25 Sep 2014 15:57:20 -0600 Subject: [racket] My DrRacket on Linux doesn't evaluate a thing In-Reply-To: References: Message-ID: <20140925215722.0D540650190@mail-svr1.cs.utah.edu> After you type "(+ 1 1)", are you hitting the Enter key on the main part of the keyboard, or the one that's part of the numpad? If you're pressing the latter (the numpad Enter), then DrRacket doesn't evaluate the expression, and it instead lets you continue typing on the next line. If that's it, use the Enter key that's not in the numpad; the two keys are intentionally treated differently. At Thu, 25 Sep 2014 22:19:51 +0200, Frank Weytjens wrote: > Hi, > > My DrRacket doesn't evaluate any expression. > Here is a link to my > bug report > Any suggestions? > > Thanks, > > Frank > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From alexander at knauth.org Thu Sep 25 18:15:50 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Thu, 25 Sep 2014 18:15:50 -0400 Subject: [racket] typed racket, filters, and polymorphism Message-ID: Do any of you have any advice for getting a function like this to type-check? #lang typed/racket (: check-int : (All (a) (case-> [a -> a] [Any -> Integer]))) (define (check-int int) (unless (exact-integer? int) (error 'check-int "expected Integer, given ~v" int)) int) ;. Type Checker: type mismatch ; expected: a ; given: Integer in: int -------------- next part -------------- An HTML attachment was scrubbed... URL: From mflatt at cs.utah.edu Thu Sep 25 18:16:15 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Thu, 25 Sep 2014 16:16:15 -0600 Subject: [racket] My DrRacket on Linux doesn't evaluate a thing In-Reply-To: References: <20140925215722.0D540650190@mail-svr1.cs.utah.edu> Message-ID: <20140925221616.B5B3665018E@mail-svr1.cs.utah.edu> Ok, so much for my guess... unless your keyboard is mapped in an unusual way. To rule that out completely, you could download https://raw.githubusercontent.com/plt/racket/stable/pkgs/gui-pkgs/gui-test/tests/gracket/showkey.rkt run it (assuming that the "Run" button works!), and make sure that the Enter key is reported as "\r". I expect that something else is happening, though, and I don't have another guess so far. At Fri, 26 Sep 2014 00:06:27 +0200, Frank Weytjens wrote: > Hi Matthew, > > I use the Enter from the main part of the keyboard. > > > > > > > 2014-09-25 23:57 GMT+02:00 Matthew Flatt : > > > After you type "(+ 1 1)", are you hitting the Enter key on the main > > part of the keyboard, or the one that's part of the numpad? > > > > If you're pressing the latter (the numpad Enter), then DrRacket doesn't > > evaluate the expression, and it instead lets you continue typing on the > > next line. If that's it, use the Enter key that's not in the numpad; > > the two keys are intentionally treated differently. > > > > At Thu, 25 Sep 2014 22:19:51 +0200, Frank Weytjens wrote: > > > Hi, > > > > > > My DrRacket doesn't evaluate any expression. > > > Here is a link > > to my > > > bug report > > > Any suggestions? > > > > > > Thanks, > > > > > > Frank > > > ____________________ > > > Racket Users list: > > > http://lists.racket-lang.org/users > > > > > > -- > Hazelarenlaan 34 bus 6 > 3500 Hasselt > +32484538321 From samth at cs.indiana.edu Thu Sep 25 18:19:37 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Thu, 25 Sep 2014 18:19:37 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: Message-ID: No, I don't think you can do this. Can you say more about what you're trying to accomplish? Sam On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth wrote: > Do any of you have any advice for getting a function like this to > type-check? > #lang typed/racket > > (: check-int : (All (a) (case-> [a -> a] > [Any -> Integer]))) > (define (check-int int) > (unless (exact-integer? int) > (error 'check-int "expected Integer, given ~v" int)) > int) > > ;. Type Checker: type mismatch > ; expected: a > ; given: Integer in: int > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From jay.mccarthy at gmail.com Thu Sep 25 18:26:58 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Thu, 25 Sep 2014 18:26:58 -0400 Subject: [racket] web server: module servlets In-Reply-To: <54247C41.1030408@comcast.net> References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> <5424482C.1030901@comcast.net> <54247C41.1030408@comcast.net> Message-ID: On Thu, Sep 25, 2014 at 4:34 PM, George Neuner wrote: > Hi Jay, > > On 9/25/2014 1:04 PM, Jay McCarthy wrote: > >> If a Racket library is deliberately put into the servlet-namespace, does >> that streamline linking? > > Your assumption about the purpose of this is not correct. Anything in > the servlet-namespace will be shared between all servlets, and thus > not loaded per-servlet. > > > I think you misunderstood my question, but you may have answered it anyway. > > What I really was asking was whether each custodian was having to > individually load common Racket libraries [ web-server/*, net/*, etc. ] for > a new servlet rather than all servlet custodians sharing libraries that are > already loaded. Or, if not actually "loading" the libraries, then having to > go to disk to check dependencies. > > So if I create a shared servlet namespace and put, e.g., > "web-server/servlet" into it, would that in any way speed up starting a new > dynamically loaded servlet? There is a very small set that is automatically shared: racket/base web-server/private/servlet web-server/http web-server/servlet/web ... web-server/servlet is NOT shared, nor is any net library or common racket library like racket/list. They are all totally unique per servlet. This, by the way, is part of why I don't recommend using dynamic servlets at all and suggest using serve/servlet. Jay -- Jay McCarthy 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&C 64:33 From gneuner2 at comcast.net Thu Sep 25 20:13:54 2014 From: gneuner2 at comcast.net (George Neuner) Date: Thu, 25 Sep 2014 20:13:54 -0400 Subject: [racket] [GENERAL] Off Topic: Anybody reading this via news.gmane.org? In-Reply-To: <5424A05A.9020809@aklaver.com> References: <54248425.90509@comcast.net> <5424A05A.9020809@aklaver.com> Message-ID: <5424AFC2.6020302@comcast.net> On 9/25/2014 5:26 PM, Neil Van Dyke wrote: > You can check your IP addr against the list at > "http://gmane.org/denied.php". > > Neil V. On 9/25/2014 7:08 PM, Adrian Klaver wrote: > > Take a look here: > > http://gmane.org/denied.php > > My guess is you are the fourth one from the bottom. > > > Might want to take a look at this thread to see what your options are > and what the turn around time is on your request: > > http://thread.gmane.org/gmane.discuss/16309 Thanks to both of you - I missed seeing the entry about the denied list in the FAQ. Adrian you were right - it seems that I have been blocked for some reason. Based on the description of infractions I really don't think I did anything to warrant it ... but there it is. I'll have to follow my lists by email until I can unblocked. Thanks again, George -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Thu Sep 25 21:42:00 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Thu, 25 Sep 2014 21:42:00 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: Message-ID: What I?m trying to accomplish is something more like this: #lang typed/racket (require "dimensions.rkt") (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent #:guard (lambda (name scalar dimension _) (unless (dimension? dimension) (error 'unit "expected Dimension, given ~v" dimension)) (values name scalar dimension))) (define-type (Unitof d) (unit d)) (define-type Unit (Unitof Dimension)) (define Unit? (make-predicate Unit)) (define-type Unitish (U (Unitof Any) Dimension Positive-Real)) (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] [Unitish -> Unit]))) (define (->unit u) (cond [(unit? u) (unless (Unit? u) ; this should never happen anyway because of the guard (error '->unit "expected (Unitof Dimension), given ~v" u)) u] [(dimension? u) (unit u 1 u)] [(positive-real? u) (unit u u dimensionless-dimension)])) On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt wrote: > No, I don't think you can do this. Can you say more about what you're > trying to accomplish? > > Sam > > On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth > wrote: >> Do any of you have any advice for getting a function like this to >> type-check? >> #lang typed/racket >> >> (: check-int : (All (a) (case-> [a -> a] >> [Any -> Integer]))) >> (define (check-int int) >> (unless (exact-integer? int) >> (error 'check-int "expected Integer, given ~v" int)) >> int) >> >> ;. Type Checker: type mismatch >> ; expected: a >> ; given: Integer in: int >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From gneuner2 at comcast.net Fri Sep 26 00:16:56 2014 From: gneuner2 at comcast.net (George Neuner) Date: Fri, 26 Sep 2014 00:16:56 -0400 Subject: [racket] web server: module servlets In-Reply-To: References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> <5424482C.1030901@comcast.net> <54247C41.1030408@comcast.net> Message-ID: <5424E8B8.8040501@comcast.net> On 9/25/2014 6:26 PM, Jay McCarthy wrote: > web-server/servlet is NOT shared, nor is any net library or common > racket library like racket/list. They are all totally unique per > servlet. > > This, by the way, is part of why I don't recommend using dynamic > servlets at all and suggest using serve/servlet. But ... IIUC ... a listener started by serve/servlet will still dynamically load from , /htdocs/*, etc. if the request doesn't match a hard coded dispatch URL - the regex of the initial servlet or an entry in a dispatcher table. At least that's the behavior I see with my own application: my initial servlet returns 404 when called - the call to serve/servlet just sets up the environment and and all the "real" servlets are demand loaded from disk when first touched. Are you advocating *static* linking and essentially just dispatching to internal functions by URL? ISTM that that defeats the purpose. George -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Fri Sep 26 12:07:19 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Fri, 26 Sep 2014 18:07:19 +0200 Subject: [racket] Tricky case of occurrence typing in Typed Racket Message-ID: <21541.36663.168649.25871@Konrad-Hinsens-MacBook-Pro-2.local> Hi everyone, I am trying to convince Typed Racket that after a run-time check on some list, its elements are all of a given type. This is just like occurrence typing based on a predicate, except that my predicate is more complicated. My first attempt was this: #lang typed/racket (struct: foo ()) (struct: bar ()) (define-type FooOrBar (U foo bar)) (: f-bar (-> (Listof bar) Void)) (define (f-bar xs) (void)) (: f-mixed (-> (Listof FooOrBar) Void)) (define (f-mixed xs) (void)) (: f (-> (Listof FooOrBar) Void)) (define (f xs) (if (for/and : Boolean ([x xs]) (bar? x)) (f-bar xs) ; contains only bars (f-mixed xs) ; may contain foos as well )) This yields a type error: ; /Users/hinsen/projects/racket/foobar.rkt:18:13: Type Checker: type mismatch ; expected: (Listof bar) ; given: (Listof FooOrBar) ; in: xs After reading section 5 of the Typed Racket Guide, in particular section 5.2 entitled "Filters and Predicates", I thought I could simply define my own predicate with a type annotation: #lang typed/racket (struct: foo ()) (struct: bar ()) (define-type FooOrBar (U foo bar)) (: f-bar (-> (Listof bar) Void)) (define (f-bar xs) (void)) (: f-mixed (-> (Listof FooOrBar) Void)) (define (f-mixed xs) (void)) (: pure-bars? (-> (Listof FooOrBar) Boolean : (Listof bar))) (define (pure-bars? xs) (for/and : Boolean ([x xs]) (bar? x))) (: f (-> (Listof FooOrBar) Void)) (define (f xs) (if (pure-bars? xs) (f-bar xs) ; contains only bars (f-mixed xs) ; may contain foos as well )) But this got me only into more trouble - now I don't even understand the error message any more: ; /Users/hinsen/projects/racket/foobar.rkt:17:2: Type Checker: type mismatch; ; mismatch in filter ; expected: (((Listof bar) @ xs) | (! (Listof bar) @ xs)) ; given: (Top | Top) ; in: (for/and : Boolean ((x xs)) (bar? x)) Is there a way to do this kind of test? Konrad. From amk.kent at gmail.com Fri Sep 26 12:12:29 2014 From: amk.kent at gmail.com (Andrew Kent) Date: Fri, 26 Sep 2014 12:12:29 -0400 Subject: [racket] Tricky case of occurrence typing in Typed Racket In-Reply-To: <21541.36663.168649.25871@Konrad-Hinsens-MacBook-Pro-2.local> References: <21541.36663.168649.25871@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: Will andmap work for you? (struct: foo ()) (struct: bar ()) (define-type FooOrBar (U foo bar)) (: f-bar (-> (Listof bar) Void)) (define (f-bar xs) (void)) (: f-mixed (-> (Listof FooOrBar) Void)) (define (f-mixed xs) (void)) (: f (-> (Listof FooOrBar) Void)) (define (f xs) (if (andmap bar? xs) (f-bar xs) ; contains only bars (f-mixed xs) ; may contain foos as well )) On Fri, Sep 26, 2014 at 12:07 PM, Konrad Hinsen wrote: > Hi everyone, > > I am trying to convince Typed Racket that after a run-time check on > some list, its elements are all of a given type. This is just like > occurrence typing based on a predicate, except that my predicate > is more complicated. > > My first attempt was this: > > > #lang typed/racket > > (struct: foo ()) > (struct: bar ()) > (define-type FooOrBar (U foo bar)) > > (: f-bar (-> (Listof bar) Void)) > (define (f-bar xs) > (void)) > > (: f-mixed (-> (Listof FooOrBar) Void)) > (define (f-mixed xs) > (void)) > > (: f (-> (Listof FooOrBar) Void)) > (define (f xs) > (if (for/and : Boolean ([x xs]) (bar? x)) > (f-bar xs) ; contains only bars > (f-mixed xs) ; may contain foos as well > )) > > This yields a type error: > > ; /Users/hinsen/projects/racket/foobar.rkt:18:13: Type Checker: type > mismatch > ; expected: (Listof bar) > ; given: (Listof FooOrBar) > ; in: xs > > After reading section 5 of the Typed Racket Guide, in particular section > 5.2 entitled "Filters and Predicates", I thought I could simply define my > own predicate with a type annotation: > > #lang typed/racket > > (struct: foo ()) > (struct: bar ()) > (define-type FooOrBar (U foo bar)) > > (: f-bar (-> (Listof bar) Void)) > (define (f-bar xs) > (void)) > > (: f-mixed (-> (Listof FooOrBar) Void)) > (define (f-mixed xs) > (void)) > > (: pure-bars? (-> (Listof FooOrBar) Boolean : (Listof bar))) > (define (pure-bars? xs) > (for/and : Boolean ([x xs]) (bar? x))) > > (: f (-> (Listof FooOrBar) Void)) > (define (f xs) > (if (pure-bars? xs) > (f-bar xs) ; contains only bars > (f-mixed xs) ; may contain foos as well > )) > > But this got me only into more trouble - now I don't even understand the > error message any more: > > ; /Users/hinsen/projects/racket/foobar.rkt:17:2: Type Checker: type > mismatch; > ; mismatch in filter > ; expected: (((Listof bar) @ xs) | (! (Listof bar) @ xs)) > ; given: (Top | Top) > ; in: (for/and : Boolean ((x xs)) (bar? x)) > > Is there a way to do this kind of test? > > Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Fri Sep 26 12:28:03 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Fri, 26 Sep 2014 18:28:03 +0200 Subject: [racket] Tricky case of occurrence typing in Typed Racket In-Reply-To: References: <21541.36663.168649.25871@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: <21541.37907.627925.114871@Konrad-Hinsens-MacBook-Pro-2.local> Andrew Kent writes: > Will andmap work for you? Interesting... I didn't know about that one. For my demonstration code, that's indeed a good solution. In my real application, the test is more complicated. I need to check all elements of a list for conformance to a union type, so I have no prefabricated predicate, not even for the elements of my list. Konrad. From amk.kent at gmail.com Fri Sep 26 12:48:05 2014 From: amk.kent at gmail.com (Andrew Kent) Date: Fri, 26 Sep 2014 12:48:05 -0400 Subject: [racket] Tricky case of occurrence typing in Typed Racket In-Reply-To: <21541.37907.627925.114871@Konrad-Hinsens-MacBook-Pro-2.local> References: <21541.36663.168649.25871@Konrad-Hinsens-MacBook-Pro-2.local> <21541.37907.627925.114871@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: Does using andmap with the custom predicates you alluded to for that union you mentioned work? Something like this perhaps?: #lang typed/racket (struct: T1 ()) (struct: T2 ()) (define-type T1or2 (U T1 T2)) (: T1or2? (-> Any Boolean : T1or2)) (define (T1or2? a) (or (T1? a) (T2? a))) (: listof-T1or2 (-> Any Boolean : (Listof T1or2))) (define (listof-T1or2 l) (and (list? l) (andmap T1or2? l))) On Fri, Sep 26, 2014 at 12:28 PM, Konrad Hinsen wrote: > Andrew Kent writes: > > > Will andmap work for you? > > Interesting... I didn't know about that one. > > For my demonstration code, that's indeed a good solution. In my real > application, the test is more complicated. I need to check all > elements of a list for conformance to a union type, so I have no > prefabricated predicate, not even for the elements of my list. > > Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michaelsbradleyjr at gmail.com Fri Sep 26 14:15:31 2014 From: michaelsbradleyjr at gmail.com (Michael =?utf-8?b?QnJhZGxleSw=?= Jr.) Date: Fri, 26 Sep 2014 18:15:31 +0000 (UTC) Subject: [racket] =?utf-8?q?ANN=3A_DOS=2C=09Delimited-continuation-based_O?= =?utf-8?q?perating-system_Simulator?= References: Message-ID: Jay McCarthy writes: > > I've just released the game architecture library I talked about in > part 2 of my RacketCon talk. > > The big picture of this library is to make World-style programs more > compositional by (a) using continuations to hide the internal state > (including control state) of components and (b) using environments as > a standard monoid-based inter-component communication channel. A > monoid is used to ensure that the components can be evaluated in any > order. Despite assumptions some have about continuations and pure > functional programming, it is incredibly efficient and can run at > 60FPS, as demonstrated in get-bonus. > > You can get it with > > raco pkg install dos > > And you can try out the demo with > > racket -l dos/examples/win > > The demo source is a bare 39 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt > > and I provide the non-DOS version for comparison: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt > > The core library has a mere 36 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt > Hi Jay, I really enjoyed your talk on get-bonus at RacketCon last weekend, and appreciate your sharing DOS with all of us. Also, your presentation at Strange Loop 2013 was my first introduction to delimited continuations in Racket! I have benefited from a number of your blog posts in the past, e.g. the one on an improved threading macro, and was wondering if you would consider doing a write-up on DOS? Best regards, -- Michael Bradley, Jr. @michaelsbradley From alexander at knauth.org Fri Sep 26 19:35:24 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Fri, 26 Sep 2014 19:35:24 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: Message-ID: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352@knauth.org> Is it possible to have a struct that does certain things according to the guard? #lang typed/racket (struct (a) foo ([a : a]) #:transparent #:guard (lambda (a _) (unless (exact-integer? a) (error 'foo "expected Integer, given ~v" a)) a)) (ann (foo (ann 1 Any)) (foo Integer)) (: x : (foo Any)) (define x (foo 1)) (ann (foo-a x) Integer) ;. Type Checker: Polymorphic function `foo1' could not be applied to arguments: ;Argument 1: ; Expected: a ; Given: Any ; ;Result type: (foo a) ;Expected result: (foo Integer) ; in: (foo (ann 1 Any)) ;. Type Checker: Polymorphic function `foo-a' could not be applied to arguments: ;Argument 1: ; Expected: (foo a) ; Given: (foo Any) ; ;Result type: (a : ....) ;Expected result: Integer ; in: (foo-a x) On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth wrote: > What I?m trying to accomplish is something more like this: > #lang typed/racket > > (require "dimensions.rkt") > > (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent > #:guard (lambda (name scalar dimension _) > (unless (dimension? dimension) > (error 'unit "expected Dimension, given ~v" dimension)) > (values name scalar dimension))) > > (define-type (Unitof d) (unit d)) > > (define-type Unit (Unitof Dimension)) > > (define Unit? (make-predicate Unit)) > > (define-type Unitish > (U (Unitof Any) > Dimension > Positive-Real)) > > (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] > [Unitish -> Unit]))) > (define (->unit u) > (cond [(unit? u) > (unless (Unit? u) ; this should never happen anyway because of the guard > (error '->unit "expected (Unitof Dimension), given ~v" u)) > u] > [(dimension? u) (unit u 1 u)] > [(positive-real? u) (unit u u dimensionless-dimension)])) > > > On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt wrote: > >> No, I don't think you can do this. Can you say more about what you're >> trying to accomplish? >> >> Sam >> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >> wrote: >>> Do any of you have any advice for getting a function like this to >>> type-check? >>> #lang typed/racket >>> >>> (: check-int : (All (a) (case-> [a -> a] >>> [Any -> Integer]))) >>> (define (check-int int) >>> (unless (exact-integer? int) >>> (error 'check-int "expected Integer, given ~v" int)) >>> int) >>> >>> ;. Type Checker: type mismatch >>> ; expected: a >>> ; given: Integer in: int >>> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.mccarthy at gmail.com Fri Sep 26 20:03:57 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Fri, 26 Sep 2014 20:03:57 -0400 Subject: [racket] ANN: DOS, Delimited-continuation-based Operating-system Simulator In-Reply-To: References: Message-ID: Sure, I can make a post about it. However, the core idea is already in this post: http://jeapostrophe.github.io/2012-07-12-cont-sys-post.html I can make another one, however, to rehash it and talk about the benefits of monoid states. Jay On Fri, Sep 26, 2014 at 2:15 PM, Michael Bradley, Jr. wrote: > Jay McCarthy writes: > >> >> I've just released the game architecture library I talked about in >> part 2 of my RacketCon talk. >> >> The big picture of this library is to make World-style programs more >> compositional by (a) using continuations to hide the internal state >> (including control state) of components and (b) using environments as >> a standard monoid-based inter-component communication channel. A >> monoid is used to ensure that the components can be evaluated in any >> order. Despite assumptions some have about continuations and pure >> functional programming, it is incredibly efficient and can run at >> 60FPS, as demonstrated in get-bonus. >> >> You can get it with >> >> raco pkg install dos >> >> And you can try out the demo with >> >> racket -l dos/examples/win >> >> The demo source is a bare 39 lines: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt >> >> and I provide the non-DOS version for comparison: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt >> >> The core library has a mere 36 lines: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt >> > > > > Hi Jay, > > I really enjoyed your talk on get-bonus at RacketCon last weekend, and > appreciate your sharing DOS with all of us. Also, your presentation at > Strange Loop 2013 was my first introduction to delimited continuations in > Racket! > > I have benefited from a number of your blog posts in the past, e.g. the one > on an improved threading macro, and was wondering if you would consider > doing a write-up on DOS? > > Best regards, > > -- > Michael Bradley, Jr. > @michaelsbradley > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From jay.mccarthy at gmail.com Fri Sep 26 20:08:30 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Fri, 26 Sep 2014 20:08:30 -0400 Subject: [racket] web server: module servlets In-Reply-To: <5424E8B8.8040501@comcast.net> References: <5421DB30.3030803@comcast.net> <54221C2D.9020109@comcast.net> <5424482C.1030901@comcast.net> <54247C41.1030408@comcast.net> <5424E8B8.8040501@comcast.net> Message-ID: Hi George, I suggest that all Racket web-server apps not use the dynamic features of serve/servlet either, but instead write the servlet as the single "request -> response" function that serve/servlet provides. This would ensure that all the libraries are loaded the one time and has the best performance out of all the options of the Web server. Furthermore, there are many features (such as total URL control) that are only available in this model. In case it is not completely clear, here's a little example (<500 lines) of a Web application that works this way: https://github.com/plt/racket/blob/master/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt#L423 Here's another that uses 'serve' directly for non-servlet needs: https://github.com/jeapostrophe/exp/blob/master/dir-serve.rkt And here's a considerably longer one: https://github.com/jeapostrophe/grade-samurai/blob/master/app.rkt#L2020 I highly recommend using serve/servlet like this over any other options. In particular, many of the problems you're talking about were the reason that I made serve/servlet in the first place. Jay On Fri, Sep 26, 2014 at 12:16 AM, George Neuner wrote: > On 9/25/2014 6:26 PM, Jay McCarthy wrote: > > web-server/servlet is NOT shared, nor is any net library or common > racket library like racket/list. They are all totally unique per > servlet. > > This, by the way, is part of why I don't recommend using dynamic > servlets at all and suggest using serve/servlet. > > > But ... IIUC ... a listener started by serve/servlet will still > dynamically load from , /htdocs/*, etc. if the > request doesn't match a hard coded dispatch URL - the regex of the initial > servlet or an entry in a dispatcher table. At least that's the behavior I > see with my own application: my initial servlet returns 404 when called - > the call to serve/servlet just sets up the environment and and all the > "real" servlets are demand loaded from disk when first touched. > > Are you advocating *static* linking and essentially just dispatching to > internal functions by URL? ISTM that that defeats the purpose. > > George -- Jay McCarthy 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&C 64:33 From acarrico at memebeam.org Fri Sep 26 23:07:55 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Fri, 26 Sep 2014 23:07:55 -0400 Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> Message-ID: <54262A0B.2010901@memebeam.org> Dredging up an old thread: So how exactly do you define custom-write for a typed racket struct? On 05/25/2014 03:30 PM, Alexander D. Knauth wrote: > Never mind I just found prop:dict. > > By the way it would probably be helpful if instead of the value for > prop:dict being a vector, it was a hash table with the method names > as the keys, so then it would be a lot easier to tell which procedure > goes with which method, and also a lot easier to extend it while > maintaining backwards compatibility. > > On May 24, 2014, at 10:38 PM, Alexander D. Knauth > wrote: > >> Do generic interfaces work using structure type properties, and if >> they do, is there a way to use generic interfaces through >> properties so that I can do it in typed racket? >> >> Specifically I?m trying to use the gen:custom-write and gen:dict >> generic interfaces. I can use prop:custom-write for the first one, >> but I don?t know what to do for gen:dict. >> >> Otherwise I?ll just put it in an untyped submodule. -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From martindemello at gmail.com Sat Sep 27 00:56:52 2014 From: martindemello at gmail.com (Martin DeMello) Date: Fri, 26 Sep 2014 21:56:52 -0700 Subject: [racket] "do what i mean" for https://github links Message-ID: It took me a while of reading through the docs to figure out why trying to install a package via "https://github.com/user/pkg" failed for want of a MANIFEST file. I think the "do what I mean" installer should have autoconverted it to git:// , seeing as how github is already special-cased. (Also my first try of installing via the git clone url https://github.com/user/pkg.git should ideally have been supported too, since that's what github encourages you to copy/paste as a reference) martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From spencerflorence at gmail.com Sat Sep 27 01:07:43 2014 From: spencerflorence at gmail.com (Spencer florence) Date: Fri, 26 Sep 2014 22:07:43 -0700 (PDT) Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> Message-ID: <1411794462639.6720ba81@Nodemailer> I don?t think you can. You would need define the struct in an untyped module then require it via require/typed. This is why dict?s don?t work in typed/racket either. On Sat, May 24, 2014 at 9:39 PM, Alexander D. Knauth wrote: > Do generic interfaces work using structure type properties, and if they do, is there a way to use generic interfaces through properties so that I can do it in typed racket? > Specifically I?m trying to use the gen:custom-write and gen:dict generic interfaces. I can use prop:custom-write for the first one, but I don?t know what to do for gen:dict. > Otherwise I?ll just put it in an untyped submodule. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From martindemello at gmail.com Sat Sep 27 03:27:29 2014 From: martindemello at gmail.com (Martin DeMello) Date: Sat, 27 Sep 2014 00:27:29 -0700 Subject: [racket] problem with pict->bitmap and mrlib/write-animated-gif Message-ID: Can't figure it out, but something in the interaction between pict->bitmap and write-animated-gif is causing the frames to display one on top of the other when viewing the gif. #lang racket (require pict mrlib/gif) (define (draw-frame i) (pict->bitmap (circle (* 50 i)))) (write-animated-gif (map draw-frame (sequence->list (in-range 1 10))) 10 "test1.gif" #:loop? true #:one-at-a-time? true) martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From richter at math.northwestern.edu Sat Sep 27 03:38:48 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sat, 27 Sep 2014 02:38:48 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap Message-ID: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> I have a few questions that might be off-topic. Are you interested in formal proofs? Have you considered adapting DrRacket to give an integrated editor for a proof assistant? The proof assistants Coq and Isabelle use jedit and ProofGeneral, which I think aren't nearly as nice as DrRacket. I actually use HOL Light, which nobody uses an integrated editor for. Here are the slides for a talk I gave at the Institut Henri Poincar? in the workshop ``Formalization of mathematics in proof assistants'' http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf HOL Light and Coq are written in OCaml, a dialect of ML, which is therefore similar to Scheme, but it has one difference that I wonder if anyone here's knows how to deal with. Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? -- Best, Bill From robby at eecs.northwestern.edu Sat Sep 27 08:38:54 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Sat, 27 Sep 2014 07:38:54 -0500 Subject: [racket] Fwd: JFP CFP In-Reply-To: References: Message-ID: If you're working on parallel or concurrent programming, consider submitting! Robby ------------------------------------------------------------------------------ CALL FOR PAPERS JFP Special Issue on Parallel and Concurrent Programming Submission Deadline: 22 December 2014 Expected Publication Date: November/December issue 2015 * Scope Functional languages are uniquely suited to provide programmers with a programming model for parallel and concurrent computing. This is reflected in the wide range of work that is currently underway, both on parallel and concurrent functional languages, but also on bringing functional language features to other programming languages. This has resulted in a rapidly growing number of practical applications. The Journal of Functional Programming will devote a special issue to functional programming for concurrent and parallel computing. The purpose of this special issue is to showcase the state of the art on how functional languages and functional concepts currently assist programmers with the task of managing the challenges of creating parallel and concurrent systems. Language designers as well as systems builders and application programmers are invited to submit papers describing the current state of the art of language support and experiences with functional programming in building real-world systems. We encourage the submission of consolidated, condensed and extended work based on prior conference and workshop publications. * Submission Details Manuscripts should be submitted to CUP's Manuscript Central formatted according to JFP's standards. Authors should specify in their cover message that the paper is intended for the special issue and choose the appropriate desired editor from the menu. For submission and formatting details, please consult the Journal of Functional Programming [ http://bit.ly/jfpadvice ] website. Guest Editors --------------------------------------------------------------------------------- Gabriele Keller Fritz Henglein keller @cse.unsw.edu.au henglein at diku.dk School of Computer Science & Engineering Department of Computer Science (DIKU) UNSW Sydney NSW 2052 University of Copenhagen and Universitetsparken 5 The Software Systems Research Group@ NICTA DK-2100 Copenhagen Australia Denmark --------------------------------------------------------------------------------- From alexander at knauth.org Sat Sep 27 09:49:48 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sat, 27 Sep 2014 09:49:48 -0400 Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: <54262A0B.2010901@memebeam.org> References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> <54262A0B.2010901@memebeam.org> Message-ID: <39AEBCAD-6138-4FE6-84A5-6AFF1A1A466C@knauth.org> Like this, I think: (but for some reason it seems to print it 3 times?) #lang typed/racket (struct foo () #:transparent #:property prop:custom-write (lambda (this out mode) (displayln "whatever"))) (print (foo)) On Sep 26, 2014, at 11:07 PM, Anthony Carrico wrote: > Dredging up an old thread: So how exactly do you define custom-write for > a typed racket struct? > > On 05/25/2014 03:30 PM, Alexander D. Knauth wrote: >> Never mind I just found prop:dict. >> >> By the way it would probably be helpful if instead of the value for >> prop:dict being a vector, it was a hash table with the method names >> as the keys, so then it would be a lot easier to tell which procedure >> goes with which method, and also a lot easier to extend it while >> maintaining backwards compatibility. >> >> On May 24, 2014, at 10:38 PM, Alexander D. Knauth >> wrote: >> >>> Do generic interfaces work using structure type properties, and if >>> they do, is there a way to use generic interfaces through >>> properties so that I can do it in typed racket? >>> >>> Specifically I?m trying to use the gen:custom-write and gen:dict >>> generic interfaces. I can use prop:custom-write for the first one, >>> but I don?t know what to do for gen:dict. >>> >>> Otherwise I?ll just put it in an untyped submodule. > > -- > Anthony Carrico > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From plragde at uwaterloo.ca Sat Sep 27 10:33:15 2014 From: plragde at uwaterloo.ca (Prabhakar Ragde) Date: Sat, 27 Sep 2014 10:33:15 -0400 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> Message-ID: <5426CAAB.2010400@uwaterloo.ca> > I have a few questions that might be off-topic. Are you interested > in formal proofs? Have you considered adapting DrRacket to give an > integrated editor for a proof assistant? The proof assistants Coq > and Isabelle use jedit and ProofGeneral, which I think aren't nearly > as nice as DrRacket. I actually use HOL Light, which nobody uses an > integrated editor for. Here are the slides for a talk I gave at the > Institut Henri Poincar? in the workshop ``Formalization of > mathematics in proof assistants'' > http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf I am teaching a grad course using Coq right now, and using Proof General within Emacs for it. That is not bad, but I would love to have a DrRacket interface. I know something like this is possible, because at Brown they used DrRacket to prepare and run OCaml programs, a few years ago. I really don't have the time to work on this, though. (And if I did, I would first work on teaching language subsets of Haskell, which I also would like to have inside DrRacket.) > HOL Light and Coq are written in OCaml, a dialect of ML, which is > therefore similar to Scheme, but it has one difference that I wonder > if anyone here's knows how to deal with. Scheme is well-suited for > writing a Scheme interpreter, because of the quote feature. OCaml > doesn't have a quote feature, so the question arises how to write an > OCaml interpreter inside OCaml. That's not quite what I want to do, > but if anyone could explain how to do it, I'd be grateful. In my senior undergraduate programming language course, I have them write various interpreters and typecheckers in various languages, including Racket, OCaml, and Haskell. In the latter two, you need to use algebraic datatypes to build an abstract syntax tree, and interpret that. So the expression (* (+ 1 2) (- 3 4)) might become (Mult (Plus (Num 1) (Num 2)) (Minus (Num 3) (Num 4))) Writing an interpreter for such an AST is even easier than in Racket/Scheme, due to concise pattern-matching syntax. But parsing an expression written in faux OCaml/Haskell is quite complicated. I don't ask students to do that, since it really is part of a separate course (both languages come with general parsing tools that can be used). Parsing is much easier in Racket/Scheme because of the similarity of code/data and the presence of 'read'. > I have a 7th grade student I'm trying to teach Racket, and I'm a bit > confused about Bootstrap and Program By Design. Is there any reason > for my student not to just read HtDP? You should view word from the authors/developers as definitive, but I would say that if your student has good algebraic skills, then using HtDP/2e is the right path. If not, Bootstrap may be a way to help develop those skills. --PR From alexander at knauth.org Sat Sep 27 13:55:12 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sat, 27 Sep 2014 13:55:12 -0400 Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: <1411794462639.6720ba81@Nodemailer> References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> <1411794462639.6720ba81@Nodemailer> Message-ID: <38E7C628-8FA0-4F07-ABAD-E271E2A66426@knauth.org> Actually using prop:dict works (I hadn?t found prop:dict yet when I first asked this) #lang typed/racket (define-type Dict-Ref ([Dict Any] [Any] . ->* . Any)) (define-type Dict-Set! (Dict Any Any . -> . Void)) (define-type Dict-Set (Dict Any Any . -> . Dict)) (define-type Dict-Remove! (Dict Any . -> . Void)) (define-type Dict-Remove (Dict Any . -> . Dict)) (define-type Dict-Iterate-First (Dict . -> . Any)) (define-type Dict-Iterate-Next (Dict Any . -> . Any)) (define-type Dict-Iterate-Key (Dict Any . -> . Any)) (define-type Dict-Iterate-Value (Dict Any . -> . Any)) (define-type Dict-Count (Dict . -> . Natural)) (require/typed racket/dict [#:opaque Dict dict?] [dict-ref Dict-Ref] [dict-set! Dict-Set!] [dict-set Dict-Set] [dict-remove! Dict-Remove!] [dict-remove Dict-Remove] [dict-iterate-first Dict-Iterate-First] [dict-iterate-next Dict-Iterate-Next] [dict-iterate-key Dict-Iterate-Key] [dict-iterate-value Dict-Iterate-Value] [dict-count Dict-Count] [prop:dict Struct-Type-Property]) (define (make-dict-prop #:dict-ref [dict-ref : Dict-Ref] #:dict-set! [dict-set! : (U Dict-Set! #f) #f] #:dict-set [dict-set : (U Dict-Set #f) #f] #:dict-remove! [dict-remove! : (U Dict-Remove! #f) #f] #:dict-remove [dict-remove : (U Dict-Remove #f) #f] #:dict-count [dict-count : Dict-Count] #:dict-iterate-first [dict-iterate-first : Dict-Iterate-First] #:dict-iterate-next [dict-iterate-next : Dict-Iterate-Next] #:dict-iterate-key [dict-iterate-key : Dict-Iterate-Key] #:dict-iterate-value [dict-iterate-value : Dict-Iterate-Value]) (vector-immutable dict-ref dict-set! dict-set dict-remove! dict-remove dict-count dict-iterate-first dict-iterate-next dict-iterate-key dict-iterate-value)) (struct foo () #:transparent #:property prop:dict (make-dict-prop #:dict-ref (lambda (this key [failure #f]) "whatever") #:dict-count (lambda (this) 0) #:dict-iterate-first (lambda (this) #f) #:dict-iterate-next (lambda (this pos) 0) #:dict-iterate-key (lambda (this pos) pos) #:dict-iterate-value (lambda (this pos) "whatever"))) (dict-ref (assert (foo) dict?) "idontkare") On Sep 27, 2014, at 1:07 AM, Spencer florence wrote: > I don?t think you can. You would need define the struct in an untyped module then require it via require/typed. This is why dict?s don?t work in typed/racket either. > > > > On Sat, May 24, 2014 at 9:39 PM, Alexander D. Knauth wrote: > > Do generic interfaces work using structure type properties, and if they do, is there a way to use generic interfaces through properties so that I can do it in typed racket? > > Specifically I?m trying to use the gen:custom-write and gen:dict generic interfaces. I can use prop:custom-write for the first one, but I don?t know what to do for gen:dict. > > Otherwise I?ll just put it in an untyped submodule. > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ianj at ccs.neu.edu Sat Sep 27 16:09:09 2014 From: ianj at ccs.neu.edu (J. Ian Johnson) Date: Sat, 27 Sep 2014 16:09:09 -0400 (EDT) Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> Message-ID: <28884853.169131411848549503.JavaMail.root@zimbra> To answer the first part of your email, yes. Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem prover. -Ian ----- Original Message ----- From: Bill Richter To: users at racket-lang.org Sent: Sat, 27 Sep 2014 03:38:48 -0400 (EDT) Subject: [racket] proof assistants, DrRacket and Bootstrap I have a few questions that might be off-topic. Are you interested in formal proofs? Have you considered adapting DrRacket to give an integrated editor for a proof assistant? The proof assistants Coq and Isabelle use jedit and ProofGeneral, which I think aren't nearly as nice as DrRacket. I actually use HOL Light, which nobody uses an integrated editor for. Here are the slides for a talk I gave at the Institut Henri Poincar? in the workshop ``Formalization of mathematics in proof assistants'' http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf HOL Light and Coq are written in OCaml, a dialect of ML, which is therefore similar to Scheme, but it has one difference that I wonder if anyone here's knows how to deal with. Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? -- Best, Bill ____________________ Racket Users list: http://lists.racket-lang.org/users From norman at astro.gla.ac.uk Sat Sep 27 16:14:55 2014 From: norman at astro.gla.ac.uk (Norman Gray) Date: Sat, 27 Sep 2014 21:14:55 +0100 Subject: [racket] aws/glacier: credential scope Message-ID: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Greetings. I'm trying to use the aws/glacier package, and running into a problem where I'm being told: Credential should be scoped to a valid region, not 'eu-west-1' I'm following the instructions at My test code is: % cat glacier.rkt #lang racket/base (require aws/glacier aws/keys) (define vault "testvault") (region "eu-west-1") (read-keys "aws-zbu-credentials") ; local file (module+ main (printf "region=~a~%" (region)) (printf "Vaults: ~s~%" (list-vaults)) (printf "...specifically: ~s~%" (describe-vault vault))) Running this produces: % racket glacier.rkt region=eu-west-1 aws: HTTP/1.1 403 Forbidden x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 Content-Type: application/json Content-Length: 129 Date: Sat, 27 Sep 2014 18:35:50 GMT {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " context...: check-response /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 request/redirect/uri (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] Things I thought of: * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? Thanks for any pointers. All the best, Norman -- Norman Gray : http://nxg.me.uk SUPA School of Physics and Astronomy, University of Glasgow, UK From richter at math.northwestern.edu Sat Sep 27 17:08:49 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sat, 27 Sep 2014 16:08:49 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <28884853.169131411848549503.JavaMail.root@zimbra> (ianj@ccs.neu.edu) References: <28884853.169131411848549503.JavaMail.root@zimbra> Message-ID: <201409272108.s8RL8nqh030467@poisson.math.northwestern.edu> Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem prover. Thanks, Ian! May I suggest that you try to handle Coq, Isabelle or HOL Light? I believe these are the foremost proof assistants. The fields medalist Vladimir Voevodsky uses Coq, in which the 4-color theorem and the Feit-Thompson theorem was formalized by Georges Gonthier. Tom Hales just finished formalizing his proof of Kepler conjecture in HOL Light and Isabelle (which is HOL as well). I'm no expert, but I think that ACL2 (also Prover9) is an FOL prover, and the bulk of activity in formal proofs uses type theories. HOL is simple, it's Church's simple types (a version of the Lambda Calculus), and Coq uses a much more complicated type theory. -- Best, Bill From richter at math.northwestern.edu Sat Sep 27 17:50:11 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sat, 27 Sep 2014 16:50:11 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <5426CAAB.2010400@uwaterloo.ca> (message from Prabhakar Ragde on Sat, 27 Sep 2014 10:33:15 -0400) References: <5426CAAB.2010400@uwaterloo.ca> Message-ID: <201409272150.s8RLoBQW030663@poisson.math.northwestern.edu> Thanks, Prabhakar, this is exactly what I wanted, and you know something about it (I was barely able to install Coq): I am teaching a grad course using Coq right now, and using Proof General within Emacs for it. That is not bad, but I would love to have a DrRacket interface. > OCaml doesn't have a quote feature, so the question arises how to > write an OCaml interpreter inside OCaml. In my senior undergraduate programming language course, I have them write various interpreters and typecheckers in various languages, including Racket, OCaml, and Haskell. [...] I know this is way off-topic, but it seems to me that Schemers are the only people who want an elegant solution here: But parsing an expression written in faux OCaml/Haskell is quite complicated. [...] Parsing is much easier in Racket/Scheme because of the similarity of code/data and the presence of 'read'. I think it's a parsing question I'm stuck on. I think I need to use camlp to avoid the following hack/kludge which I learned from the HOL Light experts, found in my file hol_light/RichterHilbertAxiomGeometry/readable.ml which is part of the HOL Light distribution: (* From update_database.ml: Execute any OCaml expression given as a string. *) let exec = ignore o Toploop.execute_phrase false Format.std_formatter o !Toploop.parse_toplevel_phrase o Lexing.from_string;; (* Following miz3.ml, exec_thm returns the theorem representing a string, so *) (* exec_thm "FORALL_PAIR_THM";; returns *) (* val it : thm = |- !P. (!p. P p) <=> (!p1 p2. P (p1,p2)) *) let thm_ref = ref TRUTH;; let exec_thm s = if Str.string_match (Str.regexp "[^;]*;") s 0 then raise Noparse else try exec ("thm_ref := (("^ s ^"): thm);;"); !thm_ref with _ -> raise Noparse;; When I posted my question on the OCaml list, the experts said don't ever use Obj.magic, but I think they didn't think much of me using Toploop either. -- Best, Bill From plragde at uwaterloo.ca Sat Sep 27 18:00:24 2014 From: plragde at uwaterloo.ca (Prabhakar Ragde) Date: Sat, 27 Sep 2014 18:00:24 -0400 Subject: [racket] proof assistants, DrRacket and Bootstrap Message-ID: <54273378.1070605@uwaterloo.ca> Bill Richter wrote: > >Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem > >prover. > > Thanks, Ian! May I suggest that you try to handle Coq, Isabelle or > HOL Light? I believe these are the foremost proof assistants. The > fields medalist Vladimir Voevodsky uses Coq, in which the 4-color > theorem and the Feit-Thompson theorem was formalized by Georges > Gonthier. Tom Hales just finished formalizing his proof of Kepler > conjecture in HOL Light and Isabelle (which is HOL as well). I'm no > expert, but I think that ACL2 (also Prover9) is an FOL prover, and > the bulk of activity in formal proofs uses type theories. HOL is > simple, it's Church's simple types (a version of the Lambda > Calculus), and Coq uses a much more complicated type theory. I'm sorry, I forgot about Carl's Dracula work when composing my earlier reply. ACL2 is more limited, but its advantage (besides being probably far and away the theorem prover that has had the most industrial impact) is that its language (Applicative Common Lisp, hence the acronym) is much closer to Racket, allowing for stronger integration both with DrRacket and into a Racket-based curriculum. A DrRacket interface to Coq or Isabelle would, in contrast, be more superficial, in the style of Proof General. --PR From richter at math.northwestern.edu Sat Sep 27 18:26:44 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sat, 27 Sep 2014 17:26:44 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <54273378.1070605@uwaterloo.ca> (message from Prabhakar Ragde on Sat, 27 Sep 2014 18:00:24 -0400) References: <54273378.1070605@uwaterloo.ca> Message-ID: <201409272226.s8RMQiEM030897@poisson.math.northwestern.edu> ACL2 [is] probably far and away the theorem prover that has had the most industrial impact Interesting, Prabhakar! I had not heard that before. A DrRacket interface to Coq or Isabelle would, in contrast, be more superficial, in the style of Proof General. I think so, but interfaces are really important, and DrRacket has a beautiful interface. -- Best, Bill From martindemello at gmail.com Sat Sep 27 18:46:25 2014 From: martindemello at gmail.com (Martin DeMello) Date: Sat, 27 Sep 2014 15:46:25 -0700 Subject: [racket] problem with pict->bitmap and mrlib/write-animated-gif In-Reply-To: References: Message-ID: Solved, with help from Jens Soegaard; I had to modify mrlib/write-gifs to take a disposal argument, and use it in all calls to gif-add-control. martin On Sat, Sep 27, 2014 at 12:27 AM, Martin DeMello wrote: > Can't figure it out, but something in the interaction between pict->bitmap > and write-animated-gif is causing the frames to display one on top of the > other when viewing the gif. > > #lang racket > > (require pict > mrlib/gif) > > (define (draw-frame i) > (pict->bitmap (circle (* 50 i)))) > > (write-animated-gif > (map draw-frame (sequence->list (in-range 1 10))) > 10 > "test1.gif" > #:loop? true > #:one-at-a-time? true) > > martin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From plragde at uwaterloo.ca Sat Sep 27 18:54:56 2014 From: plragde at uwaterloo.ca (Prabhakar Ragde) Date: Sat, 27 Sep 2014 18:54:56 -0400 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <201409272150.s8RLoBQW030663@poisson.math.northwestern.edu> References: <5426CAAB.2010400@uwaterloo.ca> <201409272150.s8RLoBQW030663@poisson.math.northwestern.edu> Message-ID: <54274040.5070902@uwaterloo.ca> On 2014-09-27, 5:50 PM, Bill Richter wrote: > Thanks, Prabhakar, this is exactly what I wanted, and you know something about it (I was barely able to install Coq): I struggled with installing it also, especially since I'm using a Mac. Racket has spoiled us in that respect. > But parsing an expression written in faux OCaml/Haskell is quite > complicated. [...] Parsing is much easier in Racket/Scheme because > of the similarity of code/data and the presence of 'read'. > > I think it's a parsing question I'm stuck on. I think I need to use camlp to avoid the following hack/kludge which I learned from the HOL Light experts, found in my file > hol_light/RichterHilbertAxiomGeometry/readable.ml > which is part of the HOL Light distribution: > > (* From update_database.ml: Execute any OCaml expression given as a string. *) I don't have enough practice in OCaml to grasp what your code does (and, yes, it is way off-topic), but I do know that about once every month or two, someone posts to this list about using 'eval' in Racket, and they are warned not to use it unless they really know what they are doing and have a suitable application (which is rare). That warning probably is doubled in a statically-typed language, in which 'eval' should not even be possible without subverting the type system (I gather this is what you are doing). Translating the gist of suggestions to such posters, I would say: do you really need to execute *any* expression? If not, use OCamllex and/or OCamlyacc (maybe Menhir, or a smaller and cleaner parser combinator library) to write a parser for your language subset, and then write an interpreter for the resulting ASTs. --PR From acarrico at memebeam.org Sat Sep 27 21:11:08 2014 From: acarrico at memebeam.org (Anthony Carrico) Date: Sat, 27 Sep 2014 21:11:08 -0400 Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: <39AEBCAD-6138-4FE6-84A5-6AFF1A1A466C@knauth.org> References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> <54262A0B.2010901@memebeam.org> <39AEBCAD-6138-4FE6-84A5-6AFF1A1A466C@knauth.org> Message-ID: <5427602C.5010101@memebeam.org> On 09/27/2014 09:49 AM, Alexander D. Knauth wrote: > Like this, I think: (but for some reason it seems to print it 3 times?) > #lang typed/racket > > (struct foo () #:transparent > #:property prop:custom-write > (lambda (this out mode) > (displayln "whatever"))) > > (print (foo)) I didn't realize #:property was legal in typed struct. I guess there should be a documentation update here: http://docs.racket-lang.org/ts-reference/special-forms.html BTW change your program to use the given port: (displayln "whatever" out) to avoid the double printing problem, although I'm not exactly sure why it would have that effect. Thanks! -- Anthony Carrico -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: OpenPGP digital signature URL: From samth at cs.indiana.edu Sat Sep 27 21:58:14 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Sat, 27 Sep 2014 21:58:14 -0400 Subject: [racket] typed racket and generic interfaces, is there a workaround using properties? In-Reply-To: <5427602C.5010101@memebeam.org> References: <2021E4C9-B660-444D-8E4B-7C41169D61F7@knauth.org> <54262A0B.2010901@memebeam.org> <39AEBCAD-6138-4FE6-84A5-6AFF1A1A466C@knauth.org> <5427602C.5010101@memebeam.org> Message-ID: On Sat, Sep 27, 2014 at 9:11 PM, Anthony Carrico wrote: > On 09/27/2014 09:49 AM, Alexander D. Knauth wrote: >> Like this, I think: (but for some reason it seems to print it 3 times?) >> #lang typed/racket >> >> (struct foo () #:transparent >> #:property prop:custom-write >> (lambda (this out mode) >> (displayln "whatever"))) >> >> (print (foo)) > > I didn't realize #:property was legal in typed struct. I guess there > should be a documentation update here: > http://docs.racket-lang.org/ts-reference/special-forms.html No, instead we need to change typed racket to reject those programs. However, that would break a bunch of code with no easy fix that relies on getting away with this, so we'll probably have to wait till we have a real story here. > BTW change your program to use the given port: (displayln "whatever" > out) to avoid the double printing problem, although I'm not exactly sure > why it would have that effect. It prints multiple times (to hidden output ports) to detect cycles among other things. Sam > Thanks! > > -- > Anthony Carrico > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From richter at math.northwestern.edu Sun Sep 28 00:57:12 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sat, 27 Sep 2014 23:57:12 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <54274040.5070902@uwaterloo.ca> (message from Prabhakar Ragde on Sat, 27 Sep 2014 18:54:56 -0400) References: <5426CAAB.2010400@uwaterloo.ca> <201409272150.s8RLoBQW030663@poisson.math.northwestern.edu> <54274040.5070902@uwaterloo.ca> Message-ID: <201409280457.s8S4vCrp000773@poisson.math.northwestern.edu> Translating the gist of suggestions to such posters, I would say: do you really need to execute *any* expression? If not, use OCamllex and/or OCamlyacc (maybe Menhir, or a smaller and cleaner parser combinator library) to write a parser for your language subset, and then write an interpreter for the resulting ASTs. Thanks, Prabhakar! I think something like what you're saying is true. HOL Light is based on quite a lot of the OCaml parser camlp, and I've thought for a long time that I had to learn it myself. I don't have enough practice in OCaml to grasp what your code does I'm making a dialect ofHOL Light with different syntax by interpreting one of my programs as a string and then breaking the string up into the component pieces, but then I need this Toploop/exec hack to evaluate my variables. That sounds like the Scheme eval, and in Scheme you can solve that problem nicely with the quote feature. -- Best, Bill From matthias at ccs.neu.edu Sat Sep 27 18:00:35 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sat, 27 Sep 2014 16:00:35 -0600 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> References: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> Message-ID: On Sep 27, 2014, at 1:38 AM, Bill Richter wrote: > Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. Decouple parsing from interpreting and your ML interpreter for ML won't look too different from your Lisp/Racket/Scheme interpreter for Lisp/Racket/Scheme. Indeed, almost everyone who does the latter actually does some form of decoupling usually. In general, (1) pick a representation for your chosen programming language that is tree-oriented, call it AST (2) pick a representation for the values that your programs may return, call it VAL (3) design a function interpreter : AST -> VAL (4) for a typed language, also design a function type_check : AST -> Boolean In ML, you might try type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast type val = BASIC of int | FUNCTION of val -> val | ... > I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? 1. HtDP explains the above in a couple of sections. 2. HtDP is for college freshmen (roughly) and for high school students who have the patience to read. The occasional 7th and 8th grader work their way thru HtDP with adults who understand HtDP or learn to understand HtDP that way. The basic 7th grader will benefit from the material at bootstrap-world.org, which is what we use with many middle school students around the country. -- Matthias From richter at math.northwestern.edu Sun Sep 28 01:39:20 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sun, 28 Sep 2014 00:39:20 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: (message from Matthias Felleisen on Sat, 27 Sep 2014 16:00:35 -0600) References: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> Message-ID: <201409280539.s8S5dKcx001372@poisson.math.northwestern.edu> type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast type val = BASIC of int | FUNCTION of val -> val | ... Thanks, Matthias! I know this is way off topic, but I think it's the sort of thing only Schemers understand, and I think HOL Light would be a lot better off my problem got solved. There's a lot I didn't understand with your ML explanation. Is this written down somewhere? How to write a ML interpreter in ML using your type ideas? Are you saying I don't need camlp parsing? I would find that hard to believe. Formal proofs in HOL Light are really just OCaml programs where a lot of code has already been evaluated. Here's a simple Hilbert geometry program in my dialect: let ExistsPointOffLine = theorem `; ?l. Line l ? ?Q. Q ? l proof intro_TAC ?l, H1; consider A B C such that ?(A = B) ? ?(A = C) ? ?(B = C) ? ?Collinear A B C [Distinct] by fol I3; assume (A ? l) ? (B ? l) ? (C ? l) [all_on] by fol ?; Collinear A B C [] by fol H1 - Collinear_DEF; fol - Distinct; qed; `;; I think I need the `;[...]` construct, which at present just turns my proof into a string without any backslash or newline problems, which is then passed to my function theorem. The usual HOL Light style is like this, using instead a function prove: let MULT_0 = prove (`!m. m * 0 = 0`, INDUCT_TAC THEN ASM_REWRITE_TAC[MULT; ADD_CLAUSES]);; Notice the related `[...]` construct, which I think sends the ordered pair off to heavy camlp parsing. Thanks for the 7th and 8th advice. I think my student is smart and hard-working, and I (finally!) learned how to program reading your book HtDP, so it sounds like you're saying that I should be able to teach it to my student. I went to bootstrap-world.org and, uh, maybe I didn't look hard enough, but I didn't find anything that looked juicy. -- Best, Bill From asumu at ccs.neu.edu Sun Sep 28 11:17:15 2014 From: asumu at ccs.neu.edu (Asumu Takikawa) Date: Sun, 28 Sep 2014 11:17:15 -0400 Subject: [racket] (fourth RacketCon) videos Message-ID: <20140928151714.GH30398@localhost> Hi all, The hi-res talk recordings for (fourth RacketCon) are now up on Youtube. You can watch all of them via this playlist: https://www.youtube.com/playlist?list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2Gdh Let me know if you find any glitches. Cheers, Asumu From plragde at uwaterloo.ca Sun Sep 28 11:29:32 2014 From: plragde at uwaterloo.ca (Prabhakar Ragde) Date: Sun, 28 Sep 2014 11:29:32 -0400 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: <201409280457.s8S4vCrp000773@poisson.math.northwestern.edu> References: <5426CAAB.2010400@uwaterloo.ca> <201409272150.s8RLoBQW030663@poisson.math.northwestern.edu> <54274040.5070902@uwaterloo.ca> <201409280457.s8S4vCrp000773@poisson.math.northwestern.edu> Message-ID: <5428295C.5050006@uwaterloo.ca> On 2014-09-28, 12:57 AM, Bill Richter wrote: > I'm making a dialect of HOL Light with different syntax by > interpreting one of my programs as a string and then breaking the > string up into the component pieces, but then I need this > Toploop/exec hack to evaluate my variables. That sounds like the > Scheme eval, and in Scheme you can solve that problem nicely with the > quote feature. A Racketeer would probably tell you to use macros to define your dialect, instead of using an eval hack. The corresponding tool for OCaml is camlp4, and it sounds as if it would be worth your time to learn it thoroughly. --PR From samth at cs.indiana.edu Sun Sep 28 11:48:12 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Sun, 28 Sep 2014 11:48:12 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352@knauth.org> References: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352@knauth.org> Message-ID: Why not do this with the type, instead of making this polymorphic? Sam On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth wrote: > Is it possible to have a struct that does certain things according to the > guard? > #lang typed/racket > > (struct (a) foo ([a : a]) #:transparent > #:guard (lambda (a _) > (unless (exact-integer? a) > (error 'foo "expected Integer, given ~v" a)) > a)) > > (ann (foo (ann 1 Any)) (foo Integer)) > > (: x : (foo Any)) > (define x (foo 1)) > > (ann (foo-a x) Integer) > > ;. Type Checker: Polymorphic function `foo1' could not be applied to > arguments: > ;Argument 1: > ; Expected: a > ; Given: Any > ; > ;Result type: (foo a) > ;Expected result: (foo Integer) > ; in: (foo (ann 1 Any)) > ;. Type Checker: Polymorphic function `foo-a' could not be applied to > arguments: > ;Argument 1: > ; Expected: (foo a) > ; Given: (foo Any) > ; > ;Result type: (a : ....) > ;Expected result: Integer > ; in: (foo-a x) > > On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth > wrote: > > What I?m trying to accomplish is something more like this: > #lang typed/racket > > (require "dimensions.rkt") > > (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) > #:transparent > #:guard (lambda (name scalar dimension _) > (unless (dimension? dimension) > (error 'unit "expected Dimension, given ~v" dimension)) > (values name scalar dimension))) > > (define-type (Unitof d) (unit d)) > > (define-type Unit (Unitof Dimension)) > > (define Unit? (make-predicate Unit)) > > (define-type Unitish > (U (Unitof Any) > Dimension > Positive-Real)) > > (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] > [Unitish -> Unit]))) > (define (->unit u) > (cond [(unit? u) > (unless (Unit? u) ; this should never happen anyway because of the > guard > (error '->unit "expected (Unitof Dimension), given ~v" u)) > u] > [(dimension? u) (unit u 1 u)] > [(positive-real? u) (unit u u dimensionless-dimension)])) > > > On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt > wrote: > > No, I don't think you can do this. Can you say more about what you're > trying to accomplish? > > Sam > > On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth > wrote: > > Do any of you have any advice for getting a function like this to > type-check? > #lang typed/racket > > (: check-int : (All (a) (case-> [a -> a] > [Any -> Integer]))) > (define (check-int int) > (unless (exact-integer? int) > (error 'check-int "expected Integer, given ~v" int)) > int) > > ;. Type Checker: type mismatch > ; expected: a > ; given: Integer in: int > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > From alexander at knauth.org Sun Sep 28 12:02:24 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 28 Sep 2014 12:02:24 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352@knauth.org> Message-ID: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: > Why not do this with the type, instead of making this polymorphic? > > Sam > > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth > wrote: >> Is it possible to have a struct that does certain things according to the >> guard? >> #lang typed/racket >> >> (struct (a) foo ([a : a]) #:transparent >> #:guard (lambda (a _) >> (unless (exact-integer? a) >> (error 'foo "expected Integer, given ~v" a)) >> a)) >> >> (ann (foo (ann 1 Any)) (foo Integer)) >> >> (: x : (foo Any)) >> (define x (foo 1)) >> >> (ann (foo-a x) Integer) >> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >> arguments: >> ;Argument 1: >> ; Expected: a >> ; Given: Any >> ; >> ;Result type: (foo a) >> ;Expected result: (foo Integer) >> ; in: (foo (ann 1 Any)) >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >> arguments: >> ;Argument 1: >> ; Expected: (foo a) >> ; Given: (foo Any) >> ; >> ;Result type: (a : ....) >> ;Expected result: Integer >> ; in: (foo-a x) >> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >> wrote: >> >> What I?m trying to accomplish is something more like this: >> #lang typed/racket >> >> (require "dimensions.rkt") >> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >> #:transparent >> #:guard (lambda (name scalar dimension _) >> (unless (dimension? dimension) >> (error 'unit "expected Dimension, given ~v" dimension)) >> (values name scalar dimension))) >> >> (define-type (Unitof d) (unit d)) >> >> (define-type Unit (Unitof Dimension)) >> >> (define Unit? (make-predicate Unit)) >> >> (define-type Unitish >> (U (Unitof Any) >> Dimension >> Positive-Real)) >> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >> [Unitish -> Unit]))) >> (define (->unit u) >> (cond [(unit? u) >> (unless (Unit? u) ; this should never happen anyway because of the >> guard >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >> u] >> [(dimension? u) (unit u 1 u)] >> [(positive-real? u) (unit u u dimensionless-dimension)])) >> >> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >> wrote: >> >> No, I don't think you can do this. Can you say more about what you're >> trying to accomplish? >> >> Sam >> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >> wrote: >> >> Do any of you have any advice for getting a function like this to >> type-check? >> #lang typed/racket >> >> (: check-int : (All (a) (case-> [a -> a] >> [Any -> Integer]))) >> (define (check-int int) >> (unless (exact-integer? int) >> (error 'check-int "expected Integer, given ~v" int)) >> int) >> >> ;. Type Checker: type mismatch >> ; expected: a >> ; given: Integer in: int >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> >> From samth at cs.indiana.edu Sun Sep 28 12:08:43 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Sun, 28 Sep 2014 12:08:43 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> References: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352@knauth.org> <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> Message-ID: No, I think we just need to add bounded polymorphism to TR. Sam On Sun, Sep 28, 2014 at 12:02 PM, Alexander D. Knauth wrote: > Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. > The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. > > On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: > >> Why not do this with the type, instead of making this polymorphic? >> >> Sam >> >> On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >> wrote: >>> Is it possible to have a struct that does certain things according to the >>> guard? >>> #lang typed/racket >>> >>> (struct (a) foo ([a : a]) #:transparent >>> #:guard (lambda (a _) >>> (unless (exact-integer? a) >>> (error 'foo "expected Integer, given ~v" a)) >>> a)) >>> >>> (ann (foo (ann 1 Any)) (foo Integer)) >>> >>> (: x : (foo Any)) >>> (define x (foo 1)) >>> >>> (ann (foo-a x) Integer) >>> >>> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>> arguments: >>> ;Argument 1: >>> ; Expected: a >>> ; Given: Any >>> ; >>> ;Result type: (foo a) >>> ;Expected result: (foo Integer) >>> ; in: (foo (ann 1 Any)) >>> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>> arguments: >>> ;Argument 1: >>> ; Expected: (foo a) >>> ; Given: (foo Any) >>> ; >>> ;Result type: (a : ....) >>> ;Expected result: Integer >>> ; in: (foo-a x) >>> >>> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>> wrote: >>> >>> What I?m trying to accomplish is something more like this: >>> #lang typed/racket >>> >>> (require "dimensions.rkt") >>> >>> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>> #:transparent >>> #:guard (lambda (name scalar dimension _) >>> (unless (dimension? dimension) >>> (error 'unit "expected Dimension, given ~v" dimension)) >>> (values name scalar dimension))) >>> >>> (define-type (Unitof d) (unit d)) >>> >>> (define-type Unit (Unitof Dimension)) >>> >>> (define Unit? (make-predicate Unit)) >>> >>> (define-type Unitish >>> (U (Unitof Any) >>> Dimension >>> Positive-Real)) >>> >>> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>> [Unitish -> Unit]))) >>> (define (->unit u) >>> (cond [(unit? u) >>> (unless (Unit? u) ; this should never happen anyway because of the >>> guard >>> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>> u] >>> [(dimension? u) (unit u 1 u)] >>> [(positive-real? u) (unit u u dimensionless-dimension)])) >>> >>> >>> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>> wrote: >>> >>> No, I don't think you can do this. Can you say more about what you're >>> trying to accomplish? >>> >>> Sam >>> >>> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>> wrote: >>> >>> Do any of you have any advice for getting a function like this to >>> type-check? >>> #lang typed/racket >>> >>> (: check-int : (All (a) (case-> [a -> a] >>> [Any -> Integer]))) >>> (define (check-int int) >>> (unless (exact-integer? int) >>> (error 'check-int "expected Integer, given ~v" int)) >>> int) >>> >>> ;. Type Checker: type mismatch >>> ; expected: a >>> ; given: Integer in: int >>> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> > From spencerflorence at gmail.com Sun Sep 28 12:13:22 2014 From: spencerflorence at gmail.com (Spencer florence) Date: Sun, 28 Sep 2014 09:13:22 -0700 (PDT) Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> Message-ID: <1411920801296.55e3aa5@Nodemailer> would something like this work? #lang typed/racket (struct (U) number+unit ([amount : Real] [unit : U])) (define-type Weight-Unit (U 'kg 'g 'mg '?g)) (define-type Weight (number+unit Weight-Unit)) (define-predicate weight? Weight) (: make-weight : Real Weight-Unit -> Weight) (define (make-weight n u) ? (number+unit n u)) (: +/weight : Weight Weight -> Weight) ;; something something needs unit conversion (define (+/weight w1 w2) ? (number+unit (+ (number+unit-amount w1) ? ? ? ? ? ? ? ? ? (number+unit-amount w1)) ?? ? ? ? ? ? ? (number+unit-unit w1))) (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: > Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. > The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. > On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >> Why not do this with the type, instead of making this polymorphic? >> >> Sam >> >> On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >> wrote: >>> Is it possible to have a struct that does certain things according to the >>> guard? >>> #lang typed/racket >>> >>> (struct (a) foo ([a : a]) #:transparent >>> #:guard (lambda (a _) >>> (unless (exact-integer? a) >>> (error 'foo "expected Integer, given ~v" a)) >>> a)) >>> >>> (ann (foo (ann 1 Any)) (foo Integer)) >>> >>> (: x : (foo Any)) >>> (define x (foo 1)) >>> >>> (ann (foo-a x) Integer) >>> >>> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>> arguments: >>> ;Argument 1: >>> ; Expected: a >>> ; Given: Any >>> ; >>> ;Result type: (foo a) >>> ;Expected result: (foo Integer) >>> ; in: (foo (ann 1 Any)) >>> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>> arguments: >>> ;Argument 1: >>> ; Expected: (foo a) >>> ; Given: (foo Any) >>> ; >>> ;Result type: (a : ....) >>> ;Expected result: Integer >>> ; in: (foo-a x) >>> >>> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>> wrote: >>> >>> What I?m trying to accomplish is something more like this: >>> #lang typed/racket >>> >>> (require "dimensions.rkt") >>> >>> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>> #:transparent >>> #:guard (lambda (name scalar dimension _) >>> (unless (dimension? dimension) >>> (error 'unit "expected Dimension, given ~v" dimension)) >>> (values name scalar dimension))) >>> >>> (define-type (Unitof d) (unit d)) >>> >>> (define-type Unit (Unitof Dimension)) >>> >>> (define Unit? (make-predicate Unit)) >>> >>> (define-type Unitish >>> (U (Unitof Any) >>> Dimension >>> Positive-Real)) >>> >>> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>> [Unitish -> Unit]))) >>> (define (->unit u) >>> (cond [(unit? u) >>> (unless (Unit? u) ; this should never happen anyway because of the >>> guard >>> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>> u] >>> [(dimension? u) (unit u 1 u)] >>> [(positive-real? u) (unit u u dimensionless-dimension)])) >>> >>> >>> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>> wrote: >>> >>> No, I don't think you can do this. Can you say more about what you're >>> trying to accomplish? >>> >>> Sam >>> >>> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>> wrote: >>> >>> Do any of you have any advice for getting a function like this to >>> type-check? >>> #lang typed/racket >>> >>> (: check-int : (All (a) (case-> [a -> a] >>> [Any -> Integer]))) >>> (define (check-int int) >>> (unless (exact-integer? int) >>> (error 'check-int "expected Integer, given ~v" int)) >>> int) >>> >>> ;. Type Checker: type mismatch >>> ; expected: a >>> ; given: Integer in: int >>> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Sun Sep 28 13:37:30 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 28 Sep 2014 13:37:30 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <1411920801296.55e3aa5@Nodemailer> References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> Message-ID: No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: > would something like this work? > > #lang typed/racket > > (struct (U) number+unit ([amount : Real] [unit : U])) > > (define-type Weight-Unit (U 'kg 'g 'mg '?g)) > (define-type Weight (number+unit Weight-Unit)) > (define-predicate weight? Weight) > > (: make-weight : Real Weight-Unit -> Weight) > (define (make-weight n u) > (number+unit n u)) > > (: +/weight : Weight Weight -> Weight) > ;; something something needs unit conversion > (define (+/weight w1 w2) > (number+unit (+ (number+unit-amount w1) > (number+unit-amount w1)) > (number+unit-unit w1))) > > (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) > > > > On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: > > Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. > The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. > > On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: > > > Why not do this with the type, instead of making this polymorphic? > > > > Sam > > > > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth > > wrote: > >> Is it possible to have a struct that does certain things according to the > >> guard? > >> #lang typed/racket > >> > >> (struct (a) foo ([a : a]) #:transparent > >> #:guard (lambda (a _) > >> (unless (exact-integer? a) > >> (error 'foo "expected Integer, given ~v" a)) > >> a)) > >> > >> (ann (foo (ann 1 Any)) (foo Integer)) > >> > >> (: x : (foo Any)) > >> (define x (foo 1)) > >> > >> (ann (foo-a x) Integer) > >> > >> ;. Type Checker: Polymorphic function `foo1' could not be applied to > >> arguments: > >> ;Argument 1: > >> ; Expected: a > >> ; Given: Any > >> ; > >> ;Result type: (foo a) > >> ;Expected result: (foo Integer) > >> ; in: (foo (ann 1 Any)) > >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to > >> arguments: > >> ;Argument 1: > >> ; Expected: (foo a) > >> ; Given: (foo Any) > >> ; > >> ;Result type: (a : ....) > >> ;Expected result: Integer > >> ; in: (foo-a x) > >> > >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth > >> wrote: > >> > >> What I?m trying to accomplish is something more like this: > >> #lang typed/racket > >> > >> (require "dimensions.rkt") > >> > >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) > >> #:transparent > >> #:guard (lambda (name scalar dimension _) > >> (unless (dimension? dimension) > >> (error 'unit "expected Dimension, given ~v" dimension)) > >> (values name scalar dimension))) > >> > >> (define-type (Unitof d) (unit d)) > >> > >> (define-type Unit (Unitof Dimension)) > >> > >> (define Unit? (make-predicate Unit)) > >> > >> (define-type Unitish > >> (U (Unitof Any) > >> Dimension > >> Positive-Real)) > >> > >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] > >> [Unitish -> Unit]))) > >> (define (->unit u) > >> (cond [(unit? u) > >> (unless (Unit? u) ; this should never happen anyway because of the > >> guard > >> (error '->unit "expected (Unitof Dimension), given ~v" u)) > >> u] > >> [(dimension? u) (unit u 1 u)] > >> [(positive-real? u) (unit u u dimensionless-dimension)])) > >> > >> > >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt > >> wrote: > >> > >> No, I don't think you can do this. Can you say more about what you're > >> trying to accomplish? > >> > >> Sam > >> > >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth > >> wrote: > >> > >> Do any of you have any advice for getting a function like this to > >> type-check? > >> #lang typed/racket > >> > >> (: check-int : (All (a) (case-> [a -> a] > >> [Any -> Integer]))) > >> (define (check-int int) > >> (unless (exact-integer? int) > >> (error 'check-int "expected Integer, given ~v" int)) > >> int) > >> > >> ;. Type Checker: type mismatch > >> ; expected: a > >> ; given: Integer in: int > >> > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > >> > >> > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.n.dobson at gmail.com Sun Sep 28 13:48:06 2014 From: eric.n.dobson at gmail.com (Eric Dobson) Date: Sun, 28 Sep 2014 10:48:06 -0700 Subject: [racket] Help debugging a ffi crash Message-ID: I'm trying to debug an FFI crash that I'm seeing, and because it is dealing with C code the error just presents as a segfault. I believe I have tracked down what is causing the problem, but don't understand how it could be doing so. I have two racket functions which take a "cursor" (the foreign libraries object) and return a string representation of it, which I'm trying to use for debugging. (define raw-clang-get-cstring (get-ffi-obj "clang_getCString" lib-clang (_fun _pointer -> _string))) (define raw-cursor-spelling (get-ffi-obj "clang_getCursorSpelling" lib-clang (_fun _CXCursor -> _pointer))) (define (cursor-spelling c) (raw-clang-get-cstring (raw-cursor-spelling c))) (define cursor-spelling2 (get-ffi-obj "clang_getCursorSpelling" lib-clang (_fun _CXCursor -> (make-ctype _pointer values (? (v) (raw-clang-get-cstring v)))))) If I use cursor-spelling, I have not been able to trigger a crash. But if I use cursor-spelling2 I can reliably trigger a crash. Is there anything obvious on how these functions are different? Because they look to me like they should be doing the same thing. If it would be helpful I can try to get my code in a portable enough shape so that it will work/crash on another machine. From adrian.klaver at aklaver.com Thu Sep 25 20:25:15 2014 From: adrian.klaver at aklaver.com (Adrian Klaver) Date: Thu, 25 Sep 2014 17:25:15 -0700 Subject: [racket] [GENERAL] Off Topic: Anybody reading this via news.gmane.org? In-Reply-To: <5424AFC2.6020302@comcast.net> References: <54248425.90509@comcast.net> <5424A05A.9020809@aklaver.com> <5424AFC2.6020302@comcast.net> Message-ID: <5424B26B.9080504@aklaver.com> On 09/25/2014 05:13 PM, George Neuner wrote: > > On 9/25/2014 5:26 PM, Neil Van Dyke wrote: >> You can check your IP addr against the list at >> "http://gmane.org/denied.php". >> >> Neil V. > > On 9/25/2014 7:08 PM, Adrian Klaver wrote: >> >> Take a look here: >> >> http://gmane.org/denied.php >> >> My guess is you are the fourth one from the bottom. >> >> >> Might want to take a look at this thread to see what your options are >> and what the turn around time is on your request: >> >> http://thread.gmane.org/gmane.discuss/16309 > > Thanks to both of you - I missed seeing the entry about the denied list > in the FAQ. > > Adrian you were right - it seems that I have been blocked for some > reason. Based on the description of infractions I really don't think I > did anything to warrant it ... but there it is. I'll have to follow my > lists by email until I can unblocked. I think the relevant part at gmane.org/denied.php is: "Since there is no way to identify users, news readers are denied on a domain/IP basis. So if somebody on a machine close to you downloaded the news spool yesterday, you're likely to be denied today" > > Thanks again, > George -- Adrian Klaver adrian.klaver at aklaver.com From mflatt at cs.utah.edu Sun Sep 28 14:08:23 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Sun, 28 Sep 2014 12:08:23 -0600 Subject: [racket] Help debugging a ffi crash In-Reply-To: References: Message-ID: <20140928180825.80D74650196@mail-svr1.cs.utah.edu> Looking at http://clang.llvm.org/doxygen/CXString_8h_source.html it seems that CXString as returned by clang_getCursorSpelling() is not a pointer: typedef struct { const void *data; unsigned private_flags; } CXString; If that's right, I'm a little surprised that `cursor-spelling` works --- but when you get representation wrong, strange things can happen, including something working when it shouldn't. Am I looking at the right library/definitions? At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote: > I'm trying to debug an FFI crash that I'm seeing, and because it is > dealing with C code the error just presents as a segfault. I believe I > have tracked down what is causing the problem, but don't understand > how it could be doing so. > > I have two racket functions which take a "cursor" (the foreign > libraries object) and return a string representation of it, which I'm > trying to use for debugging. > > (define raw-clang-get-cstring > (get-ffi-obj "clang_getCString" lib-clang > (_fun _pointer -> _string))) > > (define raw-cursor-spelling > (get-ffi-obj "clang_getCursorSpelling" lib-clang > (_fun _CXCursor -> _pointer))) > > (define (cursor-spelling c) > (raw-clang-get-cstring (raw-cursor-spelling c))) > > (define cursor-spelling2 > (get-ffi-obj "clang_getCursorSpelling" lib-clang > (_fun _CXCursor -> (make-ctype _pointer values (? (v) > (raw-clang-get-cstring v)))))) > > If I use cursor-spelling, I have not been able to trigger a crash. But > if I use cursor-spelling2 I can reliably trigger a crash. > > Is there anything obvious on how these functions are different? > Because they look to me like they should be doing the same thing. If > it would be helpful I can try to get my code in a portable enough > shape so that it will work/crash on another machine. > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From eric.n.dobson at gmail.com Sun Sep 28 14:15:33 2014 From: eric.n.dobson at gmail.com (Eric Dobson) Date: Sun, 28 Sep 2014 11:15:33 -0700 Subject: [racket] Help debugging a ffi crash In-Reply-To: <20140928180825.80D74650196@mail-svr1.cs.utah.edu> References: <20140928180825.80D74650196@mail-svr1.cs.utah.edu> Message-ID: That is almost surely it, thanks for the second pair of eyes. I had similar issues with a different type that I thought was a pointer but was actually a struct, but that one I couldn't even get a single call to work so it was much more obvious something was up. On Sun, Sep 28, 2014 at 11:08 AM, Matthew Flatt wrote: > Looking at > > http://clang.llvm.org/doxygen/CXString_8h_source.html > > it seems that CXString as returned by clang_getCursorSpelling() is not > a pointer: > > typedef struct { > const void *data; > unsigned private_flags; > } CXString; > > If that's right, I'm a little surprised that `cursor-spelling` works > --- but when you get representation wrong, strange things can happen, > including something working when it shouldn't. > > Am I looking at the right library/definitions? > > At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote: >> I'm trying to debug an FFI crash that I'm seeing, and because it is >> dealing with C code the error just presents as a segfault. I believe I >> have tracked down what is causing the problem, but don't understand >> how it could be doing so. >> >> I have two racket functions which take a "cursor" (the foreign >> libraries object) and return a string representation of it, which I'm >> trying to use for debugging. >> >> (define raw-clang-get-cstring >> (get-ffi-obj "clang_getCString" lib-clang >> (_fun _pointer -> _string))) >> >> (define raw-cursor-spelling >> (get-ffi-obj "clang_getCursorSpelling" lib-clang >> (_fun _CXCursor -> _pointer))) >> >> (define (cursor-spelling c) >> (raw-clang-get-cstring (raw-cursor-spelling c))) >> >> (define cursor-spelling2 >> (get-ffi-obj "clang_getCursorSpelling" lib-clang >> (_fun _CXCursor -> (make-ctype _pointer values (? (v) >> (raw-clang-get-cstring v)))))) >> >> If I use cursor-spelling, I have not been able to trigger a crash. But >> if I use cursor-spelling2 I can reliably trigger a crash. >> >> Is there anything obvious on how these functions are different? >> Because they look to me like they should be doing the same thing. If >> it would be helpful I can try to get my code in a portable enough >> shape so that it will work/crash on another machine. >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From kalimehtar at mail.ru Sun Sep 28 14:39:54 2014 From: kalimehtar at mail.ru (=?UTF-8?B?Um9tYW4gS2xvY2hrb3Y=?=) Date: Sun, 28 Sep 2014 22:39:54 +0400 Subject: [racket] =?utf-8?q?How_to_document_a_field=3F?= Message-ID: <1411929594.923492574@f67.i.mail.ru> At http://docs.racket-lang.org/scribble/doc-classes.html I see classes, interfaces, methods, but don't see fields. How to document them? Via @defthing or is there some syntax with (get-field ..) (set-field! ...) template like @defparam ? -- Roman Klochkov -------------- next part -------------- An HTML attachment was scrubbed... URL: From richter at math.northwestern.edu Sun Sep 28 14:51:26 2014 From: richter at math.northwestern.edu (Bill Richter) Date: Sun, 28 Sep 2014 13:51:26 -0500 Subject: [racket] proof assistants, DrRacket and Bootstrap In-Reply-To: (message from Matthias Felleisen on Sat, 27 Sep 2014 16:00:35 -0600) References: <201409270738.s8R7cmcd022184@poisson.math.northwestern.edu> Message-ID: <201409281851.s8SIpQMx006764@poisson.math.northwestern.edu> Matthias & Prabhakar, I think I see what you're saying now. I need the camlp parser to turn my dialect-expressions into trees. Then I turn my tree into standard expressions just as one does in Scheme. The only differences is that in Scheme we have the quote function that skips the parsing step. So your ML code MF> type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast MF> type val = BASIC of int | FUNCTION of val -> val | ... looks a lot like the HOL Light definition of preterms: type preterm = Varp of string * pretype (* Variable - v *) | Constp of string * pretype (* Constant - c *) | Combp of preterm * preterm (* Combination - f x *) | Absp of preterm * preterm (* Lambda-abstraction - \x. t *) | Typing of preterm * pretype;; (* Type constraint - t : ty *) and so we can see one of these preterms in a standard term: # preterm_of_term `x + y`;; val it : preterm = Combp (Combp (Constp ("+", Ptycon ("fun", [Ptycon ("num", []); Ptycon ("fun", [Ptycon ("num", []); Ptycon ("num", [])])])), Varp ("x", Ptycon ("num", []))), Varp ("y", Ptycon ("num", []))) So the Scheme story works fine except that I haven't understood camlp or how HOL Light turns expressions `[...]` into preterms. But I feel better about investing the time into learning camlp now that I see the Scheme story remains intact in HOL Light. And you're right about my ignorance: MF> 1. HtDP explains the above in a couple of sections. Right, there's something I seem not to have understood in either Scheme or ML, how when we create and evaluate our trees we retain the values of our variables. I can figure that out, and HtDP sounds like a good place to start. PR> A Racketeer would probably tell you to use macros to define your PR> dialect, instead of using an eval hack. The corresponding tool for PR> OCaml is camlp4, and it sounds as if it would be worth your time PR> to learn it thoroughly. That's an interesting comparison, and since macros, maybe I can learn to like camlp. In fact, maybe I ought to learn something about racket macros first. -- Best, Bill From greghendershott at gmail.com Sun Sep 28 16:01:20 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 28 Sep 2014 16:01:20 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: Hi, Norman. I logged an issue for this: https://github.com/greghendershott/aws/issues/32 I see the problem (or at least the main problem) and will push a fix. The bug is embarrassing, not just because it's such a silly mistake, but it's something a unit test could have caught. (I could say that doing unit tests for Glacier is challenging, because the retrieval process can take hours. Although that's true, I could have done more to test _some_ operations working among various regions.) On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray wrote: > > Greetings. > > I'm trying to use the aws/glacier package, and running into a problem where I'm being told: > > Credential should be scoped to a valid region, not 'eu-west-1' > > I'm following the instructions at > > My test code is: > > % cat glacier.rkt > #lang racket/base > > (require aws/glacier > aws/keys) > > (define vault "testvault") > (region "eu-west-1") > (read-keys "aws-zbu-credentials") ; local file > > (module+ main > (printf "region=~a~%" (region)) > (printf "Vaults: ~s~%" (list-vaults)) > (printf "...specifically: ~s~%" (describe-vault vault))) > > Running this produces: > > % racket glacier.rkt > region=eu-west-1 > aws: HTTP/1.1 403 Forbidden > x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 > Content-Type: application/json > Content-Length: 129 > Date: Sat, 27 Sep 2014 18:35:50 GMT > > {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} > HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " > context...: > check-response > /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 > request/redirect/uri > (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] > > Things I thought of: > > * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. > * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. > * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com > * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. > * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. > * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. > > If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. > > I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? > > Thanks for any pointers. > > All the best, > > Norman > > > -- > Norman Gray : http://nxg.me.uk > SUPA School of Physics and Astronomy, University of Glasgow, UK > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From norman at astro.gla.ac.uk Sun Sep 28 16:29:03 2014 From: norman at astro.gla.ac.uk (Norman Gray) Date: Sun, 28 Sep 2014 21:29:03 +0100 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: Greg, hello. On 2014 Sep 28, at 21:01, Greg Hendershott wrote: > I logged an issue for this: > > https://github.com/greghendershott/aws/issues/32 Ah: I wondered if the problem might be related to that. > The bug is embarrassing, not just because it's such a silly mistake, > but it's something a unit test could have caught. (I could say that > doing unit tests for Glacier is challenging, because the retrieval > process can take hours. I can imagine how protracted that would be ... *shudder*. Thanks for looking at this. Also, Frank: > What happens if you read-keys before setting the region? Thanks for this suggestion: I did try that just a little earlier, but it didn't make any difference. All the best, Norman -- Norman Gray : http://nxg.me.uk SUPA School of Physics and Astronomy, University of Glasgow, UK From greghendershott at gmail.com Sun Sep 28 16:29:12 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 28 Sep 2014 16:29:12 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: I pushed a fix, including running the tests across a few different AWS regions. They pass. I clicked "update" on pkgs.racket-lang.org. But it seems to be slower than usual to refresh. After it does, you can `raco pkg update aws` to get the fix. On Sun, Sep 28, 2014 at 4:01 PM, Greg Hendershott wrote: > Hi, Norman. > > I logged an issue for this: > > https://github.com/greghendershott/aws/issues/32 > > I see the problem (or at least the main problem) and will push a fix. > > The bug is embarrassing, not just because it's such a silly mistake, > but it's something a unit test could have caught. (I could say that > doing unit tests for Glacier is challenging, because the retrieval > process can take hours. Although that's true, I could have done more > to test _some_ operations working among various regions.) > > On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray wrote: >> >> Greetings. >> >> I'm trying to use the aws/glacier package, and running into a problem where I'm being told: >> >> Credential should be scoped to a valid region, not 'eu-west-1' >> >> I'm following the instructions at >> >> My test code is: >> >> % cat glacier.rkt >> #lang racket/base >> >> (require aws/glacier >> aws/keys) >> >> (define vault "testvault") >> (region "eu-west-1") >> (read-keys "aws-zbu-credentials") ; local file >> >> (module+ main >> (printf "region=~a~%" (region)) >> (printf "Vaults: ~s~%" (list-vaults)) >> (printf "...specifically: ~s~%" (describe-vault vault))) >> >> Running this produces: >> >> % racket glacier.rkt >> region=eu-west-1 >> aws: HTTP/1.1 403 Forbidden >> x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 >> Content-Type: application/json >> Content-Length: 129 >> Date: Sat, 27 Sep 2014 18:35:50 GMT >> >> {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} >> HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " >> context...: >> check-response >> /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 >> request/redirect/uri >> (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] >> >> Things I thought of: >> >> * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. >> * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. >> * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com >> * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. >> * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. >> * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. >> >> If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. >> >> I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? >> >> Thanks for any pointers. >> >> All the best, >> >> Norman >> >> >> -- >> Norman Gray : http://nxg.me.uk >> SUPA School of Physics and Astronomy, University of Glasgow, UK >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From greghendershott at gmail.com Sun Sep 28 17:15:21 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 28 Sep 2014 17:15:21 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: > I clicked "update" on pkgs.racket-lang.org. But it seems to be slower > than usual to refresh. After it does, you can `raco pkg update aws` to > get the fix. Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: "update upload in progress: there may be inconsistencies below" It's been saying that for nearly an hour. In the past, clicking "update" would cause a successful refresh -- the package would get a red star indicating it's updated -- within a minute or two. From greghendershott at gmail.com Sun Sep 28 17:17:32 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 28 Sep 2014 17:17:32 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: >> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >> than usual to refresh. After it does, you can `raco pkg update aws` to >> get the fix. > > Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: > > "update upload in progress: there may be inconsistencies below" > > It's been saying that for nearly an hour. Sometimes instead it says: "update upload being computed: the information below may not represent all recent changes and updates" It has switched between those two messages at various intervals over the last hour. From norman at astro.gla.ac.uk Sun Sep 28 17:40:19 2014 From: norman at astro.gla.ac.uk (Norman Gray) Date: Sun, 28 Sep 2014 22:40:19 +0100 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> Message-ID: <73617243-E0D5-43C6-872B-EA0121AD5142@astro.gla.ac.uk> On 2014 Sep 28, at 22:17, Greg Hendershott wrote: >>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>> than usual to refresh. After it does, you can `raco pkg update aws` to >>> get the fix. >> >> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >> >> "update upload in progress: there may be inconsistencies below" >> >> It's been saying that for nearly an hour. > > Sometimes instead it says: > > "update upload being computed: the information below may not > represent all recent changes and updates" > > It has switched between those two messages at various intervals over > the last hour. And in case it's a useful data point, I'm getting % raco pkg update aws Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ Resolving "aws" via http://pkgs.racket-lang.org No updates available % And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... Norman -- Norman Gray : http://nxg.me.uk SUPA School of Physics and Astronomy, University of Glasgow, UK From greghendershott at gmail.com Sun Sep 28 18:10:55 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Sun, 28 Sep 2014 18:10:55 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: <73617243-E0D5-43C6-872B-EA0121AD5142@astro.gla.ac.uk> References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> <73617243-E0D5-43C6-872B-EA0121AD5142@astro.gla.ac.uk> Message-ID: If you're in a hurry you could remove and re-install directly from GitHub: $ raco pkg remove aws $ raco pkg install git://github.com/greghendershott/aws On Sun, Sep 28, 2014 at 5:40 PM, Norman Gray wrote: > > On 2014 Sep 28, at 22:17, Greg Hendershott wrote: > >>>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>>> than usual to refresh. After it does, you can `raco pkg update aws` to >>>> get the fix. >>> >>> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >>> >>> "update upload in progress: there may be inconsistencies below" >>> >>> It's been saying that for nearly an hour. >> >> Sometimes instead it says: >> >> "update upload being computed: the information below may not >> represent all recent changes and updates" >> >> It has switched between those two messages at various intervals over >> the last hour. > > And in case it's a useful data point, I'm getting > > % raco pkg update aws > Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ > Resolving "aws" via http://pkgs.racket-lang.org > No updates available > % > > And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... > > Norman > > > -- > Norman Gray : http://nxg.me.uk > SUPA School of Physics and Astronomy, University of Glasgow, UK > From matthias at ccs.neu.edu Sun Sep 28 18:58:20 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sun, 28 Sep 2014 18:58:20 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> Message-ID: <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: > No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. > I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. > > I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. > > On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: > >> would something like this work? >> >> #lang typed/racket >> >> (struct (U) number+unit ([amount : Real] [unit : U])) >> >> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >> (define-type Weight (number+unit Weight-Unit)) >> (define-predicate weight? Weight) >> >> (: make-weight : Real Weight-Unit -> Weight) >> (define (make-weight n u) >> (number+unit n u)) >> >> (: +/weight : Weight Weight -> Weight) >> ;; something something needs unit conversion >> (define (+/weight w1 w2) >> (number+unit (+ (number+unit-amount w1) >> (number+unit-amount w1)) >> (number+unit-unit w1))) >> >> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >> >> >> >> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >> >> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >> >> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >> >> > Why not do this with the type, instead of making this polymorphic? >> > >> > Sam >> > >> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >> > wrote: >> >> Is it possible to have a struct that does certain things according to the >> >> guard? >> >> #lang typed/racket >> >> >> >> (struct (a) foo ([a : a]) #:transparent >> >> #:guard (lambda (a _) >> >> (unless (exact-integer? a) >> >> (error 'foo "expected Integer, given ~v" a)) >> >> a)) >> >> >> >> (ann (foo (ann 1 Any)) (foo Integer)) >> >> >> >> (: x : (foo Any)) >> >> (define x (foo 1)) >> >> >> >> (ann (foo-a x) Integer) >> >> >> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >> >> arguments: >> >> ;Argument 1: >> >> ; Expected: a >> >> ; Given: Any >> >> ; >> >> ;Result type: (foo a) >> >> ;Expected result: (foo Integer) >> >> ; in: (foo (ann 1 Any)) >> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >> >> arguments: >> >> ;Argument 1: >> >> ; Expected: (foo a) >> >> ; Given: (foo Any) >> >> ; >> >> ;Result type: (a : ....) >> >> ;Expected result: Integer >> >> ; in: (foo-a x) >> >> >> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >> >> wrote: >> >> >> >> What I?m trying to accomplish is something more like this: >> >> #lang typed/racket >> >> >> >> (require "dimensions.rkt") >> >> >> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >> >> #:transparent >> >> #:guard (lambda (name scalar dimension _) >> >> (unless (dimension? dimension) >> >> (error 'unit "expected Dimension, given ~v" dimension)) >> >> (values name scalar dimension))) >> >> >> >> (define-type (Unitof d) (unit d)) >> >> >> >> (define-type Unit (Unitof Dimension)) >> >> >> >> (define Unit? (make-predicate Unit)) >> >> >> >> (define-type Unitish >> >> (U (Unitof Any) >> >> Dimension >> >> Positive-Real)) >> >> >> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >> >> [Unitish -> Unit]))) >> >> (define (->unit u) >> >> (cond [(unit? u) >> >> (unless (Unit? u) ; this should never happen anyway because of the >> >> guard >> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >> >> u] >> >> [(dimension? u) (unit u 1 u)] >> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >> >> >> >> >> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >> >> wrote: >> >> >> >> No, I don't think you can do this. Can you say more about what you're >> >> trying to accomplish? >> >> >> >> Sam >> >> >> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >> >> wrote: >> >> >> >> Do any of you have any advice for getting a function like this to >> >> type-check? >> >> #lang typed/racket >> >> >> >> (: check-int : (All (a) (case-> [a -> a] >> >> [Any -> Integer]))) >> >> (define (check-int int) >> >> (unless (exact-integer? int) >> >> (error 'check-int "expected Integer, given ~v" int)) >> >> int) >> >> >> >> ;. Type Checker: type mismatch >> >> ; expected: a >> >> ; given: Integer in: int >> >> >> >> >> >> >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> >> >> >> >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> >> >> >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> >> > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Sun Sep 28 20:14:43 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 28 Sep 2014 20:14:43 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> Message-ID: Yes I do want run-time residual of the dimensions, and yes I want a unit struct. Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: > > If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias > > > > > > > On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: > >> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >> >> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >> >> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >> >>> would something like this work? >>> >>> #lang typed/racket >>> >>> (struct (U) number+unit ([amount : Real] [unit : U])) >>> >>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>> (define-type Weight (number+unit Weight-Unit)) >>> (define-predicate weight? Weight) >>> >>> (: make-weight : Real Weight-Unit -> Weight) >>> (define (make-weight n u) >>> (number+unit n u)) >>> >>> (: +/weight : Weight Weight -> Weight) >>> ;; something something needs unit conversion >>> (define (+/weight w1 w2) >>> (number+unit (+ (number+unit-amount w1) >>> (number+unit-amount w1)) >>> (number+unit-unit w1))) >>> >>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>> >>> >>> >>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>> >>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>> >>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>> >>> > Why not do this with the type, instead of making this polymorphic? >>> > >>> > Sam >>> > >>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>> > wrote: >>> >> Is it possible to have a struct that does certain things according to the >>> >> guard? >>> >> #lang typed/racket >>> >> >>> >> (struct (a) foo ([a : a]) #:transparent >>> >> #:guard (lambda (a _) >>> >> (unless (exact-integer? a) >>> >> (error 'foo "expected Integer, given ~v" a)) >>> >> a)) >>> >> >>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>> >> >>> >> (: x : (foo Any)) >>> >> (define x (foo 1)) >>> >> >>> >> (ann (foo-a x) Integer) >>> >> >>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>> >> arguments: >>> >> ;Argument 1: >>> >> ; Expected: a >>> >> ; Given: Any >>> >> ; >>> >> ;Result type: (foo a) >>> >> ;Expected result: (foo Integer) >>> >> ; in: (foo (ann 1 Any)) >>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>> >> arguments: >>> >> ;Argument 1: >>> >> ; Expected: (foo a) >>> >> ; Given: (foo Any) >>> >> ; >>> >> ;Result type: (a : ....) >>> >> ;Expected result: Integer >>> >> ; in: (foo-a x) >>> >> >>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>> >> wrote: >>> >> >>> >> What I?m trying to accomplish is something more like this: >>> >> #lang typed/racket >>> >> >>> >> (require "dimensions.rkt") >>> >> >>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>> >> #:transparent >>> >> #:guard (lambda (name scalar dimension _) >>> >> (unless (dimension? dimension) >>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>> >> (values name scalar dimension))) >>> >> >>> >> (define-type (Unitof d) (unit d)) >>> >> >>> >> (define-type Unit (Unitof Dimension)) >>> >> >>> >> (define Unit? (make-predicate Unit)) >>> >> >>> >> (define-type Unitish >>> >> (U (Unitof Any) >>> >> Dimension >>> >> Positive-Real)) >>> >> >>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>> >> [Unitish -> Unit]))) >>> >> (define (->unit u) >>> >> (cond [(unit? u) >>> >> (unless (Unit? u) ; this should never happen anyway because of the >>> >> guard >>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>> >> u] >>> >> [(dimension? u) (unit u 1 u)] >>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>> >> >>> >> >>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>> >> wrote: >>> >> >>> >> No, I don't think you can do this. Can you say more about what you're >>> >> trying to accomplish? >>> >> >>> >> Sam >>> >> >>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>> >> wrote: >>> >> >>> >> Do any of you have any advice for getting a function like this to >>> >> type-check? >>> >> #lang typed/racket >>> >> >>> >> (: check-int : (All (a) (case-> [a -> a] >>> >> [Any -> Integer]))) >>> >> (define (check-int int) >>> >> (unless (exact-integer? int) >>> >> (error 'check-int "expected Integer, given ~v" int)) >>> >> int) >>> >> >>> >> ;. Type Checker: type mismatch >>> >> ; expected: a >>> >> ; given: Integer in: int >>> >> >>> >> >>> >> >>> >> ____________________ >>> >> Racket Users list: >>> >> http://lists.racket-lang.org/users >>> >> >>> >> >>> >> ____________________ >>> >> Racket Users list: >>> >> http://lists.racket-lang.org/users >>> >> >>> >> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Sun Sep 28 20:25:45 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sun, 28 Sep 2014 20:25:45 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> Message-ID: Your message points out where gradual typing badly fails. Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. -- Matthias On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: > Yes I do want run-time residual of the dimensions, and yes I want a unit struct. > > Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. > > And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. > > On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: > >> >> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >> >> >> >> >> >> >> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >> >>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>> >>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>> >>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>> >>>> would something like this work? >>>> >>>> #lang typed/racket >>>> >>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>> >>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>> (define-type Weight (number+unit Weight-Unit)) >>>> (define-predicate weight? Weight) >>>> >>>> (: make-weight : Real Weight-Unit -> Weight) >>>> (define (make-weight n u) >>>> (number+unit n u)) >>>> >>>> (: +/weight : Weight Weight -> Weight) >>>> ;; something something needs unit conversion >>>> (define (+/weight w1 w2) >>>> (number+unit (+ (number+unit-amount w1) >>>> (number+unit-amount w1)) >>>> (number+unit-unit w1))) >>>> >>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>> >>>> >>>> >>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>> >>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>> >>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>> >>>> > Why not do this with the type, instead of making this polymorphic? >>>> > >>>> > Sam >>>> > >>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>> > wrote: >>>> >> Is it possible to have a struct that does certain things according to the >>>> >> guard? >>>> >> #lang typed/racket >>>> >> >>>> >> (struct (a) foo ([a : a]) #:transparent >>>> >> #:guard (lambda (a _) >>>> >> (unless (exact-integer? a) >>>> >> (error 'foo "expected Integer, given ~v" a)) >>>> >> a)) >>>> >> >>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>> >> >>>> >> (: x : (foo Any)) >>>> >> (define x (foo 1)) >>>> >> >>>> >> (ann (foo-a x) Integer) >>>> >> >>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>> >> arguments: >>>> >> ;Argument 1: >>>> >> ; Expected: a >>>> >> ; Given: Any >>>> >> ; >>>> >> ;Result type: (foo a) >>>> >> ;Expected result: (foo Integer) >>>> >> ; in: (foo (ann 1 Any)) >>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>> >> arguments: >>>> >> ;Argument 1: >>>> >> ; Expected: (foo a) >>>> >> ; Given: (foo Any) >>>> >> ; >>>> >> ;Result type: (a : ....) >>>> >> ;Expected result: Integer >>>> >> ; in: (foo-a x) >>>> >> >>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>> >> wrote: >>>> >> >>>> >> What I?m trying to accomplish is something more like this: >>>> >> #lang typed/racket >>>> >> >>>> >> (require "dimensions.rkt") >>>> >> >>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>> >> #:transparent >>>> >> #:guard (lambda (name scalar dimension _) >>>> >> (unless (dimension? dimension) >>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>> >> (values name scalar dimension))) >>>> >> >>>> >> (define-type (Unitof d) (unit d)) >>>> >> >>>> >> (define-type Unit (Unitof Dimension)) >>>> >> >>>> >> (define Unit? (make-predicate Unit)) >>>> >> >>>> >> (define-type Unitish >>>> >> (U (Unitof Any) >>>> >> Dimension >>>> >> Positive-Real)) >>>> >> >>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>> >> [Unitish -> Unit]))) >>>> >> (define (->unit u) >>>> >> (cond [(unit? u) >>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>> >> guard >>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>> >> u] >>>> >> [(dimension? u) (unit u 1 u)] >>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>> >> >>>> >> >>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>> >> wrote: >>>> >> >>>> >> No, I don't think you can do this. Can you say more about what you're >>>> >> trying to accomplish? >>>> >> >>>> >> Sam >>>> >> >>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>> >> wrote: >>>> >> >>>> >> Do any of you have any advice for getting a function like this to >>>> >> type-check? >>>> >> #lang typed/racket >>>> >> >>>> >> (: check-int : (All (a) (case-> [a -> a] >>>> >> [Any -> Integer]))) >>>> >> (define (check-int int) >>>> >> (unless (exact-integer? int) >>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>> >> int) >>>> >> >>>> >> ;. Type Checker: type mismatch >>>> >> ; expected: a >>>> >> ; given: Integer in: int >>>> >> >>>> >> >>>> >> >>>> >> ____________________ >>>> >> Racket Users list: >>>> >> http://lists.racket-lang.org/users >>>> >> >>>> >> >>>> >> ____________________ >>>> >> Racket Users list: >>>> >> http://lists.racket-lang.org/users >>>> >> >>>> >> >>>> >>>> >>>> ____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >>>> >>>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Sun Sep 28 22:03:02 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 28 Sep 2014 22:03:02 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> Message-ID: <6237F562-9E68-4D2D-A307-49668BB8E5DF@knauth.org> On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: > > Your message points out where gradual typing badly fails. > > Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. > > In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write > > area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] > > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. > > This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. Is this sort of like what happens with flonum unboxing? > > Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. > > -- Matthias > > > > > > > > > On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: > >> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >> >> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >> >> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >> >> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >> >>> >>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>> >>> >>> >>> >>> >>> >>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>> >>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>> >>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>> >>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>> >>>>> would something like this work? >>>>> >>>>> #lang typed/racket >>>>> >>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>> >>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>> (define-type Weight (number+unit Weight-Unit)) >>>>> (define-predicate weight? Weight) >>>>> >>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>> (define (make-weight n u) >>>>> (number+unit n u)) >>>>> >>>>> (: +/weight : Weight Weight -> Weight) >>>>> ;; something something needs unit conversion >>>>> (define (+/weight w1 w2) >>>>> (number+unit (+ (number+unit-amount w1) >>>>> (number+unit-amount w1)) >>>>> (number+unit-unit w1))) >>>>> >>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>> >>>>> >>>>> >>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>> >>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>> >>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>> >>>>> > Why not do this with the type, instead of making this polymorphic? >>>>> > >>>>> > Sam >>>>> > >>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>> > wrote: >>>>> >> Is it possible to have a struct that does certain things according to the >>>>> >> guard? >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>> >> #:guard (lambda (a _) >>>>> >> (unless (exact-integer? a) >>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>> >> a)) >>>>> >> >>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>> >> >>>>> >> (: x : (foo Any)) >>>>> >> (define x (foo 1)) >>>>> >> >>>>> >> (ann (foo-a x) Integer) >>>>> >> >>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>> >> arguments: >>>>> >> ;Argument 1: >>>>> >> ; Expected: a >>>>> >> ; Given: Any >>>>> >> ; >>>>> >> ;Result type: (foo a) >>>>> >> ;Expected result: (foo Integer) >>>>> >> ; in: (foo (ann 1 Any)) >>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>> >> arguments: >>>>> >> ;Argument 1: >>>>> >> ; Expected: (foo a) >>>>> >> ; Given: (foo Any) >>>>> >> ; >>>>> >> ;Result type: (a : ....) >>>>> >> ;Expected result: Integer >>>>> >> ; in: (foo-a x) >>>>> >> >>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>> >> wrote: >>>>> >> >>>>> >> What I?m trying to accomplish is something more like this: >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (require "dimensions.rkt") >>>>> >> >>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>> >> #:transparent >>>>> >> #:guard (lambda (name scalar dimension _) >>>>> >> (unless (dimension? dimension) >>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>> >> (values name scalar dimension))) >>>>> >> >>>>> >> (define-type (Unitof d) (unit d)) >>>>> >> >>>>> >> (define-type Unit (Unitof Dimension)) >>>>> >> >>>>> >> (define Unit? (make-predicate Unit)) >>>>> >> >>>>> >> (define-type Unitish >>>>> >> (U (Unitof Any) >>>>> >> Dimension >>>>> >> Positive-Real)) >>>>> >> >>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>> >> [Unitish -> Unit]))) >>>>> >> (define (->unit u) >>>>> >> (cond [(unit? u) >>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>> >> guard >>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>> >> u] >>>>> >> [(dimension? u) (unit u 1 u)] >>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>> >> >>>>> >> >>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>> >> wrote: >>>>> >> >>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>> >> trying to accomplish? >>>>> >> >>>>> >> Sam >>>>> >> >>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>> >> wrote: >>>>> >> >>>>> >> Do any of you have any advice for getting a function like this to >>>>> >> type-check? >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>> >> [Any -> Integer]))) >>>>> >> (define (check-int int) >>>>> >> (unless (exact-integer? int) >>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>> >> int) >>>>> >> >>>>> >> ;. Type Checker: type mismatch >>>>> >> ; expected: a >>>>> >> ; given: Integer in: int >>>>> >> >>>>> >> >>>>> >> >>>>> >> ____________________ >>>>> >> Racket Users list: >>>>> >> http://lists.racket-lang.org/users >>>>> >> >>>>> >> >>>>> >> ____________________ >>>>> >> Racket Users list: >>>>> >> http://lists.racket-lang.org/users >>>>> >> >>>>> >> >>>>> >>>>> >>>>> ____________________ >>>>> Racket Users list: >>>>> http://lists.racket-lang.org/users >>>>> >>>>> >>>> >>>> ____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Sun Sep 28 22:29:31 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Sun, 28 Sep 2014 22:29:31 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <6237F562-9E68-4D2D-A307-49668BB8E5DF@knauth.org> References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> <6237F562-9E68-4D2D-A307-49668BB8E5DF@knauth.org> Message-ID: <6ADD4F6D-6B79-4F32-AD11-379CD2FF87AB@ccs.neu.edu> You might be able to unwrap such things for a local context, but then you need to wrap it again on the way out. That cost might become quite high if it happens in a loop. Then again Racket programs rely on this a lot too (as do many dynamically typed programs) so it might not be a cost that kills performance completely. But do be aware of how others deal with this issue -- Matthias On Sep 28, 2014, at 10:03 PM, Alexander D. Knauth wrote: > > > On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: > >> >> Your message points out where gradual typing badly fails. >> >> Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. >> >> In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write >> >> area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] >> >> If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. >> >> This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. > > What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. > > And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. > > Is this sort of like what happens with flonum unboxing? > > > >> >> Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. >> >> -- Matthias >> >> >> >> >> >> >> >> >> On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: >> >>> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >>> >>> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >>> >>> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >>> >>> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >>> >>>> >>>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>>> >>>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>>> >>>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>>> >>>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>>> >>>>>> would something like this work? >>>>>> >>>>>> #lang typed/racket >>>>>> >>>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>>> >>>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>>> (define-type Weight (number+unit Weight-Unit)) >>>>>> (define-predicate weight? Weight) >>>>>> >>>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>>> (define (make-weight n u) >>>>>> (number+unit n u)) >>>>>> >>>>>> (: +/weight : Weight Weight -> Weight) >>>>>> ;; something something needs unit conversion >>>>>> (define (+/weight w1 w2) >>>>>> (number+unit (+ (number+unit-amount w1) >>>>>> (number+unit-amount w1)) >>>>>> (number+unit-unit w1))) >>>>>> >>>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>>> >>>>>> >>>>>> >>>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>>> >>>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>>> >>>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>>> >>>>>> > Why not do this with the type, instead of making this polymorphic? >>>>>> > >>>>>> > Sam >>>>>> > >>>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>>> > wrote: >>>>>> >> Is it possible to have a struct that does certain things according to the >>>>>> >> guard? >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>>> >> #:guard (lambda (a _) >>>>>> >> (unless (exact-integer? a) >>>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>>> >> a)) >>>>>> >> >>>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>>> >> >>>>>> >> (: x : (foo Any)) >>>>>> >> (define x (foo 1)) >>>>>> >> >>>>>> >> (ann (foo-a x) Integer) >>>>>> >> >>>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>>> >> arguments: >>>>>> >> ;Argument 1: >>>>>> >> ; Expected: a >>>>>> >> ; Given: Any >>>>>> >> ; >>>>>> >> ;Result type: (foo a) >>>>>> >> ;Expected result: (foo Integer) >>>>>> >> ; in: (foo (ann 1 Any)) >>>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>>> >> arguments: >>>>>> >> ;Argument 1: >>>>>> >> ; Expected: (foo a) >>>>>> >> ; Given: (foo Any) >>>>>> >> ; >>>>>> >> ;Result type: (a : ....) >>>>>> >> ;Expected result: Integer >>>>>> >> ; in: (foo-a x) >>>>>> >> >>>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>>> >> wrote: >>>>>> >> >>>>>> >> What I?m trying to accomplish is something more like this: >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (require "dimensions.rkt") >>>>>> >> >>>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>>> >> #:transparent >>>>>> >> #:guard (lambda (name scalar dimension _) >>>>>> >> (unless (dimension? dimension) >>>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>>> >> (values name scalar dimension))) >>>>>> >> >>>>>> >> (define-type (Unitof d) (unit d)) >>>>>> >> >>>>>> >> (define-type Unit (Unitof Dimension)) >>>>>> >> >>>>>> >> (define Unit? (make-predicate Unit)) >>>>>> >> >>>>>> >> (define-type Unitish >>>>>> >> (U (Unitof Any) >>>>>> >> Dimension >>>>>> >> Positive-Real)) >>>>>> >> >>>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>>> >> [Unitish -> Unit]))) >>>>>> >> (define (->unit u) >>>>>> >> (cond [(unit? u) >>>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>>> >> guard >>>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>>> >> u] >>>>>> >> [(dimension? u) (unit u 1 u)] >>>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>>> >> >>>>>> >> >>>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>>> >> wrote: >>>>>> >> >>>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>>> >> trying to accomplish? >>>>>> >> >>>>>> >> Sam >>>>>> >> >>>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>>> >> wrote: >>>>>> >> >>>>>> >> Do any of you have any advice for getting a function like this to >>>>>> >> type-check? >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>>> >> [Any -> Integer]))) >>>>>> >> (define (check-int int) >>>>>> >> (unless (exact-integer? int) >>>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>>> >> int) >>>>>> >> >>>>>> >> ;. Type Checker: type mismatch >>>>>> >> ; expected: a >>>>>> >> ; given: Integer in: int >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> ____________________ >>>>>> >> Racket Users list: >>>>>> >> http://lists.racket-lang.org/users >>>>>> >> >>>>>> >> >>>>>> >> ____________________ >>>>>> >> Racket Users list: >>>>>> >> http://lists.racket-lang.org/users >>>>>> >> >>>>>> >> >>>>>> >>>>>> >>>>>> ____________________ >>>>>> Racket Users list: >>>>>> http://lists.racket-lang.org/users >>>>>> >>>>>> >>>>> >>>>> ____________________ >>>>> Racket Users list: >>>>> http://lists.racket-lang.org/users >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at knauth.org Sun Sep 28 23:00:17 2014 From: alexander at knauth.org (Alexander D. Knauth) Date: Sun, 28 Sep 2014 23:00:17 -0400 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> <6237F562-9E68-4D2D-A307-49668BB8E5DF@knauth.org> <6ADD4F6D-6B79-4F32-AD11-379CD2FF87AB@ccs.neu.edu> Message-ID: <0BDCBA09-5AA1-410A-A954-D2B6A8B30465@knauth.org> I just realized that typed racket seems to ignore the guard anyway, so I could do something like this and convince the type-checker that any value I want has any type that I want: (struct (a) foo ([a : a]) #:guard (lambda (a _) "this value")) (: x : (foo 1)) (define x (foo 1)) > (foo-a x) - : Integer [more precisely: One] "this value? On Sep 28, 2014, at 10:41 PM, Benjamin Greenman wrote: > I was able to get something very similar to your example program to compile. > > (struct (a) foo ([a : a]) #:transparent > #:guard (lambda (a _) > (define a* a) ;; a* not "polluted" by occurrence typing > (unless (exact-integer? a) > (error 'foo "expected Integer, given ~v" a)) > a*)) ;; we return a value of type a, so the typechecker is happy > > From here, you can safely cast a foo-a into an Integer. It's not type safe to ann because we (deliberately) don't have the occurrence typing information, but we the programmers can be sure that the casts will never fail. > > (cast (foo (ann 1 Any)) (foo Integer)) > > (foo 1) > > > > On Sun, Sep 28, 2014 at 10:29 PM, Matthias Felleisen wrote: > > You might be able to unwrap such things for a local context, but then you need to wrap it again on the way out. That cost might become quite high if it happens in a loop. Then again Racket programs rely on this a lot too (as do many dynamically typed programs) so it might not be a cost that kills performance completely. But do be aware of how others deal with this issue -- Matthias > > > > > > > > On Sep 28, 2014, at 10:03 PM, Alexander D. Knauth wrote: > >> >> >> On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: >> >>> >>> Your message points out where gradual typing badly fails. >>> >>> Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. >>> >>> In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write >>> >>> area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] >>> >>> If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. >>> >>> This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. >> >> What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. >> >> And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. >> >> Is this sort of like what happens with flonum unboxing? >> >> >> >>> >>> Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. >>> >>> -- Matthias >>> >>> >>> >>> >>> >>> >>> >>> >>> On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: >>> >>>> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >>>> >>>> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >>>> >>>> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >>>> >>>> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >>>> >>>>> >>>>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>>>> >>>>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>>>> >>>>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>>>> >>>>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>>>> >>>>>>> would something like this work? >>>>>>> >>>>>>> #lang typed/racket >>>>>>> >>>>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>>>> >>>>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>>>> (define-type Weight (number+unit Weight-Unit)) >>>>>>> (define-predicate weight? Weight) >>>>>>> >>>>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>>>> (define (make-weight n u) >>>>>>> (number+unit n u)) >>>>>>> >>>>>>> (: +/weight : Weight Weight -> Weight) >>>>>>> ;; something something needs unit conversion >>>>>>> (define (+/weight w1 w2) >>>>>>> (number+unit (+ (number+unit-amount w1) >>>>>>> (number+unit-amount w1)) >>>>>>> (number+unit-unit w1))) >>>>>>> >>>>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>>>> >>>>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>>>> >>>>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>>>> >>>>>>> > Why not do this with the type, instead of making this polymorphic? >>>>>>> > >>>>>>> > Sam >>>>>>> > >>>>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>>>> > wrote: >>>>>>> >> Is it possible to have a struct that does certain things according to the >>>>>>> >> guard? >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>>>> >> #:guard (lambda (a _) >>>>>>> >> (unless (exact-integer? a) >>>>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>>>> >> a)) >>>>>>> >> >>>>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>>>> >> >>>>>>> >> (: x : (foo Any)) >>>>>>> >> (define x (foo 1)) >>>>>>> >> >>>>>>> >> (ann (foo-a x) Integer) >>>>>>> >> >>>>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>>>> >> arguments: >>>>>>> >> ;Argument 1: >>>>>>> >> ; Expected: a >>>>>>> >> ; Given: Any >>>>>>> >> ; >>>>>>> >> ;Result type: (foo a) >>>>>>> >> ;Expected result: (foo Integer) >>>>>>> >> ; in: (foo (ann 1 Any)) >>>>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>>>> >> arguments: >>>>>>> >> ;Argument 1: >>>>>>> >> ; Expected: (foo a) >>>>>>> >> ; Given: (foo Any) >>>>>>> >> ; >>>>>>> >> ;Result type: (a : ....) >>>>>>> >> ;Expected result: Integer >>>>>>> >> ; in: (foo-a x) >>>>>>> >> >>>>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> What I?m trying to accomplish is something more like this: >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (require "dimensions.rkt") >>>>>>> >> >>>>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>>>> >> #:transparent >>>>>>> >> #:guard (lambda (name scalar dimension _) >>>>>>> >> (unless (dimension? dimension) >>>>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>>>> >> (values name scalar dimension))) >>>>>>> >> >>>>>>> >> (define-type (Unitof d) (unit d)) >>>>>>> >> >>>>>>> >> (define-type Unit (Unitof Dimension)) >>>>>>> >> >>>>>>> >> (define Unit? (make-predicate Unit)) >>>>>>> >> >>>>>>> >> (define-type Unitish >>>>>>> >> (U (Unitof Any) >>>>>>> >> Dimension >>>>>>> >> Positive-Real)) >>>>>>> >> >>>>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>>>> >> [Unitish -> Unit]))) >>>>>>> >> (define (->unit u) >>>>>>> >> (cond [(unit? u) >>>>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>>>> >> guard >>>>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>>>> >> u] >>>>>>> >> [(dimension? u) (unit u 1 u)] >>>>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>>>> >> >>>>>>> >> >>>>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>>>> >> trying to accomplish? >>>>>>> >> >>>>>>> >> Sam >>>>>>> >> >>>>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> Do any of you have any advice for getting a function like this to >>>>>>> >> type-check? >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>>>> >> [Any -> Integer]))) >>>>>>> >> (define (check-int int) >>>>>>> >> (unless (exact-integer? int) >>>>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>>>> >> int) >>>>>>> >> >>>>>>> >> ;. Type Checker: type mismatch >>>>>>> >> ; expected: a >>>>>>> >> ; given: Integer in: int >>>>>>> >> >>>>>>> >> >>>>>>> >> >>>>>>> >> ____________________ >>>>>>> >> Racket Users list: >>>>>>> >> http://lists.racket-lang.org/users >>>>>>> >> >>>>>>> >> >>>>>>> >> ____________________ >>>>>>> >> Racket Users list: >>>>>>> >> http://lists.racket-lang.org/users >>>>>>> >> >>>>>>> >> >>>>>>> >>>>>>> >>>>>>> ____________________ >>>>>>> Racket Users list: >>>>>>> http://lists.racket-lang.org/users >>>>>>> >>>>>>> >>>>>> >>>>>> ____________________ >>>>>> Racket Users list: >>>>>> http://lists.racket-lang.org/users >>>>> >>>> >>> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jab at math.brown.edu Sun Sep 28 23:36:05 2014 From: jab at math.brown.edu (jab at math.brown.edu) Date: Sun, 28 Sep 2014 23:36:05 -0400 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: On Wed, Sep 17, 2014 at 10:51 AM, Sam Tobin-Hochstadt wrote: > I've now created a wiki page for this, with some initial content: > https://github.com/plt/racket/wiki/Courses-using-Racket > And now it's up to 22 revisions! Thanks for creating, Sam, and to everyone who added to it. On Tue, Sep 16, 2014 at 8:43 PM, Matthias Felleisen > wrote: > > Do you imagine listing college courses such as Brown's 17, which uses > > DrRacket and the teaching languages? Or do you want Coursera courses that > > everyone can access? > I think linking to any class that makes educational materials publicly available is valuable, but they should be divided into one section for classes that don't require being admitted into a larger institution to participate in (e.g. Bootstrap World, Coursera, summer programs for teens, etc.), and another section for those that do. > > And yes, we should probably create a wiki like thing for such an effort > or > > perhaps something like packages.racket-lang.org. I'll bring it up as we > meet > > in St Louis. > Thanks, Matthias, and hope you all had a great time in St Louis. Looks like it was a wonderful conference. Can the wiki page above be directly linked off racket-lang.org, perhaps a bit more prominently? I hadn't even noticed https://github.com/plt/racket/wiki before; now I see the link to it kind of buried under the Contributing column of the Community section. Perhaps it's not easy to find for others too. Thanks again for following up on this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Mon Sep 29 04:44:56 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Mon, 29 Sep 2014 10:44:56 +0200 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> Message-ID: <21545.7176.252047.613404@Ordinateur-de-Catherine-Konrad.local> Matthias Felleisen writes: > Your message points out where gradual typing badly fails. Not just gradual typing. I am not aware of any good unit implementation in any type system, with the exception of F# and Frink whose type systems were explicitly modified to add unit checking as a special case. Dependent types should permit a good solution, but I haven't seen it done yet. The reason you need dependent types is that the product of two measures is another measure with a new unit, so you must be able to construct new types (representing units) from values. For example, a length divided by a time yields a speed. Once you can do that, scaling a unit (e.g. from meters to kilometers) becomes a special case. > In this specific case, you have two aspects of dimensionality: > dimension per se (I am sure there is a word for it) and the chosen > unit to represent it. The two terms used for this distinction are in fact "dimension" and "unit". > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is > nothing wrong with it -- except that the type checker should insert > a coercion from mm to m and from km to m (multiplying/dividing by > 1,000). That's a topic of hot debate in the scientific computing community. Some argue that the type checker should consider your example as an error, and not do any implicit conversion. The motivation is that the expression you used is more likely to be a mistake than the meaningful use of expressive language, since best practices recommend to use a minimal set of units inside any piece of code. Anyway, that's a minor detail. If your type system can handle automatic conversion, then it can also handle its absence. Alexander D. Knauth writes: > What I had in mind was for the structs to be available at run-time, > but that ideally the optimizer could take them out for the > intermediate operations and put them back for the final result. You are actually adding a very Racket-specific requirement to the already difficult units-as-types problem: the interplay between a typed and an untyped dialect of the same language. I agree this would be nice to have. Konrad. From greghendershott at gmail.com Mon Sep 29 09:13:11 2014 From: greghendershott at gmail.com (Greg Hendershott) Date: Mon, 29 Sep 2014 09:13:11 -0400 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> <73617243-E0D5-43C6-872B-EA0121AD5142@astro.gla.ac.uk> Message-ID: It looks like the package server did eventually refresh a few hours ago: Last Updated: 9/28/2014, 4:21:56 PM ;change on GitHub Last Checked: 9/29/2014, 7:51:37 AM ;pkgs.r-l.org refresh (I believe those times are US MT, -0600.) On Sun, Sep 28, 2014 at 6:10 PM, Greg Hendershott wrote: > If you're in a hurry you could remove and re-install directly from GitHub: > > $ raco pkg remove aws > $ raco pkg install git://github.com/greghendershott/aws > > On Sun, Sep 28, 2014 at 5:40 PM, Norman Gray wrote: >> >> On 2014 Sep 28, at 22:17, Greg Hendershott wrote: >> >>>>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>>>> than usual to refresh. After it does, you can `raco pkg update aws` to >>>>> get the fix. >>>> >>>> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >>>> >>>> "update upload in progress: there may be inconsistencies below" >>>> >>>> It's been saying that for nearly an hour. >>> >>> Sometimes instead it says: >>> >>> "update upload being computed: the information below may not >>> represent all recent changes and updates" >>> >>> It has switched between those two messages at various intervals over >>> the last hour. >> >> And in case it's a useful data point, I'm getting >> >> % raco pkg update aws >> Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ >> Resolving "aws" via http://pkgs.racket-lang.org >> No updates available >> % >> >> And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... >> >> Norman >> >> >> -- >> Norman Gray : http://nxg.me.uk >> SUPA School of Physics and Astronomy, University of Glasgow, UK >> From ckkashyap at gmail.com Mon Sep 29 09:39:17 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Mon, 29 Sep 2014 19:09:17 +0530 Subject: [racket] rsound docs Message-ID: Hi, I saw this nice racketcon video ( https://www.youtube.com/watch?v=DkIVzHNjNEA&list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2Gdh&index=9) on rsound. I've installed the rsound package and have been able to run the example from the video. Is there a place that has mode documentation/tutorial on rsound? Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Mon Sep 29 10:32:40 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 29 Sep 2014 09:32:40 -0500 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: <21545.7176.252047.613404@Ordinateur-de-Catherine-Konrad.local> References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> <21545.7176.252047.613404@Ordinateur-de-Catherine-Konrad.local> Message-ID: Just in case, here is one piece of related work from the PL world and is probably a reasonable starting point for finding others' attempts at this problem: http://research.microsoft.com/en-us/um/people/akenn/units/ Robby On Mon, Sep 29, 2014 at 3:44 AM, Konrad Hinsen wrote: > Matthias Felleisen writes: > > > Your message points out where gradual typing badly fails. > > Not just gradual typing. I am not aware of any good unit > implementation in any type system, with the exception of F# and Frink > whose type systems were explicitly modified to add unit checking as a > special case. Dependent types should permit a good solution, but I > haven't seen it done yet. > > The reason you need dependent types is that the product of two > measures is another measure with a new unit, so you must be able to > construct new types (representing units) from values. For example, a > length divided by a time yields a speed. Once you can do that, scaling > a unit (e.g. from meters to kilometers) becomes a special case. > > > In this specific case, you have two aspects of dimensionality: > > dimension per se (I am sure there is a word for it) and the chosen > > unit to represent it. > > The two terms used for this distinction are in fact "dimension" and > "unit". > > > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is > > nothing wrong with it -- except that the type checker should insert > > a coercion from mm to m and from km to m (multiplying/dividing by > > 1,000). > > That's a topic of hot debate in the scientific computing community. > Some argue that the type checker should consider your example as an > error, and not do any implicit conversion. The motivation is that the > expression you used is more likely to be a mistake than the meaningful > use of expressive language, since best practices recommend to use a > minimal set of units inside any piece of code. > > Anyway, that's a minor detail. If your type system can handle > automatic conversion, then it can also handle its absence. > > > Alexander D. Knauth writes: > > > What I had in mind was for the structs to be available at run-time, > > but that ideally the optimizer could take them out for the > > intermediate operations and put them back for the final result. > > You are actually adding a very Racket-specific requirement to the > already difficult units-as-types problem: the interplay between a > typed and an untyped dialect of the same language. I agree this would > be nice to have. > > Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From emanonhere at gmx.com Mon Sep 29 11:14:43 2014 From: emanonhere at gmx.com (rrandom) Date: Mon, 29 Sep 2014 23:14:43 +0800 Subject: [racket] Is there any way to get the bit depth of a bitmap? Message-ID: <54297763.3020407@gmx.com> Hi,I am recently working in the book Digital Image Processing with racket. I want to know is there any way to get the bit depth or color depth of a input bitmap in Racket? I found the get-depth method in racket/draw,bitmap%, but it only return 1 and 32, that's not what i really want.I input a bitmap whose bit depth is 8 but i got 32. following is the code: > (send (read-bitmap "Fig0305(a)(DFT_no_log).tif") get-depth) 32 Is there anything I am wrong? Thank you! From mflatt at cs.utah.edu Mon Sep 29 11:24:07 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Mon, 29 Sep 2014 09:24:07 -0600 Subject: [racket] Is there any way to get the bit depth of a bitmap? In-Reply-To: <54297763.3020407@gmx.com> References: <54297763.3020407@gmx.com> Message-ID: <20140929152408.F0E42650192@mail-svr1.cs.utah.edu> Racket libraries can read and write images of various formats and pixels depths, but a `bitmap%` object always represents an image using 1 or 32 bits per pixel in memory. At Mon, 29 Sep 2014 23:14:43 +0800, rrandom wrote: > Hi,I am recently working in the book Digital Image Processing with > racket. I want to know is there any way to get the bit depth or color > depth of a input bitmap in Racket? I found the get-depth method in > racket/draw,bitmap%, but it only return 1 and 32, that's not what i > really want.I input a bitmap whose bit depth is 8 but i got 32. > following is the code: > > > (send (read-bitmap "Fig0305(a)(DFT_no_log).tif") > get-depth) > 32 > > Is there anything I am wrong? Thank you! > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From mflatt at cs.utah.edu Mon Sep 29 11:28:14 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Mon, 29 Sep 2014 09:28:14 -0600 Subject: [racket] rsound docs In-Reply-To: References: Message-ID: <20140929152815.C87E6650194@mail-svr1.cs.utah.edu> When you install the package, you also install documentation for RSound. You should be able to find it by selecting "Racket Documentation" from the "Help" menu in DrRacket, by right-clicking on an identifier in DrRacket that is provided by the package's library, or by running `raco docs` on the command line. You can also find documentation linked from the "rsound" entry at http://pkgs.racket-lang.org/, which goes to http://pkg-build.racket-lang.org/doc/rsound/index.html At Mon, 29 Sep 2014 19:09:17 +0530, C K Kashyap wrote: > Hi, > > I saw this nice racketcon video ( > https://www.youtube.com/watch?v=DkIVzHNjNEA&list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2 > Gdh&index=9) > on rsound. I've installed the rsound package and have been able to run the > example from the video. > > Is there a place that has mode documentation/tutorial on rsound? > > Regards, > Kashyap > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From robby at eecs.northwestern.edu Mon Sep 29 11:40:08 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 29 Sep 2014 10:40:08 -0500 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> <21545.7176.252047.613404@Ordinateur-de-Catherine-Konrad.local> Message-ID: Whoops, sorry: this is the same thing Konrad was talking about! Duh. Well, hopefully the link is useful. Robby On Mon, Sep 29, 2014 at 9:32 AM, Robby Findler wrote: > Just in case, here is one piece of related work from the PL world and > is probably a reasonable starting point for finding others' attempts > at this problem: > > http://research.microsoft.com/en-us/um/people/akenn/units/ > > Robby > > > On Mon, Sep 29, 2014 at 3:44 AM, Konrad Hinsen > wrote: >> Matthias Felleisen writes: >> >> > Your message points out where gradual typing badly fails. >> >> Not just gradual typing. I am not aware of any good unit >> implementation in any type system, with the exception of F# and Frink >> whose type systems were explicitly modified to add unit checking as a >> special case. Dependent types should permit a good solution, but I >> haven't seen it done yet. >> >> The reason you need dependent types is that the product of two >> measures is another measure with a new unit, so you must be able to >> construct new types (representing units) from values. For example, a >> length divided by a time yields a speed. Once you can do that, scaling >> a unit (e.g. from meters to kilometers) becomes a special case. >> >> > In this specific case, you have two aspects of dimensionality: >> > dimension per se (I am sure there is a word for it) and the chosen >> > unit to represent it. >> >> The two terms used for this distinction are in fact "dimension" and >> "unit". >> >> > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is >> > nothing wrong with it -- except that the type checker should insert >> > a coercion from mm to m and from km to m (multiplying/dividing by >> > 1,000). >> >> That's a topic of hot debate in the scientific computing community. >> Some argue that the type checker should consider your example as an >> error, and not do any implicit conversion. The motivation is that the >> expression you used is more likely to be a mistake than the meaningful >> use of expressive language, since best practices recommend to use a >> minimal set of units inside any piece of code. >> >> Anyway, that's a minor detail. If your type system can handle >> automatic conversion, then it can also handle its absence. >> >> >> Alexander D. Knauth writes: >> >> > What I had in mind was for the structs to be available at run-time, >> > but that ideally the optimizer could take them out for the >> > intermediate operations and put them back for the final result. >> >> You are actually adding a very Racket-specific requirement to the >> already difficult units-as-types problem: the interplay between a >> typed and an untyped dialect of the same language. I agree this would >> be nice to have. >> >> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From konrad.hinsen at fastmail.net Mon Sep 29 12:10:29 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Mon, 29 Sep 2014 18:10:29 +0200 Subject: [racket] Cyclic data structures in Typed Racket Message-ID: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> Hi everyone, I am trying to port code creating a cyclic data structure to Typed Racket, but notice that this is not as straightforward as I expected. Here is the untyped code I start from: #lang racket (struct foo (x) #:mutable) (struct bar (x)) (define-values (f b) (shared ([f (foo b)] [b (bar f)]) (values f b))) (eq? (bar-x b) f) (eq? (foo-x f) b) Switching to Typed Racket and annotating the struct definitions, I get an error message saying that make-placeholder and placeholder-set! from racket/base are lacking type annotations. I also get the recommendation to use require/typed for importing them. OK, let's try: #lang typed/racket (require/typed racket/base [#:opaque Placeholder placeholder?] [make-placeholder (-> Any Placeholder)] [placeholder-set! (-> Placeholder Any Void)]) (struct foo ([x : bar]) #:mutable) (struct bar ([x : foo])) (define-values (f b) (shared ([f (foo b)] [b (bar f)]) (values f b))) (eq? (bar-x b) f) (eq? (foo-x f) b) Same error message... which is not really surprising. I suppose typed/racket already requires racket/base, so my additional require/typed has no effect. But how can I fix this? I don't see any way to exclude items from typed/racket. Konrad. From samth at cs.indiana.edu Mon Sep 29 12:17:29 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Mon, 29 Sep 2014 12:17:29 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: I recommend doing the mutation yourself, and not using `shared`. That's the most obvious solution. The reason that your `require/typed` doesn't work is that it creates new versions of the placeholder functions, but those aren't the ones that `shared` uses internally, so Typed Racket doesn't use the types you've given. Note also that the types you gave aren't safe -- the way shared uses placeholders expects particular types for particular ones (this would result in a contract error at runtime if `shared` used your bindings). Sam On Mon, Sep 29, 2014 at 12:10 PM, Konrad Hinsen wrote: > Hi everyone, > > I am trying to port code creating a cyclic data structure to Typed > Racket, but notice that this is not as straightforward as I expected. > > Here is the untyped code I start from: > > #lang racket > > (struct foo (x) #:mutable) > (struct bar (x)) > > (define-values (f b) > (shared ([f (foo b)] > [b (bar f)]) > (values f b))) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > Switching to Typed Racket and annotating the struct definitions, I get > an error message saying that make-placeholder and placeholder-set! > from racket/base are lacking type annotations. I also get the recommendation > to use require/typed for importing them. OK, let's try: > > #lang typed/racket > > (require/typed racket/base > [#:opaque Placeholder placeholder?] > [make-placeholder (-> Any Placeholder)] > [placeholder-set! (-> Placeholder Any Void)]) > > (struct foo ([x : bar]) #:mutable) > (struct bar ([x : foo])) > > (define-values (f b) > (shared ([f (foo b)] > [b (bar f)]) > (values f b))) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > Same error message... which is not really surprising. I suppose typed/racket > already requires racket/base, so my additional require/typed has no effect. > But how can I fix this? I don't see any way to exclude items from typed/racket. > > Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From konrad.hinsen at fastmail.net Mon Sep 29 12:33:38 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Mon, 29 Sep 2014 18:33:38 +0200 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> Sam Tobin-Hochstadt writes: > I recommend doing the mutation yourself, and not using `shared`. > That's the most obvious solution. Not for me, unfortunately, but probably I am missing something obvious. Here's explicit mutation in untyped Racket: #lang racket (struct foo (x) #:mutable) (struct bar (x)) (define f (foo (void))) (define b (bar f)) (set-foo-x! f b) (eq? (bar-x b) f) (eq? (foo-x f) b) That works fine. Moving to Typed Racket, this is rejected by the type checker because (void) is of type Void. Since I need a bar to make a foo and a foo to make a bar, I don't see how I can ever initialize my foo structure. > The reason that your `require/typed` doesn't work is that it creates > new versions of the placeholder functions, but those aren't the ones > that `shared` uses internally, so Typed Racket doesn't use the types > you've given. That makes sense, thanks for the explanation! Konrad. From samth at cs.indiana.edu Mon Sep 29 12:52:25 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Mon, 29 Sep 2014 12:52:25 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: Ah, if you want to create truly cyclic structure with no base case like this, then you'll have to do more work. Either you'll need to expand the type of the `x` field in `foo` to allow an initial value, or you'll need to create a dummy `foo` with that extended type, and then copy the cyclic data once you've created it to a new version of `foo`, using hash tables to track cycles. That's basically how `shared` works, although I haven't tried implementing it in TR and it might not be possible. Sam On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen wrote: > Sam Tobin-Hochstadt writes: > > > I recommend doing the mutation yourself, and not using `shared`. > > That's the most obvious solution. > > Not for me, unfortunately, but probably I am missing something > obvious. > > Here's explicit mutation in untyped Racket: > > #lang racket > > (struct foo (x) #:mutable) > (struct bar (x)) > > (define f (foo (void))) > (define b (bar f)) > (set-foo-x! f b) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > That works fine. Moving to Typed Racket, this is rejected by the type > checker because (void) is of type Void. Since I need a bar to make a > foo and a foo to make a bar, I don't see how I can ever initialize my > foo structure. > > > The reason that your `require/typed` doesn't work is that it creates > > new versions of the placeholder functions, but those aren't the ones > > that `shared` uses internally, so Typed Racket doesn't use the types > > you've given. > > That makes sense, thanks for the explanation! > > Konrad. From blg59 at cornell.edu Mon Sep 29 14:00:12 2014 From: blg59 at cornell.edu (Benjamin Greenman) Date: Mon, 29 Sep 2014 14:00:12 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: To be sure: Is there any TR analog to this OCaml code, initializing a cyclic, 3-element list? I've tried using letrec in TR, but the typechecker yells at me even if I annotate the a,b,c,d. # type 'a mylist = Nil | Cons of 'a * 'a mylist;; type 'a mylist = Nil | Cons of 'a * 'a mylist # let mylist = let rec a = Cons(1, b) and b = Cons(2, c) and c = Cons(3, d) and d = Cons(4, a) in a;; val mylist : int mylist = Cons (1, Cons (2, Cons (3, Cons (4, )))) On Mon, Sep 29, 2014 at 12:52 PM, Sam Tobin-Hochstadt wrote: > Ah, if you want to create truly cyclic structure with no base case > like this, then you'll have to do more work. Either you'll need to > expand the type of the `x` field in `foo` to allow an initial value, > or you'll need to create a dummy `foo` with that extended type, and > then copy the cyclic data once you've created it to a new version of > `foo`, using hash tables to track cycles. That's basically how > `shared` works, although I haven't tried implementing it in TR and it > might not be possible. > > Sam > > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen > wrote: > > Sam Tobin-Hochstadt writes: > > > > > I recommend doing the mutation yourself, and not using `shared`. > > > That's the most obvious solution. > > > > Not for me, unfortunately, but probably I am missing something > > obvious. > > > > Here's explicit mutation in untyped Racket: > > > > #lang racket > > > > (struct foo (x) #:mutable) > > (struct bar (x)) > > > > (define f (foo (void))) > > (define b (bar f)) > > (set-foo-x! f b) > > > > (eq? (bar-x b) f) > > (eq? (foo-x f) b) > > > > That works fine. Moving to Typed Racket, this is rejected by the type > > checker because (void) is of type Void. Since I need a bar to make a > > foo and a foo to make a bar, I don't see how I can ever initialize my > > foo structure. > > > > > The reason that your `require/typed` doesn't work is that it creates > > > new versions of the placeholder functions, but those aren't the ones > > > that `shared` uses internally, so Typed Racket doesn't use the types > > > you've given. > > > > That makes sense, thanks for the explanation! > > > > Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norman at astro.gla.ac.uk Mon Sep 29 14:06:32 2014 From: norman at astro.gla.ac.uk (Norman Gray) Date: Mon, 29 Sep 2014 19:06:32 +0100 Subject: [racket] aws/glacier: credential scope In-Reply-To: References: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5@astro.gla.ac.uk> <73617243-E0D5-43C6-872B-EA0121AD5142@astro.gla.ac.uk> Message-ID: <45C827C4-EF46-4B7C-8328-5902E05E4ECE@astro.gla.ac.uk> Greg, hello. On 2014 Sep 29, at 14:13, Greg Hendershott wrote: > It looks like the package server did eventually refresh a few hours ago: Hero: I've updated, and it works perfectly! All the best, Norman -- Norman Gray : http://nxg.me.uk SUPA School of Physics and Astronomy, University of Glasgow, UK From schuster at ccs.neu.edu Mon Sep 29 14:06:35 2014 From: schuster at ccs.neu.edu (Jonathan Schuster) Date: Mon, 29 Sep 2014 14:06:35 -0400 Subject: [racket] Better discoverability for errortrace Message-ID: We were having a discussion today in the Northeastern lab about how the Racket stack traces sometimes don't give enough information, and the solution to the problem (errrortrace) is not very discoverable if you're not using DrRacket. Here's an example of the kind of case I mean: $ racket -t jpg.rkt Assertion failed on #f context...: do-it /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop decode-jpeg /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] $ racket -l errortrace -t jpg.rkt Assertion failed on #f errortrace...: /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode dc-tree bits) /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) context...: huff-dc-decode do-it /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop decode-jpeg /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] To solve the discoverability issue, what would people think of putting a message like "If this information is not sufficient, try errrortrace with racket -l errortrace -t " after the default trace? Also, can anyone think of a way to programmatically detect when a trace is not informative enough and only display the message in those cases? I haven't looked into the feasibility of this myself; it's just an idea that came up during our discussion. -------------- next part -------------- An HTML attachment was scrubbed... URL: From robby at eecs.northwestern.edu Mon Sep 29 14:12:51 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 29 Sep 2014 13:12:51 -0500 Subject: [racket] Better discoverability for errortrace In-Reply-To: References: Message-ID: I don't think that that particular message makes sense as part of the default error messages. Specifically, if you disable errortrace in drracket, then you wouldn't want to see those messages (or, perhaps more accurately, you'd want to see different error messages). Maybe the repl that racket starts up can do that, tho? But perhaps this is something to add to xrepl? Robby On Mon, Sep 29, 2014 at 1:06 PM, Jonathan Schuster wrote: > We were having a discussion today in the Northeastern lab about how the > Racket stack traces sometimes don't give enough information, and the > solution to the problem (errrortrace) is not very discoverable if you're not > using DrRacket. > > Here's an example of the kind of case I mean: > > $ racket -t jpg.rkt > Assertion failed on #f > context...: > do-it > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > decode-jpeg > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > $ racket -l errortrace -t jpg.rkt > Assertion failed on #f > errortrace...: > /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) > /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode dc-tree > bits) > /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) > > context...: > huff-dc-decode > do-it > /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > decode-jpeg > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > > To solve the discoverability issue, what would people think of putting a > message like "If this information is not sufficient, try errrortrace with > racket -l errortrace -t " after the default trace? Also, can anyone > think of a way to programmatically detect when a trace is not informative > enough and only display the message in those cases? I haven't looked into > the feasibility of this myself; it's just an idea that came up during our > discussion. > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From leif at leifandersen.net Mon Sep 29 14:19:37 2014 From: leif at leifandersen.net (Leif Andersen) Date: Mon, 29 Sep 2014 14:19:37 -0400 Subject: [racket] Better discoverability for errortrace In-Reply-To: References: Message-ID: Another possibility we discussed was to give errortrace it's own flag that shows up when you do racket -h. It certainly wouldn't really scale for all of the libraries, but errortrace seems like it's something common enough that it might deserve it's own flag. Maybe something like: racket --errortrace ~Leif Andersen On Mon, Sep 29, 2014 at 2:12 PM, Robby Findler wrote: > I don't think that that particular message makes sense as part of the > default error messages. Specifically, if you disable errortrace in > drracket, then you wouldn't want to see those messages (or, perhaps > more accurately, you'd want to see different error messages). Maybe > the repl that racket starts up can do that, tho? > > But perhaps this is something to add to xrepl? > > Robby > > On Mon, Sep 29, 2014 at 1:06 PM, Jonathan Schuster > wrote: > > We were having a discussion today in the Northeastern lab about how the > > Racket stack traces sometimes don't give enough information, and the > > solution to the problem (errrortrace) is not very discoverable if you're > not > > using DrRacket. > > > > Here's an example of the kind of case I mean: > > > > $ racket -t jpg.rkt > > Assertion failed on #f > > context...: > > do-it > > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > > decode-jpeg > > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > > > $ racket -l errortrace -t jpg.rkt > > Assertion failed on #f > > errortrace...: > > /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) > > /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode > dc-tree > > bits) > > /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) > > > > context...: > > huff-dc-decode > > do-it > > /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop > > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > > decode-jpeg > > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > > > > > To solve the discoverability issue, what would people think of putting a > > message like "If this information is not sufficient, try errrortrace with > > racket -l errortrace -t " after the default trace? Also, can anyone > > think of a way to programmatically detect when a trace is not informative > > enough and only display the message in those cases? I haven't looked into > > the feasibility of this myself; it's just an idea that came up during our > > discussion. > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From schuster at ccs.neu.edu Mon Sep 29 14:42:19 2014 From: schuster at ccs.neu.edu (Jonathan Schuster) Date: Mon, 29 Sep 2014 14:42:19 -0400 Subject: [racket] Better discoverability for errortrace In-Reply-To: References: Message-ID: Hmm, I agree that there are cases when the message is extraneous, but I think adding it only to something like xrepl doesn't solve the core discoverability issue for those who use plain vanilla Racket on the command line. What about a parameter that determines if the message should be printed or not, and DrRacket could enable or disable it as needed? It could be enabled by default, so that places like the REPL would still show the message. On Mon, Sep 29, 2014 at 2:12 PM, Robby Findler wrote: > I don't think that that particular message makes sense as part of the > default error messages. Specifically, if you disable errortrace in > drracket, then you wouldn't want to see those messages (or, perhaps > more accurately, you'd want to see different error messages). Maybe > the repl that racket starts up can do that, tho? > > But perhaps this is something to add to xrepl? > > Robby > > On Mon, Sep 29, 2014 at 1:06 PM, Jonathan Schuster > wrote: > > We were having a discussion today in the Northeastern lab about how the > > Racket stack traces sometimes don't give enough information, and the > > solution to the problem (errrortrace) is not very discoverable if you're > not > > using DrRacket. > > > > Here's an example of the kind of case I mean: > > > > $ racket -t jpg.rkt > > Assertion failed on #f > > context...: > > do-it > > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > > decode-jpeg > > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > > > $ racket -l errortrace -t jpg.rkt > > Assertion failed on #f > > errortrace...: > > /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) > > /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode > dc-tree > > bits) > > /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) > > > > context...: > > huff-dc-decode > > do-it > > /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop > > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop > > decode-jpeg > > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] > > > > > > To solve the discoverability issue, what would people think of putting a > > message like "If this information is not sufficient, try errrortrace with > > racket -l errortrace -t " after the default trace? Also, can anyone > > think of a way to programmatically detect when a trace is not informative > > enough and only display the message in those cases? I haven't looked into > > the feasibility of this myself; it's just an idea that came up during our > > discussion. > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at ccs.neu.edu Mon Sep 29 15:30:52 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 29 Sep 2014 15:30:52 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> I guess the real problem is to create suitable default values so that the pass the type checker or to figure out a cast that forces TR to accept some other value as the default value (and making sure you never use the object). Undefined not completely solved. Argh. -- Matthias On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt wrote: > Ah, if you want to create truly cyclic structure with no base case > like this, then you'll have to do more work. Either you'll need to > expand the type of the `x` field in `foo` to allow an initial value, > or you'll need to create a dummy `foo` with that extended type, and > then copy the cyclic data once you've created it to a new version of > `foo`, using hash tables to track cycles. That's basically how > `shared` works, although I haven't tried implementing it in TR and it > might not be possible. > > Sam > > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen > wrote: >> Sam Tobin-Hochstadt writes: >> >>> I recommend doing the mutation yourself, and not using `shared`. >>> That's the most obvious solution. >> >> Not for me, unfortunately, but probably I am missing something >> obvious. >> >> Here's explicit mutation in untyped Racket: >> >> #lang racket >> >> (struct foo (x) #:mutable) >> (struct bar (x)) >> >> (define f (foo (void))) >> (define b (bar f)) >> (set-foo-x! f b) >> >> (eq? (bar-x b) f) >> (eq? (foo-x f) b) >> >> That works fine. Moving to Typed Racket, this is rejected by the type >> checker because (void) is of type Void. Since I need a bar to make a >> foo and a foo to make a bar, I don't see how I can ever initialize my >> foo structure. >> >>> The reason that your `require/typed` doesn't work is that it creates >>> new versions of the placeholder functions, but those aren't the ones >>> that `shared` uses internally, so Typed Racket doesn't use the types >>> you've given. >> >> That makes sense, thanks for the explanation! >> >> Konrad. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From neil at neilvandyke.org Mon Sep 29 15:33:58 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Mon, 29 Sep 2014 15:33:58 -0400 Subject: [racket] Better discoverability for errortrace In-Reply-To: References: Message-ID: <5429B426.7020404@neilvandyke.org> Small comment: In addition to discoverability, try to have this go direct to *understanding* of how&when to use "errortrace". (Multiple times over the years, I have been doing crucial performance optimizations to server code, and remnants of various versions of "errortrace" kept getting added back into the code. Pattern: get it optimized, incidentally also remove killer "errortrace" bits, then someone merges the changes, and some terrible "#! ... -l errortrace" or ancient "require ... errortrace.ss" somehow sneaks back into several different places each in multiple branches, sneaks back into hurting production capacity. Even if you provide a switch in the app-specific build environment to enable/disable errortrace. With lots of code and lots of branches and merging, it seems that errortrace can be like bed bugs -- terrorizing you with small bites everywhere, and you just can't get rid of it. This might seem like a CM and merging problem, not an "errortrace" problem, but it seems somewhat peculiar to "errortrace" in practice. I am forming a theory that some programmers are afraid to let a merge remove whatever cargo-cult incantations they found in the past gave them better backtraces, damn any consequences. :) Hence my suggestion to have your improved discoverability send the programmer direct to *understanding*, rather than to cargo-cult "add this magical snippet to your project" with an implied "and never lose the faith".) (Like many programming pragmatics, I know it looks silly to consider this seemingly little thing a matter of importance worth mention, but my view from the ground is that it has been important.) Neil V. From robby at eecs.northwestern.edu Mon Sep 29 15:59:19 2014 From: robby at eecs.northwestern.edu (Robby Findler) Date: Mon, 29 Sep 2014 14:59:19 -0500 Subject: [racket] Better discoverability for errortrace In-Reply-To: References: Message-ID: If you want to go that way, I think the right thing is to change the initial error-display-handler that racket installs when it is started up in "open a repl" mode. I will note, however, that there are lots of things that aren't discoverable in this way. Indeed, I would prefer that if someone were unhappy with their feedback of the racket repl that they were directed to a) use xrepl, b) use Greg's emacs mode, or c) use drracket, all ahead of being directed to use "racket -l errortrace -t file.rkt". That latter one I view as a convenience for wizards, not something where discovery is important. Robby On Mon, Sep 29, 2014 at 1:42 PM, Jonathan Schuster wrote: > Hmm, I agree that there are cases when the message is extraneous, but I > think adding it only to something like xrepl doesn't solve the core > discoverability issue for those who use plain vanilla Racket on the command > line. What about a parameter that determines if the message should be > printed or not, and DrRacket could enable or disable it as needed? It could > be enabled by default, so that places like the REPL would still show the > message. > > On Mon, Sep 29, 2014 at 2:12 PM, Robby Findler > wrote: >> >> I don't think that that particular message makes sense as part of the >> default error messages. Specifically, if you disable errortrace in >> drracket, then you wouldn't want to see those messages (or, perhaps >> more accurately, you'd want to see different error messages). Maybe >> the repl that racket starts up can do that, tho? >> >> But perhaps this is something to add to xrepl? >> >> Robby >> >> On Mon, Sep 29, 2014 at 1:06 PM, Jonathan Schuster >> wrote: >> > We were having a discussion today in the Northeastern lab about how the >> > Racket stack traces sometimes don't give enough information, and the >> > solution to the problem (errrortrace) is not very discoverable if you're >> > not >> > using DrRacket. >> > >> > Here's an example of the kind of case I mean: >> > >> > $ racket -t jpg.rkt >> > Assertion failed on #f >> > context...: >> > do-it >> > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop >> > decode-jpeg >> > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] >> > >> > $ racket -l errortrace -t jpg.rkt >> > Assertion failed on #f >> > errortrace...: >> > /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) >> > /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode >> > dc-tree >> > bits) >> > /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) >> > >> > context...: >> > huff-dc-decode >> > do-it >> > /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop >> > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop >> > decode-jpeg >> > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] >> > >> > >> > To solve the discoverability issue, what would people think of putting a >> > message like "If this information is not sufficient, try errrortrace >> > with >> > racket -l errortrace -t " after the default trace? Also, can >> > anyone >> > think of a way to programmatically detect when a trace is not >> > informative >> > enough and only display the message in those cases? I haven't looked >> > into >> > the feasibility of this myself; it's just an idea that came up during >> > our >> > discussion. >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > > > From blg59 at cornell.edu Mon Sep 29 16:32:19 2014 From: blg59 at cornell.edu (Benjamin Greenman) Date: Mon, 29 Sep 2014 16:32:19 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> Message-ID: Could Andrew Myer's work on masked types (to eliminate nulls for object initialization) be relevant? http://www.cs.cornell.edu/Projects/jmask/ On Mon, Sep 29, 2014 at 3:30 PM, Matthias Felleisen wrote: > > I guess the real problem is to create suitable default values so > that the pass the type checker or to figure out a cast that forces > TR to accept some other value as the default value (and making sure > you never use the object). > > Undefined not completely solved. Argh. -- Matthias > > > > > > On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt > wrote: > > > Ah, if you want to create truly cyclic structure with no base case > > like this, then you'll have to do more work. Either you'll need to > > expand the type of the `x` field in `foo` to allow an initial value, > > or you'll need to create a dummy `foo` with that extended type, and > > then copy the cyclic data once you've created it to a new version of > > `foo`, using hash tables to track cycles. That's basically how > > `shared` works, although I haven't tried implementing it in TR and it > > might not be possible. > > > > Sam > > > > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen > > wrote: > >> Sam Tobin-Hochstadt writes: > >> > >>> I recommend doing the mutation yourself, and not using `shared`. > >>> That's the most obvious solution. > >> > >> Not for me, unfortunately, but probably I am missing something > >> obvious. > >> > >> Here's explicit mutation in untyped Racket: > >> > >> #lang racket > >> > >> (struct foo (x) #:mutable) > >> (struct bar (x)) > >> > >> (define f (foo (void))) > >> (define b (bar f)) > >> (set-foo-x! f b) > >> > >> (eq? (bar-x b) f) > >> (eq? (foo-x f) b) > >> > >> That works fine. Moving to Typed Racket, this is rejected by the type > >> checker because (void) is of type Void. Since I need a bar to make a > >> foo and a foo to make a bar, I don't see how I can ever initialize my > >> foo structure. > >> > >>> The reason that your `require/typed` doesn't work is that it creates > >>> new versions of the placeholder functions, but those aren't the ones > >>> that `shared` uses internally, so Typed Racket doesn't use the types > >>> you've given. > >> > >> That makes sense, thanks for the explanation! > >> > >> Konrad. > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From moshedeutsch115 at gmail.com Mon Sep 29 16:40:15 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:40:15 -0400 Subject: [racket] users Digest, Vol 109, Issue 79 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Mon, Sep 29, 2014 at 4:32 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: Cyclic data structures in Typed Racket (Matthias Felleisen) > 2. Re: Better discoverability for errortrace (Neil Van Dyke) > 3. Re: Better discoverability for errortrace (Robby Findler) > 4. Re: Cyclic data structures in Typed Racket (Benjamin Greenman) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 29 Sep 2014 15:30:52 -0400 > From: Matthias Felleisen > To: Sam Tobin-Hochstadt > Cc: users > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: <3597E44F-0EF5-4837-AA2D-E06E728B8B71 at ccs.neu.edu> > Content-Type: text/plain; charset=us-ascii > > > I guess the real problem is to create suitable default values so > that the pass the type checker or to figure out a cast that forces > TR to accept some other value as the default value (and making sure > you never use the object). > > Undefined not completely solved. Argh. -- Matthias > > > > > > On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt wrote: > >> Ah, if you want to create truly cyclic structure with no base case >> like this, then you'll have to do more work. Either you'll need to >> expand the type of the `x` field in `foo` to allow an initial value, >> or you'll need to create a dummy `foo` with that extended type, and >> then copy the cyclic data once you've created it to a new version of >> `foo`, using hash tables to track cycles. That's basically how >> `shared` works, although I haven't tried implementing it in TR and it >> might not be possible. >> >> Sam >> >> On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen >> wrote: >>> Sam Tobin-Hochstadt writes: >>> >>>> I recommend doing the mutation yourself, and not using `shared`. >>>> That's the most obvious solution. >>> >>> Not for me, unfortunately, but probably I am missing something >>> obvious. >>> >>> Here's explicit mutation in untyped Racket: >>> >>> #lang racket >>> >>> (struct foo (x) #:mutable) >>> (struct bar (x)) >>> >>> (define f (foo (void))) >>> (define b (bar f)) >>> (set-foo-x! f b) >>> >>> (eq? (bar-x b) f) >>> (eq? (foo-x f) b) >>> >>> That works fine. Moving to Typed Racket, this is rejected by the type >>> checker because (void) is of type Void. Since I need a bar to make a >>> foo and a foo to make a bar, I don't see how I can ever initialize my >>> foo structure. >>> >>>> The reason that your `require/typed` doesn't work is that it creates >>>> new versions of the placeholder functions, but those aren't the ones >>>> that `shared` uses internally, so Typed Racket doesn't use the types >>>> you've given. >>> >>> That makes sense, thanks for the explanation! >>> >>> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > > ------------------------------ > > Message: 2 > Date: Mon, 29 Sep 2014 15:33:58 -0400 > From: Neil Van Dyke > To: Jonathan Schuster , Robby Findler > > Cc: Racket List > Subject: Re: [racket] Better discoverability for errortrace > Message-ID: <5429B426.7020404 at neilvandyke.org> > Content-Type: text/plain; charset=UTF-8; format=flowed > > Small comment: In addition to discoverability, try to have this go > direct to *understanding* of how&when to use "errortrace". > > (Multiple times over the years, I have been doing crucial performance > optimizations to server code, and remnants of various versions of > "errortrace" kept getting added back into the code. Pattern: get it > optimized, incidentally also remove killer "errortrace" bits, then > someone merges the changes, and some terrible "#! ... -l errortrace" or > ancient "require ... errortrace.ss" somehow sneaks back into several > different places each in multiple branches, sneaks back into hurting > production capacity. Even if you provide a switch in the app-specific > build environment to enable/disable errortrace. With lots of code and > lots of branches and merging, it seems that errortrace can be like bed > bugs -- terrorizing you with small bites everywhere, and you just can't > get rid of it. This might seem like a CM and merging problem, not an > "errortrace" problem, but it seems somewhat peculiar to "errortrace" in > practice. I am forming a theory that some programmers are afraid to let > a merge remove whatever cargo-cult incantations they found in the past > gave them better backtraces, damn any consequences. :) Hence my > suggestion to have your improved discoverability send the programmer > direct to *understanding*, rather than to cargo-cult "add this magical > snippet to your project" with an implied "and never lose the faith".) > > (Like many programming pragmatics, I know it looks silly to consider > this seemingly little thing a matter of importance worth mention, but my > view from the ground is that it has been important.) > > Neil V. > > > > ------------------------------ > > Message: 3 > Date: Mon, 29 Sep 2014 14:59:19 -0500 > From: Robby Findler > To: Jonathan Schuster > Cc: Racket List > Subject: Re: [racket] Better discoverability for errortrace > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > If you want to go that way, I think the right thing is to change the > initial error-display-handler that racket installs when it is started > up in "open a repl" mode. > > I will note, however, that there are lots of things that aren't > discoverable in this way. Indeed, I would prefer that if someone were > unhappy with their feedback of the racket repl that they were directed > to a) use xrepl, b) use Greg's emacs mode, or c) use drracket, all > ahead of being directed to use "racket -l errortrace -t file.rkt". > That latter one I view as a convenience for wizards, not something > where discovery is important. > > Robby > > > On Mon, Sep 29, 2014 at 1:42 PM, Jonathan Schuster wrote: >> Hmm, I agree that there are cases when the message is extraneous, but I >> think adding it only to something like xrepl doesn't solve the core >> discoverability issue for those who use plain vanilla Racket on the command >> line. What about a parameter that determines if the message should be >> printed or not, and DrRacket could enable or disable it as needed? It could >> be enabled by default, so that places like the REPL would still show the >> message. >> >> On Mon, Sep 29, 2014 at 2:12 PM, Robby Findler >> wrote: >>> >>> I don't think that that particular message makes sense as part of the >>> default error messages. Specifically, if you disable errortrace in >>> drracket, then you wouldn't want to see those messages (or, perhaps >>> more accurately, you'd want to see different error messages). Maybe >>> the repl that racket starts up can do that, tho? >>> >>> But perhaps this is something to add to xrepl? >>> >>> Robby >>> >>> On Mon, Sep 29, 2014 at 1:06 PM, Jonathan Schuster >>> wrote: >>> > We were having a discussion today in the Northeastern lab about how the >>> > Racket stack traces sometimes don't give enough information, and the >>> > solution to the problem (errrortrace) is not very discoverable if you're >>> > not >>> > using DrRacket. >>> > >>> > Here's an example of the kind of case I mean: >>> > >>> > $ racket -t jpg.rkt >>> > Assertion failed on #f >>> > context...: >>> > do-it >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop >>> > decode-jpeg >>> > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] >>> > >>> > $ racket -l errortrace -t jpg.rkt >>> > Assertion failed on #f >>> > errortrace...: >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:126:16: (assert #f) >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:363:36: (huff-dc-decode >>> > dc-tree >>> > bits) >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:407:37: (reader bits) >>> > >>> > context...: >>> > huff-dc-decode >>> > do-it >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:406:5: for-loop >>> > /Users/acobb/programs/jpg-parse/jpg.rkt:402:2: for-loop >>> > decode-jpeg >>> > /Users/acobb/programs/jpg-parse/jpg.rkt: [running body] >>> > >>> > >>> > To solve the discoverability issue, what would people think of putting a >>> > message like "If this information is not sufficient, try errrortrace >>> > with >>> > racket -l errortrace -t " after the default trace? Also, can >>> > anyone >>> > think of a way to programmatically detect when a trace is not >>> > informative >>> > enough and only display the message in those cases? I haven't looked >>> > into >>> > the feasibility of this myself; it's just an idea that came up during >>> > our >>> > discussion. >>> > >>> > ____________________ >>> > Racket Users list: >>> > http://lists.racket-lang.org/users >>> > >> >> > > > ------------------------------ > > Message: 4 > Date: Mon, 29 Sep 2014 16:32:19 -0400 > From: Benjamin Greenman > To: Matthias Felleisen > Cc: users , Sam Tobin-Hochstadt > > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Could Andrew Myer's work on masked types (to eliminate nulls for object > initialization) be relevant? > http://www.cs.cornell.edu/Projects/jmask/ > > On Mon, Sep 29, 2014 at 3:30 PM, Matthias Felleisen > wrote: > >> >> I guess the real problem is to create suitable default values so >> that the pass the type checker or to figure out a cast that forces >> TR to accept some other value as the default value (and making sure >> you never use the object). >> >> Undefined not completely solved. Argh. -- Matthias >> >> >> >> >> >> On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt >> wrote: >> >> > Ah, if you want to create truly cyclic structure with no base case >> > like this, then you'll have to do more work. Either you'll need to >> > expand the type of the `x` field in `foo` to allow an initial value, >> > or you'll need to create a dummy `foo` with that extended type, and >> > then copy the cyclic data once you've created it to a new version of >> > `foo`, using hash tables to track cycles. That's basically how >> > `shared` works, although I haven't tried implementing it in TR and it >> > might not be possible. >> > >> > Sam >> > >> > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen >> > wrote: >> >> Sam Tobin-Hochstadt writes: >> >> >> >>> I recommend doing the mutation yourself, and not using `shared`. >> >>> That's the most obvious solution. >> >> >> >> Not for me, unfortunately, but probably I am missing something >> >> obvious. >> >> >> >> Here's explicit mutation in untyped Racket: >> >> >> >> #lang racket >> >> >> >> (struct foo (x) #:mutable) >> >> (struct bar (x)) >> >> >> >> (define f (foo (void))) >> >> (define b (bar f)) >> >> (set-foo-x! f b) >> >> >> >> (eq? (bar-x b) f) >> >> (eq? (foo-x f) b) >> >> >> >> That works fine. Moving to Typed Racket, this is rejected by the type >> >> checker because (void) is of type Void. Since I need a bar to make a >> >> foo and a foo to make a bar, I don't see how I can ever initialize my >> >> foo structure. >> >> >> >>> The reason that your `require/typed` doesn't work is that it creates >> >>> new versions of the placeholder functions, but those aren't the ones >> >>> that `shared` uses internally, so Typed Racket doesn't use the types >> >>> you've given. >> >> >> >> That makes sense, thanks for the explanation! >> >> >> >> Konrad. >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 79 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:40:43 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:40:43 -0400 Subject: [racket] users Digest, Vol 109, Issue 77 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Mon, Sep 29, 2014 at 2:00 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Cyclic data structures in Typed Racket (Konrad Hinsen) > 2. Re: Cyclic data structures in Typed Racket (Sam Tobin-Hochstadt) > 3. Re: Cyclic data structures in Typed Racket (Konrad Hinsen) > 4. Re: Cyclic data structures in Typed Racket (Sam Tobin-Hochstadt) > 5. Re: Cyclic data structures in Typed Racket (Benjamin Greenman) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 29 Sep 2014 18:10:29 +0200 > From: Konrad Hinsen > To: users at racket-lang.org > Subject: [racket] Cyclic data structures in Typed Racket > Message-ID: > <21545.33909.430329.240145 at Konrad-Hinsens-MacBook-Pro-2.local> > Content-Type: text/plain; charset=us-ascii > > Hi everyone, > > I am trying to port code creating a cyclic data structure to Typed > Racket, but notice that this is not as straightforward as I expected. > > Here is the untyped code I start from: > > #lang racket > > (struct foo (x) #:mutable) > (struct bar (x)) > > (define-values (f b) > (shared ([f (foo b)] > [b (bar f)]) > (values f b))) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > Switching to Typed Racket and annotating the struct definitions, I get > an error message saying that make-placeholder and placeholder-set! > from racket/base are lacking type annotations. I also get the recommendation > to use require/typed for importing them. OK, let's try: > > #lang typed/racket > > (require/typed racket/base > [#:opaque Placeholder placeholder?] > [make-placeholder (-> Any Placeholder)] > [placeholder-set! (-> Placeholder Any Void)]) > > (struct foo ([x : bar]) #:mutable) > (struct bar ([x : foo])) > > (define-values (f b) > (shared ([f (foo b)] > [b (bar f)]) > (values f b))) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > Same error message... which is not really surprising. I suppose typed/racket > already requires racket/base, so my additional require/typed has no effect. > But how can I fix this? I don't see any way to exclude items from typed/racket. > > Konrad. > > > ------------------------------ > > Message: 2 > Date: Mon, 29 Sep 2014 12:17:29 -0400 > From: Sam Tobin-Hochstadt > To: Konrad Hinsen > Cc: users > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I recommend doing the mutation yourself, and not using `shared`. > That's the most obvious solution. > > The reason that your `require/typed` doesn't work is that it creates > new versions of the placeholder functions, but those aren't the ones > that `shared` uses internally, so Typed Racket doesn't use the types > you've given. > > Note also that the types you gave aren't safe -- the way shared uses > placeholders expects particular types for particular ones (this would > result in a contract error at runtime if `shared` used your bindings). > > Sam > > On Mon, Sep 29, 2014 at 12:10 PM, Konrad Hinsen > wrote: >> Hi everyone, >> >> I am trying to port code creating a cyclic data structure to Typed >> Racket, but notice that this is not as straightforward as I expected. >> >> Here is the untyped code I start from: >> >> #lang racket >> >> (struct foo (x) #:mutable) >> (struct bar (x)) >> >> (define-values (f b) >> (shared ([f (foo b)] >> [b (bar f)]) >> (values f b))) >> >> (eq? (bar-x b) f) >> (eq? (foo-x f) b) >> >> Switching to Typed Racket and annotating the struct definitions, I get >> an error message saying that make-placeholder and placeholder-set! >> from racket/base are lacking type annotations. I also get the recommendation >> to use require/typed for importing them. OK, let's try: >> >> #lang typed/racket >> >> (require/typed racket/base >> [#:opaque Placeholder placeholder?] >> [make-placeholder (-> Any Placeholder)] >> [placeholder-set! (-> Placeholder Any Void)]) >> >> (struct foo ([x : bar]) #:mutable) >> (struct bar ([x : foo])) >> >> (define-values (f b) >> (shared ([f (foo b)] >> [b (bar f)]) >> (values f b))) >> >> (eq? (bar-x b) f) >> (eq? (foo-x f) b) >> >> Same error message... which is not really surprising. I suppose typed/racket >> already requires racket/base, so my additional require/typed has no effect. >> But how can I fix this? I don't see any way to exclude items from typed/racket. >> >> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > ------------------------------ > > Message: 3 > Date: Mon, 29 Sep 2014 18:33:38 +0200 > From: Konrad Hinsen > To: Sam Tobin-Hochstadt > Cc: users > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: > <21545.35298.582248.45625 at Konrad-Hinsens-MacBook-Pro-2.local> > Content-Type: text/plain; charset=us-ascii > > Sam Tobin-Hochstadt writes: > > > I recommend doing the mutation yourself, and not using `shared`. > > That's the most obvious solution. > > Not for me, unfortunately, but probably I am missing something > obvious. > > Here's explicit mutation in untyped Racket: > > #lang racket > > (struct foo (x) #:mutable) > (struct bar (x)) > > (define f (foo (void))) > (define b (bar f)) > (set-foo-x! f b) > > (eq? (bar-x b) f) > (eq? (foo-x f) b) > > That works fine. Moving to Typed Racket, this is rejected by the type > checker because (void) is of type Void. Since I need a bar to make a > foo and a foo to make a bar, I don't see how I can ever initialize my > foo structure. > > > The reason that your `require/typed` doesn't work is that it creates > > new versions of the placeholder functions, but those aren't the ones > > that `shared` uses internally, so Typed Racket doesn't use the types > > you've given. > > That makes sense, thanks for the explanation! > > Konrad. > > > ------------------------------ > > Message: 4 > Date: Mon, 29 Sep 2014 12:52:25 -0400 > From: Sam Tobin-Hochstadt > To: Konrad Hinsen > Cc: users > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Ah, if you want to create truly cyclic structure with no base case > like this, then you'll have to do more work. Either you'll need to > expand the type of the `x` field in `foo` to allow an initial value, > or you'll need to create a dummy `foo` with that extended type, and > then copy the cyclic data once you've created it to a new version of > `foo`, using hash tables to track cycles. That's basically how > `shared` works, although I haven't tried implementing it in TR and it > might not be possible. > > Sam > > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen > wrote: >> Sam Tobin-Hochstadt writes: >> >> > I recommend doing the mutation yourself, and not using `shared`. >> > That's the most obvious solution. >> >> Not for me, unfortunately, but probably I am missing something >> obvious. >> >> Here's explicit mutation in untyped Racket: >> >> #lang racket >> >> (struct foo (x) #:mutable) >> (struct bar (x)) >> >> (define f (foo (void))) >> (define b (bar f)) >> (set-foo-x! f b) >> >> (eq? (bar-x b) f) >> (eq? (foo-x f) b) >> >> That works fine. Moving to Typed Racket, this is rejected by the type >> checker because (void) is of type Void. Since I need a bar to make a >> foo and a foo to make a bar, I don't see how I can ever initialize my >> foo structure. >> >> > The reason that your `require/typed` doesn't work is that it creates >> > new versions of the placeholder functions, but those aren't the ones >> > that `shared` uses internally, so Typed Racket doesn't use the types >> > you've given. >> >> That makes sense, thanks for the explanation! >> >> Konrad. > > > ------------------------------ > > Message: 5 > Date: Mon, 29 Sep 2014 14:00:12 -0400 > From: Benjamin Greenman > To: Sam Tobin-Hochstadt > Cc: users > Subject: Re: [racket] Cyclic data structures in Typed Racket > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > To be sure: Is there any TR analog to this OCaml code, initializing a > cyclic, 3-element list? I've tried using letrec in TR, but the typechecker > yells at me even if I annotate the a,b,c,d. > > # type 'a mylist = Nil | Cons of 'a * 'a mylist;; > type 'a mylist = Nil | Cons of 'a * 'a mylist > # let mylist = > let rec a = Cons(1, b) > and b = Cons(2, c) > and c = Cons(3, d) > and d = Cons(4, a) in > a;; > val mylist : int mylist = Cons (1, Cons (2, Cons (3, Cons (4, )))) > > On Mon, Sep 29, 2014 at 12:52 PM, Sam Tobin-Hochstadt > wrote: > >> Ah, if you want to create truly cyclic structure with no base case >> like this, then you'll have to do more work. Either you'll need to >> expand the type of the `x` field in `foo` to allow an initial value, >> or you'll need to create a dummy `foo` with that extended type, and >> then copy the cyclic data once you've created it to a new version of >> `foo`, using hash tables to track cycles. That's basically how >> `shared` works, although I haven't tried implementing it in TR and it >> might not be possible. >> >> Sam >> >> On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen >> wrote: >> > Sam Tobin-Hochstadt writes: >> > >> > > I recommend doing the mutation yourself, and not using `shared`. >> > > That's the most obvious solution. >> > >> > Not for me, unfortunately, but probably I am missing something >> > obvious. >> > >> > Here's explicit mutation in untyped Racket: >> > >> > #lang racket >> > >> > (struct foo (x) #:mutable) >> > (struct bar (x)) >> > >> > (define f (foo (void))) >> > (define b (bar f)) >> > (set-foo-x! f b) >> > >> > (eq? (bar-x b) f) >> > (eq? (foo-x f) b) >> > >> > That works fine. Moving to Typed Racket, this is rejected by the type >> > checker because (void) is of type Void. Since I need a bar to make a >> > foo and a foo to make a bar, I don't see how I can ever initialize my >> > foo structure. >> > >> > > The reason that your `require/typed` doesn't work is that it creates >> > > new versions of the placeholder functions, but those aren't the ones >> > > that `shared` uses internally, so Typed Racket doesn't use the types >> > > you've given. >> > >> > That makes sense, thanks for the explanation! >> > >> > Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 77 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:00 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:00 -0400 Subject: [racket] users Digest, Vol 109, Issue 76 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Mon, Sep 29, 2014 at 12:00 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Is there any way to get the bit depth of a bitmap? (rrandom) > 2. Re: Is there any way to get the bit depth of a bitmap? > (Matthew Flatt) > 3. Re: rsound docs (Matthew Flatt) > 4. Re: typed racket, filters, and polymorphism (Robby Findler) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 29 Sep 2014 23:14:43 +0800 > From: rrandom > To: Racket Users > Subject: [racket] Is there any way to get the bit depth of a bitmap? > Message-ID: <54297763.3020407 at gmx.com> > Content-Type: text/plain; charset=GB2312 > > Hi,I am recently working in the book Digital Image Processing with > racket. I want to know is there any way to get the bit depth or color > depth of a input bitmap in Racket? I found the get-depth method in > racket/draw,bitmap%, but it only return 1 and 32, that's not what i > really want.I input a bitmap whose bit depth is 8 but i got 32. > following is the code: > >> (send (read-bitmap "Fig0305(a)(DFT_no_log).tif") > get-depth) > 32 > > Is there anything I am wrong? Thank you! > > > ------------------------------ > > Message: 2 > Date: Mon, 29 Sep 2014 09:24:07 -0600 > From: Matthew Flatt > To: rrandom > Cc: Racket Users > Subject: Re: [racket] Is there any way to get the bit depth of a > bitmap? > Message-ID: <20140929152408.F0E42650192 at mail-svr1.cs.utah.edu> > Content-Type: text/plain; charset=UTF-8 > > Racket libraries can read and write images of various formats and > pixels depths, but a `bitmap%` object always represents an image using > 1 or 32 bits per pixel in memory. > > At Mon, 29 Sep 2014 23:14:43 +0800, rrandom wrote: >> Hi,I am recently working in the book Digital Image Processing with >> racket. I want to know is there any way to get the bit depth or color >> depth of a input bitmap in Racket? I found the get-depth method in >> racket/draw,bitmap%, but it only return 1 and 32, that's not what i >> really want.I input a bitmap whose bit depth is 8 but i got 32. >> following is the code: >> >> > (send (read-bitmap "Fig0305(a)(DFT_no_log).tif") >> get-depth) >> 32 >> >> Is there anything I am wrong? Thank you! >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > ------------------------------ > > Message: 3 > Date: Mon, 29 Sep 2014 09:28:14 -0600 > From: Matthew Flatt > To: C K Kashyap > Cc: users at racket-lang.org > Subject: Re: [racket] rsound docs > Message-ID: <20140929152815.C87E6650194 at mail-svr1.cs.utah.edu> > Content-Type: text/plain; charset=UTF-8 > > When you install the package, you also install documentation for > RSound. You should be able to find it by selecting "Racket > Documentation" from the "Help" menu in DrRacket, by right-clicking on > an identifier in DrRacket that is provided by the package's library, or > by running `raco docs` on the command line. > > You can also find documentation linked from the "rsound" entry at > http://pkgs.racket-lang.org/, which goes to > > http://pkg-build.racket-lang.org/doc/rsound/index.html > > > At Mon, 29 Sep 2014 19:09:17 +0530, C K Kashyap wrote: >> Hi, >> >> I saw this nice racketcon video ( >> https://www.youtube.com/watch?v=DkIVzHNjNEA&list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2 >> Gdh&index=9) >> on rsound. I've installed the rsound package and have been able to run the >> example from the video. >> >> Is there a place that has mode documentation/tutorial on rsound? >> >> Regards, >> Kashyap >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > ------------------------------ > > Message: 4 > Date: Mon, 29 Sep 2014 10:40:08 -0500 > From: Robby Findler > To: Konrad Hinsen > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Whoops, sorry: this is the same thing Konrad was talking about! Duh. > Well, hopefully the link is useful. > > Robby > > > On Mon, Sep 29, 2014 at 9:32 AM, Robby Findler > wrote: >> Just in case, here is one piece of related work from the PL world and >> is probably a reasonable starting point for finding others' attempts >> at this problem: >> >> http://research.microsoft.com/en-us/um/people/akenn/units/ >> >> Robby >> >> >> On Mon, Sep 29, 2014 at 3:44 AM, Konrad Hinsen >> wrote: >>> Matthias Felleisen writes: >>> >>> > Your message points out where gradual typing badly fails. >>> >>> Not just gradual typing. I am not aware of any good unit >>> implementation in any type system, with the exception of F# and Frink >>> whose type systems were explicitly modified to add unit checking as a >>> special case. Dependent types should permit a good solution, but I >>> haven't seen it done yet. >>> >>> The reason you need dependent types is that the product of two >>> measures is another measure with a new unit, so you must be able to >>> construct new types (representing units) from values. For example, a >>> length divided by a time yields a speed. Once you can do that, scaling >>> a unit (e.g. from meters to kilometers) becomes a special case. >>> >>> > In this specific case, you have two aspects of dimensionality: >>> > dimension per se (I am sure there is a word for it) and the chosen >>> > unit to represent it. >>> >>> The two terms used for this distinction are in fact "dimension" and >>> "unit". >>> >>> > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is >>> > nothing wrong with it -- except that the type checker should insert >>> > a coercion from mm to m and from km to m (multiplying/dividing by >>> > 1,000). >>> >>> That's a topic of hot debate in the scientific computing community. >>> Some argue that the type checker should consider your example as an >>> error, and not do any implicit conversion. The motivation is that the >>> expression you used is more likely to be a mistake than the meaningful >>> use of expressive language, since best practices recommend to use a >>> minimal set of units inside any piece of code. >>> >>> Anyway, that's a minor detail. If your type system can handle >>> automatic conversion, then it can also handle its absence. >>> >>> >>> Alexander D. Knauth writes: >>> >>> > What I had in mind was for the structs to be available at run-time, >>> > but that ideally the optimizer could take them out for the >>> > intermediate operations and put them back for the final result. >>> >>> You are actually adding a very Racket-specific requirement to the >>> already difficult units-as-types problem: the interplay between a >>> typed and an untyped dialect of the same language. I agree this would >>> be nice to have. >>> >>> Konrad. >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users > > > End of users Digest, Vol 109, Issue 76 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:10 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:10 -0400 Subject: [racket] users Digest, Vol 109, Issue 75 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Mon, Sep 29, 2014 at 10:32 AM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: canonical index of Racket courses? [was: Summer programs > learning Racket for a student] (jab at math.brown.edu) > 2. Re: typed racket, filters, and polymorphism (Konrad Hinsen) > 3. Re: aws/glacier: credential scope (Greg Hendershott) > 4. rsound docs (C K Kashyap) > 5. Re: typed racket, filters, and polymorphism (Robby Findler) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 23:36:05 -0400 > From: jab at math.brown.edu > To: Sam Tobin-Hochstadt , Matthias Felleisen > > Cc: Racket Users > Subject: Re: [racket] canonical index of Racket courses? [was: Summer > programs learning Racket for a student] > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > On Wed, Sep 17, 2014 at 10:51 AM, Sam Tobin-Hochstadt > wrote: > >> I've now created a wiki page for this, with some initial content: >> https://github.com/plt/racket/wiki/Courses-using-Racket >> > > And now it's up to 22 revisions! Thanks for creating, Sam, and to everyone > who added to it. > > On Tue, Sep 16, 2014 at 8:43 PM, Matthias Felleisen >> wrote: >> > Do you imagine listing college courses such as Brown's 17, which uses >> > DrRacket and the teaching languages? Or do you want Coursera courses that >> > everyone can access? >> > > I think linking to any class that makes educational materials publicly > available is valuable, but they should be divided into one section for > classes that don't require being admitted into a larger institution to > participate in (e.g. Bootstrap World, Coursera, summer programs for teens, > etc.), and another section for those that do. > > >> > And yes, we should probably create a wiki like thing for such an effort >> or >> > perhaps something like packages.racket-lang.org. I'll bring it up as we >> meet >> > in St Louis. >> > > Thanks, Matthias, and hope you all had a great time in St Louis. Looks like > it was a wonderful conference. > > Can the wiki page above be directly linked off racket-lang.org, perhaps a > bit more prominently? I hadn't even noticed > https://github.com/plt/racket/wiki before; now I see the link to it kind of > buried under the Contributing column of the Community section. Perhaps it's > not easy to find for others too. > > Thanks again for following up on this. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Mon, 29 Sep 2014 10:44:56 +0200 > From: Konrad Hinsen > To: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > <21545.7176.252047.613404 at Ordinateur-de-Catherine-Konrad.local> > Content-Type: text/plain; charset=us-ascii > > Matthias Felleisen writes: > > > Your message points out where gradual typing badly fails. > > Not just gradual typing. I am not aware of any good unit > implementation in any type system, with the exception of F# and Frink > whose type systems were explicitly modified to add unit checking as a > special case. Dependent types should permit a good solution, but I > haven't seen it done yet. > > The reason you need dependent types is that the product of two > measures is another measure with a new unit, so you must be able to > construct new types (representing units) from values. For example, a > length divided by a time yields a speed. Once you can do that, scaling > a unit (e.g. from meters to kilometers) becomes a special case. > > > In this specific case, you have two aspects of dimensionality: > > dimension per se (I am sure there is a word for it) and the chosen > > unit to represent it. > > The two terms used for this distinction are in fact "dimension" and > "unit". > > > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is > > nothing wrong with it -- except that the type checker should insert > > a coercion from mm to m and from km to m (multiplying/dividing by > > 1,000). > > That's a topic of hot debate in the scientific computing community. > Some argue that the type checker should consider your example as an > error, and not do any implicit conversion. The motivation is that the > expression you used is more likely to be a mistake than the meaningful > use of expressive language, since best practices recommend to use a > minimal set of units inside any piece of code. > > Anyway, that's a minor detail. If your type system can handle > automatic conversion, then it can also handle its absence. > > > Alexander D. Knauth writes: > > > What I had in mind was for the structs to be available at run-time, > > but that ideally the optimizer could take them out for the > > intermediate operations and put them back for the final result. > > You are actually adding a very Racket-specific requirement to the > already difficult units-as-types problem: the interplay between a > typed and an untyped dialect of the same language. I agree this would > be nice to have. > > Konrad. > > > ------------------------------ > > Message: 3 > Date: Mon, 29 Sep 2014 09:13:11 -0400 > From: Greg Hendershott > To: Norman Gray > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > It looks like the package server did eventually refresh a few hours ago: > > Last Updated: 9/28/2014, 4:21:56 PM ;change on GitHub > Last Checked: 9/29/2014, 7:51:37 AM ;pkgs.r-l.org refresh > > (I believe those times are US MT, -0600.) > > On Sun, Sep 28, 2014 at 6:10 PM, Greg Hendershott > wrote: >> If you're in a hurry you could remove and re-install directly from GitHub: >> >> $ raco pkg remove aws >> $ raco pkg install git://github.com/greghendershott/aws >> >> On Sun, Sep 28, 2014 at 5:40 PM, Norman Gray wrote: >>> >>> On 2014 Sep 28, at 22:17, Greg Hendershott wrote: >>> >>>>>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>>>>> than usual to refresh. After it does, you can `raco pkg update aws` to >>>>>> get the fix. >>>>> >>>>> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >>>>> >>>>> "update upload in progress: there may be inconsistencies below" >>>>> >>>>> It's been saying that for nearly an hour. >>>> >>>> Sometimes instead it says: >>>> >>>> "update upload being computed: the information below may not >>>> represent all recent changes and updates" >>>> >>>> It has switched between those two messages at various intervals over >>>> the last hour. >>> >>> And in case it's a useful data point, I'm getting >>> >>> % raco pkg update aws >>> Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ >>> Resolving "aws" via http://pkgs.racket-lang.org >>> No updates available >>> % >>> >>> And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... >>> >>> Norman >>> >>> >>> -- >>> Norman Gray : http://nxg.me.uk >>> SUPA School of Physics and Astronomy, University of Glasgow, UK >>> > > > ------------------------------ > > Message: 4 > Date: Mon, 29 Sep 2014 19:09:17 +0530 > From: C K Kashyap > To: users at racket-lang.org > Subject: [racket] rsound docs > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Hi, > > I saw this nice racketcon video ( > https://www.youtube.com/watch?v=DkIVzHNjNEA&list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2Gdh&index=9) > on rsound. I've installed the rsound package and have been able to run the > example from the video. > > Is there a place that has mode documentation/tutorial on rsound? > > Regards, > Kashyap > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 5 > Date: Mon, 29 Sep 2014 09:32:40 -0500 > From: Robby Findler > To: Konrad Hinsen > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Just in case, here is one piece of related work from the PL world and > is probably a reasonable starting point for finding others' attempts > at this problem: > > http://research.microsoft.com/en-us/um/people/akenn/units/ > > Robby > > > On Mon, Sep 29, 2014 at 3:44 AM, Konrad Hinsen > wrote: >> Matthias Felleisen writes: >> >> > Your message points out where gradual typing badly fails. >> >> Not just gradual typing. I am not aware of any good unit >> implementation in any type system, with the exception of F# and Frink >> whose type systems were explicitly modified to add unit checking as a >> special case. Dependent types should permit a good solution, but I >> haven't seen it done yet. >> >> The reason you need dependent types is that the product of two >> measures is another measure with a new unit, so you must be able to >> construct new types (representing units) from values. For example, a >> length divided by a time yields a speed. Once you can do that, scaling >> a unit (e.g. from meters to kilometers) becomes a special case. >> >> > In this specific case, you have two aspects of dimensionality: >> > dimension per se (I am sure there is a word for it) and the chosen >> > unit to represent it. >> >> The two terms used for this distinction are in fact "dimension" and >> "unit". >> >> > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is >> > nothing wrong with it -- except that the type checker should insert >> > a coercion from mm to m and from km to m (multiplying/dividing by >> > 1,000). >> >> That's a topic of hot debate in the scientific computing community. >> Some argue that the type checker should consider your example as an >> error, and not do any implicit conversion. The motivation is that the >> expression you used is more likely to be a mistake than the meaningful >> use of expressive language, since best practices recommend to use a >> minimal set of units inside any piece of code. >> >> Anyway, that's a minor detail. If your type system can handle >> automatic conversion, then it can also handle its absence. >> >> >> Alexander D. Knauth writes: >> >> > What I had in mind was for the structs to be available at run-time, >> > but that ideally the optimizer could take them out for the >> > intermediate operations and put them back for the final result. >> >> You are actually adding a very Racket-specific requirement to the >> already difficult units-as-types problem: the interplay between a >> typed and an untyped dialect of the same language. I agree this would >> be nice to have. >> >> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > End of users Digest, Vol 109, Issue 75 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:19 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:19 -0400 Subject: [racket] users Digest, Vol 109, Issue 74 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 11:00 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 23:00:17 -0400 > From: "Alexander D. Knauth" > To: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: <0BDCBA09-5AA1-410A-A954-D2B6A8B30465 at knauth.org> > Content-Type: text/plain; charset="utf-8" > > I just realized that typed racket seems to ignore the guard anyway, so I could do something like this and convince the type-checker that any value I want has any type that I want: > > (struct (a) foo ([a : a]) > #:guard (lambda (a _) "this value")) > > (: x : (foo 1)) > (define x (foo 1)) > >> (foo-a x) > - : Integer [more precisely: One] > "this value? > > > On Sep 28, 2014, at 10:41 PM, Benjamin Greenman wrote: > >> I was able to get something very similar to your example program to compile. >> >> (struct (a) foo ([a : a]) #:transparent >> #:guard (lambda (a _) >> (define a* a) ;; a* not "polluted" by occurrence typing >> (unless (exact-integer? a) >> (error 'foo "expected Integer, given ~v" a)) >> a*)) ;; we return a value of type a, so the typechecker is happy >> >> From here, you can safely cast a foo-a into an Integer. It's not type safe to ann because we (deliberately) don't have the occurrence typing information, but we the programmers can be sure that the casts will never fail. >> >> (cast (foo (ann 1 Any)) (foo Integer)) >> > (foo 1) >> >> >> >> On Sun, Sep 28, 2014 at 10:29 PM, Matthias Felleisen wrote: >> >> You might be able to unwrap such things for a local context, but then you need to wrap it again on the way out. That cost might become quite high if it happens in a loop. Then again Racket programs rely on this a lot too (as do many dynamically typed programs) so it might not be a cost that kills performance completely. But do be aware of how others deal with this issue -- Matthias >> >> >> >> >> >> >> >> On Sep 28, 2014, at 10:03 PM, Alexander D. Knauth wrote: >> >>> >>> >>> On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: >>> >>>> >>>> Your message points out where gradual typing badly fails. >>>> >>>> Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. >>>> >>>> In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write >>>> >>>> area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] >>>> >>>> If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. >>>> >>>> This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. >>> >>> What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. >>> >>> And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. >>> >>> Is this sort of like what happens with flonum unboxing? >>> >>> >>> >>>> >>>> Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. >>>> >>>> -- Matthias >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: >>>> >>>>> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >>>>> >>>>> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >>>>> >>>>> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >>>>> >>>>> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >>>>> >>>>>> >>>>>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>>>>> >>>>>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>>>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>>>>> >>>>>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>>>>> >>>>>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>>>>> >>>>>>>> would something like this work? >>>>>>>> >>>>>>>> #lang typed/racket >>>>>>>> >>>>>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>>>>> >>>>>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>>>>> (define-type Weight (number+unit Weight-Unit)) >>>>>>>> (define-predicate weight? Weight) >>>>>>>> >>>>>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>>>>> (define (make-weight n u) >>>>>>>> (number+unit n u)) >>>>>>>> >>>>>>>> (: +/weight : Weight Weight -> Weight) >>>>>>>> ;; something something needs unit conversion >>>>>>>> (define (+/weight w1 w2) >>>>>>>> (number+unit (+ (number+unit-amount w1) >>>>>>>> (number+unit-amount w1)) >>>>>>>> (number+unit-unit w1))) >>>>>>>> >>>>>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>>>>> >>>>>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>>>>> >>>>>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>>>>> >>>>>>>> > Why not do this with the type, instead of making this polymorphic? >>>>>>>> > >>>>>>>> > Sam >>>>>>>> > >>>>>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>>>>> > wrote: >>>>>>>> >> Is it possible to have a struct that does certain things according to the >>>>>>>> >> guard? >>>>>>>> >> #lang typed/racket >>>>>>>> >> >>>>>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>>>>> >> #:guard (lambda (a _) >>>>>>>> >> (unless (exact-integer? a) >>>>>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>>>>> >> a)) >>>>>>>> >> >>>>>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>>>>> >> >>>>>>>> >> (: x : (foo Any)) >>>>>>>> >> (define x (foo 1)) >>>>>>>> >> >>>>>>>> >> (ann (foo-a x) Integer) >>>>>>>> >> >>>>>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>>>>> >> arguments: >>>>>>>> >> ;Argument 1: >>>>>>>> >> ; Expected: a >>>>>>>> >> ; Given: Any >>>>>>>> >> ; >>>>>>>> >> ;Result type: (foo a) >>>>>>>> >> ;Expected result: (foo Integer) >>>>>>>> >> ; in: (foo (ann 1 Any)) >>>>>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>>>>> >> arguments: >>>>>>>> >> ;Argument 1: >>>>>>>> >> ; Expected: (foo a) >>>>>>>> >> ; Given: (foo Any) >>>>>>>> >> ; >>>>>>>> >> ;Result type: (a : ....) >>>>>>>> >> ;Expected result: Integer >>>>>>>> >> ; in: (foo-a x) >>>>>>>> >> >>>>>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>>>>> >> wrote: >>>>>>>> >> >>>>>>>> >> What I?m trying to accomplish is something more like this: >>>>>>>> >> #lang typed/racket >>>>>>>> >> >>>>>>>> >> (require "dimensions.rkt") >>>>>>>> >> >>>>>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>>>>> >> #:transparent >>>>>>>> >> #:guard (lambda (name scalar dimension _) >>>>>>>> >> (unless (dimension? dimension) >>>>>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>>>>> >> (values name scalar dimension))) >>>>>>>> >> >>>>>>>> >> (define-type (Unitof d) (unit d)) >>>>>>>> >> >>>>>>>> >> (define-type Unit (Unitof Dimension)) >>>>>>>> >> >>>>>>>> >> (define Unit? (make-predicate Unit)) >>>>>>>> >> >>>>>>>> >> (define-type Unitish >>>>>>>> >> (U (Unitof Any) >>>>>>>> >> Dimension >>>>>>>> >> Positive-Real)) >>>>>>>> >> >>>>>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>>>>> >> [Unitish -> Unit]))) >>>>>>>> >> (define (->unit u) >>>>>>>> >> (cond [(unit? u) >>>>>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>>>>> >> guard >>>>>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>>>>> >> u] >>>>>>>> >> [(dimension? u) (unit u 1 u)] >>>>>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>>>>> >> wrote: >>>>>>>> >> >>>>>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>>>>> >> trying to accomplish? >>>>>>>> >> >>>>>>>> >> Sam >>>>>>>> >> >>>>>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>>>>> >> wrote: >>>>>>>> >> >>>>>>>> >> Do any of you have any advice for getting a function like this to >>>>>>>> >> type-check? >>>>>>>> >> #lang typed/racket >>>>>>>> >> >>>>>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>>>>> >> [Any -> Integer]))) >>>>>>>> >> (define (check-int int) >>>>>>>> >> (unless (exact-integer? int) >>>>>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>>>>> >> int) >>>>>>>> >> >>>>>>>> >> ;. Type Checker: type mismatch >>>>>>>> >> ; expected: a >>>>>>>> >> ; given: Integer in: int >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> ____________________ >>>>>>>> >> Racket Users list: >>>>>>>> >> http://lists.racket-lang.org/users >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> ____________________ >>>>>>>> >> Racket Users list: >>>>>>>> >> http://lists.racket-lang.org/users >>>>>>>> >> >>>>>>>> >> >>>>>>>> >>>>>>>> >>>>>>>> ____________________ >>>>>>>> Racket Users list: >>>>>>>> http://lists.racket-lang.org/users >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> ____________________ >>>>>>> Racket Users list: >>>>>>> http://lists.racket-lang.org/users >>>>>> >>>>> >>>> >>> >> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 74 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:29 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:29 -0400 Subject: [racket] users Digest, Vol 109, Issue 73 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 10:29 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > 2. Re: typed racket, filters, and polymorphism (Matthias Felleisen) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 22:03:02 -0400 > From: "Alexander D. Knauth" > To: Matthias Felleisen > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: <6237F562-9E68-4D2D-A307-49668BB8E5DF at knauth.org> > Content-Type: text/plain; charset="utf-8" > > > > On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: > >> >> Your message points out where gradual typing badly fails. >> >> Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. >> >> In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write >> >> area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] >> >> If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. >> >> This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. > > What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. > > And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. > > Is this sort of like what happens with flonum unboxing? > > > >> >> Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. >> >> -- Matthias >> >> >> >> >> >> >> >> >> On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: >> >>> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >>> >>> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >>> >>> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >>> >>> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >>> >>>> >>>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>>> >>>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>>> >>>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>>> >>>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>>> >>>>>> would something like this work? >>>>>> >>>>>> #lang typed/racket >>>>>> >>>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>>> >>>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>>> (define-type Weight (number+unit Weight-Unit)) >>>>>> (define-predicate weight? Weight) >>>>>> >>>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>>> (define (make-weight n u) >>>>>> (number+unit n u)) >>>>>> >>>>>> (: +/weight : Weight Weight -> Weight) >>>>>> ;; something something needs unit conversion >>>>>> (define (+/weight w1 w2) >>>>>> (number+unit (+ (number+unit-amount w1) >>>>>> (number+unit-amount w1)) >>>>>> (number+unit-unit w1))) >>>>>> >>>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>>> >>>>>> >>>>>> >>>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>>> >>>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>>> >>>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>>> >>>>>> > Why not do this with the type, instead of making this polymorphic? >>>>>> > >>>>>> > Sam >>>>>> > >>>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>>> > wrote: >>>>>> >> Is it possible to have a struct that does certain things according to the >>>>>> >> guard? >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>>> >> #:guard (lambda (a _) >>>>>> >> (unless (exact-integer? a) >>>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>>> >> a)) >>>>>> >> >>>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>>> >> >>>>>> >> (: x : (foo Any)) >>>>>> >> (define x (foo 1)) >>>>>> >> >>>>>> >> (ann (foo-a x) Integer) >>>>>> >> >>>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>>> >> arguments: >>>>>> >> ;Argument 1: >>>>>> >> ; Expected: a >>>>>> >> ; Given: Any >>>>>> >> ; >>>>>> >> ;Result type: (foo a) >>>>>> >> ;Expected result: (foo Integer) >>>>>> >> ; in: (foo (ann 1 Any)) >>>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>>> >> arguments: >>>>>> >> ;Argument 1: >>>>>> >> ; Expected: (foo a) >>>>>> >> ; Given: (foo Any) >>>>>> >> ; >>>>>> >> ;Result type: (a : ....) >>>>>> >> ;Expected result: Integer >>>>>> >> ; in: (foo-a x) >>>>>> >> >>>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>>> >> wrote: >>>>>> >> >>>>>> >> What I?m trying to accomplish is something more like this: >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (require "dimensions.rkt") >>>>>> >> >>>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>>> >> #:transparent >>>>>> >> #:guard (lambda (name scalar dimension _) >>>>>> >> (unless (dimension? dimension) >>>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>>> >> (values name scalar dimension))) >>>>>> >> >>>>>> >> (define-type (Unitof d) (unit d)) >>>>>> >> >>>>>> >> (define-type Unit (Unitof Dimension)) >>>>>> >> >>>>>> >> (define Unit? (make-predicate Unit)) >>>>>> >> >>>>>> >> (define-type Unitish >>>>>> >> (U (Unitof Any) >>>>>> >> Dimension >>>>>> >> Positive-Real)) >>>>>> >> >>>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>>> >> [Unitish -> Unit]))) >>>>>> >> (define (->unit u) >>>>>> >> (cond [(unit? u) >>>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>>> >> guard >>>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>>> >> u] >>>>>> >> [(dimension? u) (unit u 1 u)] >>>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>>> >> >>>>>> >> >>>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>>> >> wrote: >>>>>> >> >>>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>>> >> trying to accomplish? >>>>>> >> >>>>>> >> Sam >>>>>> >> >>>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>>> >> wrote: >>>>>> >> >>>>>> >> Do any of you have any advice for getting a function like this to >>>>>> >> type-check? >>>>>> >> #lang typed/racket >>>>>> >> >>>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>>> >> [Any -> Integer]))) >>>>>> >> (define (check-int int) >>>>>> >> (unless (exact-integer? int) >>>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>>> >> int) >>>>>> >> >>>>>> >> ;. Type Checker: type mismatch >>>>>> >> ; expected: a >>>>>> >> ; given: Integer in: int >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> ____________________ >>>>>> >> Racket Users list: >>>>>> >> http://lists.racket-lang.org/users >>>>>> >> >>>>>> >> >>>>>> >> ____________________ >>>>>> >> Racket Users list: >>>>>> >> http://lists.racket-lang.org/users >>>>>> >> >>>>>> >> >>>>>> >>>>>> >>>>>> ____________________ >>>>>> Racket Users list: >>>>>> http://lists.racket-lang.org/users >>>>>> >>>>>> >>>>> >>>>> ____________________ >>>>> Racket Users list: >>>>> http://lists.racket-lang.org/users >>>> >>> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Sun, 28 Sep 2014 22:29:31 -0400 > From: Matthias Felleisen > To: "Alexander D. Knauth" > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: <6ADD4F6D-6B79-4F32-AD11-379CD2FF87AB at ccs.neu.edu> > Content-Type: text/plain; charset="utf-8" > > > You might be able to unwrap such things for a local context, but then you need to wrap it again on the way out. That cost might become quite high if it happens in a loop. Then again Racket programs rely on this a lot too (as do many dynamically typed programs) so it might not be a cost that kills performance completely. But do be aware of how others deal with this issue -- Matthias > > > > > > > > On Sep 28, 2014, at 10:03 PM, Alexander D. Knauth wrote: > >> >> >> On Sep 28, 2014, at 8:25 PM, Matthias Felleisen wrote: >> >>> >>> Your message points out where gradual typing badly fails. >>> >>> Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. >>> >>> In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write >>> >>> area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] >>> >>> If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. >>> >>> This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. >> >> What I had in mind was for the structs to be available at run-time, but that ideally the optimizer could take them out for the intermediate operations and put them back for the final result. >> >> And then if this value goes into untyped code, then it knows at run-time that it has the unit (u* millimeter kilometer), which is unit=? to square-meter. >> >> Is this sort of like what happens with flonum unboxing? >> >> >> >>> >>> Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. >>> >>> -- Matthias >>> >>> >>> >>> >>> >>> >>> >>> >>> On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: >>> >>>> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >>>> >>>> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >>>> >>>> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >>>> >>>> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >>>> >>>>> >>>>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>>>> >>>>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>>>> >>>>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>>>> >>>>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>>>> >>>>>>> would something like this work? >>>>>>> >>>>>>> #lang typed/racket >>>>>>> >>>>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>>>> >>>>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>>>> (define-type Weight (number+unit Weight-Unit)) >>>>>>> (define-predicate weight? Weight) >>>>>>> >>>>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>>>> (define (make-weight n u) >>>>>>> (number+unit n u)) >>>>>>> >>>>>>> (: +/weight : Weight Weight -> Weight) >>>>>>> ;; something something needs unit conversion >>>>>>> (define (+/weight w1 w2) >>>>>>> (number+unit (+ (number+unit-amount w1) >>>>>>> (number+unit-amount w1)) >>>>>>> (number+unit-unit w1))) >>>>>>> >>>>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>>>> >>>>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>>>> >>>>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>>>> >>>>>>> > Why not do this with the type, instead of making this polymorphic? >>>>>>> > >>>>>>> > Sam >>>>>>> > >>>>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>>>> > wrote: >>>>>>> >> Is it possible to have a struct that does certain things according to the >>>>>>> >> guard? >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>>>> >> #:guard (lambda (a _) >>>>>>> >> (unless (exact-integer? a) >>>>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>>>> >> a)) >>>>>>> >> >>>>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>>>> >> >>>>>>> >> (: x : (foo Any)) >>>>>>> >> (define x (foo 1)) >>>>>>> >> >>>>>>> >> (ann (foo-a x) Integer) >>>>>>> >> >>>>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>>>> >> arguments: >>>>>>> >> ;Argument 1: >>>>>>> >> ; Expected: a >>>>>>> >> ; Given: Any >>>>>>> >> ; >>>>>>> >> ;Result type: (foo a) >>>>>>> >> ;Expected result: (foo Integer) >>>>>>> >> ; in: (foo (ann 1 Any)) >>>>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>>>> >> arguments: >>>>>>> >> ;Argument 1: >>>>>>> >> ; Expected: (foo a) >>>>>>> >> ; Given: (foo Any) >>>>>>> >> ; >>>>>>> >> ;Result type: (a : ....) >>>>>>> >> ;Expected result: Integer >>>>>>> >> ; in: (foo-a x) >>>>>>> >> >>>>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> What I?m trying to accomplish is something more like this: >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (require "dimensions.rkt") >>>>>>> >> >>>>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>>>> >> #:transparent >>>>>>> >> #:guard (lambda (name scalar dimension _) >>>>>>> >> (unless (dimension? dimension) >>>>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>>>> >> (values name scalar dimension))) >>>>>>> >> >>>>>>> >> (define-type (Unitof d) (unit d)) >>>>>>> >> >>>>>>> >> (define-type Unit (Unitof Dimension)) >>>>>>> >> >>>>>>> >> (define Unit? (make-predicate Unit)) >>>>>>> >> >>>>>>> >> (define-type Unitish >>>>>>> >> (U (Unitof Any) >>>>>>> >> Dimension >>>>>>> >> Positive-Real)) >>>>>>> >> >>>>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>>>> >> [Unitish -> Unit]))) >>>>>>> >> (define (->unit u) >>>>>>> >> (cond [(unit? u) >>>>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>>>> >> guard >>>>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>>>> >> u] >>>>>>> >> [(dimension? u) (unit u 1 u)] >>>>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>>>> >> >>>>>>> >> >>>>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>>>> >> trying to accomplish? >>>>>>> >> >>>>>>> >> Sam >>>>>>> >> >>>>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>>>> >> wrote: >>>>>>> >> >>>>>>> >> Do any of you have any advice for getting a function like this to >>>>>>> >> type-check? >>>>>>> >> #lang typed/racket >>>>>>> >> >>>>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>>>> >> [Any -> Integer]))) >>>>>>> >> (define (check-int int) >>>>>>> >> (unless (exact-integer? int) >>>>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>>>> >> int) >>>>>>> >> >>>>>>> >> ;. Type Checker: type mismatch >>>>>>> >> ; expected: a >>>>>>> >> ; given: Integer in: int >>>>>>> >> >>>>>>> >> >>>>>>> >> >>>>>>> >> ____________________ >>>>>>> >> Racket Users list: >>>>>>> >> http://lists.racket-lang.org/users >>>>>>> >> >>>>>>> >> >>>>>>> >> ____________________ >>>>>>> >> Racket Users list: >>>>>>> >> http://lists.racket-lang.org/users >>>>>>> >> >>>>>>> >> >>>>>>> >>>>>>> >>>>>>> ____________________ >>>>>>> Racket Users list: >>>>>>> http://lists.racket-lang.org/users >>>>>>> >>>>>>> >>>>>> >>>>>> ____________________ >>>>>> Racket Users list: >>>>>> http://lists.racket-lang.org/users >>>>> >>>> >>> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 73 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:38 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:38 -0400 Subject: [racket] users Digest, Vol 109, Issue 72 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 8:26 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > 2. Re: typed racket, filters, and polymorphism (Matthias Felleisen) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 20:14:43 -0400 > From: "Alexander D. Knauth" > To: Matthias Felleisen > Cc: Spencer florence , racket users list > , Sam Tobin-Hochstadt > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > Content-Type: text/plain; charset="utf-8" > > Yes I do want run-time residual of the dimensions, and yes I want a unit struct. > > Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. > > And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. > > On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: > >> >> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >> >> >> >> >> >> >> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >> >>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>> >>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>> >>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>> >>>> would something like this work? >>>> >>>> #lang typed/racket >>>> >>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>> >>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>> (define-type Weight (number+unit Weight-Unit)) >>>> (define-predicate weight? Weight) >>>> >>>> (: make-weight : Real Weight-Unit -> Weight) >>>> (define (make-weight n u) >>>> (number+unit n u)) >>>> >>>> (: +/weight : Weight Weight -> Weight) >>>> ;; something something needs unit conversion >>>> (define (+/weight w1 w2) >>>> (number+unit (+ (number+unit-amount w1) >>>> (number+unit-amount w1)) >>>> (number+unit-unit w1))) >>>> >>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>> >>>> >>>> >>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>> >>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>> >>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>> >>>> > Why not do this with the type, instead of making this polymorphic? >>>> > >>>> > Sam >>>> > >>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>> > wrote: >>>> >> Is it possible to have a struct that does certain things according to the >>>> >> guard? >>>> >> #lang typed/racket >>>> >> >>>> >> (struct (a) foo ([a : a]) #:transparent >>>> >> #:guard (lambda (a _) >>>> >> (unless (exact-integer? a) >>>> >> (error 'foo "expected Integer, given ~v" a)) >>>> >> a)) >>>> >> >>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>> >> >>>> >> (: x : (foo Any)) >>>> >> (define x (foo 1)) >>>> >> >>>> >> (ann (foo-a x) Integer) >>>> >> >>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>> >> arguments: >>>> >> ;Argument 1: >>>> >> ; Expected: a >>>> >> ; Given: Any >>>> >> ; >>>> >> ;Result type: (foo a) >>>> >> ;Expected result: (foo Integer) >>>> >> ; in: (foo (ann 1 Any)) >>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>> >> arguments: >>>> >> ;Argument 1: >>>> >> ; Expected: (foo a) >>>> >> ; Given: (foo Any) >>>> >> ; >>>> >> ;Result type: (a : ....) >>>> >> ;Expected result: Integer >>>> >> ; in: (foo-a x) >>>> >> >>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>> >> wrote: >>>> >> >>>> >> What I?m trying to accomplish is something more like this: >>>> >> #lang typed/racket >>>> >> >>>> >> (require "dimensions.rkt") >>>> >> >>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>> >> #:transparent >>>> >> #:guard (lambda (name scalar dimension _) >>>> >> (unless (dimension? dimension) >>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>> >> (values name scalar dimension))) >>>> >> >>>> >> (define-type (Unitof d) (unit d)) >>>> >> >>>> >> (define-type Unit (Unitof Dimension)) >>>> >> >>>> >> (define Unit? (make-predicate Unit)) >>>> >> >>>> >> (define-type Unitish >>>> >> (U (Unitof Any) >>>> >> Dimension >>>> >> Positive-Real)) >>>> >> >>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>> >> [Unitish -> Unit]))) >>>> >> (define (->unit u) >>>> >> (cond [(unit? u) >>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>> >> guard >>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>> >> u] >>>> >> [(dimension? u) (unit u 1 u)] >>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>> >> >>>> >> >>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>> >> wrote: >>>> >> >>>> >> No, I don't think you can do this. Can you say more about what you're >>>> >> trying to accomplish? >>>> >> >>>> >> Sam >>>> >> >>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>> >> wrote: >>>> >> >>>> >> Do any of you have any advice for getting a function like this to >>>> >> type-check? >>>> >> #lang typed/racket >>>> >> >>>> >> (: check-int : (All (a) (case-> [a -> a] >>>> >> [Any -> Integer]))) >>>> >> (define (check-int int) >>>> >> (unless (exact-integer? int) >>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>> >> int) >>>> >> >>>> >> ;. Type Checker: type mismatch >>>> >> ; expected: a >>>> >> ; given: Integer in: int >>>> >> >>>> >> >>>> >> >>>> >> ____________________ >>>> >> Racket Users list: >>>> >> http://lists.racket-lang.org/users >>>> >> >>>> >> >>>> >> ____________________ >>>> >> Racket Users list: >>>> >> http://lists.racket-lang.org/users >>>> >> >>>> >> >>>> >>>> >>>> ____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >>>> >>>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Sun, 28 Sep 2014 20:25:45 -0400 > From: Matthias Felleisen > To: "Alexander D. Knauth" > Cc: racket users list , Benjamin Greenman > > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > Content-Type: text/plain; charset="utf-8" > > > Your message points out where gradual typing badly fails. > > Type systems combine two nearly orthogonal ideas: (1) proving theorems about your program and (2) bridging the gap between abstract linguistic constructs and concrete machine implementations. In a sense, the design of a type system should always have the goal to eliminate as much run-time overhead as possible. > > In this specific case, you have two aspects of dimensionality: dimension per se (I am sure there is a word for it) and the chosen unit to represent it. So if you know that a number denotes a distance, you can choose mm, m, and km to represent it. If you want to represent an area, you choose mm^2, m^2, km^2. Now if you want to compute the area of a rectangle, you write > > area-of-rectangle : Real [Distance in m] * Real [Distance in m] -> Real [Area in m^2] > > If someone writes (area-of-rectangle 1 [mm] 1 [km]), there is nothing wrong with it -- except that the type checker should insert a coercion from mm to m and from km to m (multiplying/dividing by 1,000). That is, a type system for this application ought to use the type elaboration process idea and translate code as it goes. > > This is quite comparable to the idea that a machine-oriented type system needs to insert a coercion from integer to real (for example) as Algol 60 and its degraded successors do. > > Our gradual type system lacks some (intensiona) expressive power, which is why you can't get close to this ideal. > > -- Matthias > > > > > > > > > On Sep 28, 2014, at 8:14 PM, Alexander D. Knauth wrote: > >> Yes I do want run-time residual of the dimensions, and yes I want a unit struct. >> >> Also if there?s run-time residual, then I can use predicates and occurrence typing, and it can also be used in untyped code with contracts instead of types. >> >> And also the type-checker would check if it is dimension-correct, but at run-time it would would still convert between different units of the same dimension, multiply and divide units, etc. >> >> On Sep 28, 2014, at 6:58 PM, Matthias Felleisen wrote: >> >>> >>> If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias >>> >>> >>> >>> >>> >>> >>> On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: >>> >>>> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >>>> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >>>> >>>> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >>>> >>>> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >>>> >>>>> would something like this work? >>>>> >>>>> #lang typed/racket >>>>> >>>>> (struct (U) number+unit ([amount : Real] [unit : U])) >>>>> >>>>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>>>> (define-type Weight (number+unit Weight-Unit)) >>>>> (define-predicate weight? Weight) >>>>> >>>>> (: make-weight : Real Weight-Unit -> Weight) >>>>> (define (make-weight n u) >>>>> (number+unit n u)) >>>>> >>>>> (: +/weight : Weight Weight -> Weight) >>>>> ;; something something needs unit conversion >>>>> (define (+/weight w1 w2) >>>>> (number+unit (+ (number+unit-amount w1) >>>>> (number+unit-amount w1)) >>>>> (number+unit-unit w1))) >>>>> >>>>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>>>> >>>>> >>>>> >>>>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>>>> >>>>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>>>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>>>> >>>>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>>>> >>>>> > Why not do this with the type, instead of making this polymorphic? >>>>> > >>>>> > Sam >>>>> > >>>>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>>>> > wrote: >>>>> >> Is it possible to have a struct that does certain things according to the >>>>> >> guard? >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (struct (a) foo ([a : a]) #:transparent >>>>> >> #:guard (lambda (a _) >>>>> >> (unless (exact-integer? a) >>>>> >> (error 'foo "expected Integer, given ~v" a)) >>>>> >> a)) >>>>> >> >>>>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>>>> >> >>>>> >> (: x : (foo Any)) >>>>> >> (define x (foo 1)) >>>>> >> >>>>> >> (ann (foo-a x) Integer) >>>>> >> >>>>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>>>> >> arguments: >>>>> >> ;Argument 1: >>>>> >> ; Expected: a >>>>> >> ; Given: Any >>>>> >> ; >>>>> >> ;Result type: (foo a) >>>>> >> ;Expected result: (foo Integer) >>>>> >> ; in: (foo (ann 1 Any)) >>>>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>>>> >> arguments: >>>>> >> ;Argument 1: >>>>> >> ; Expected: (foo a) >>>>> >> ; Given: (foo Any) >>>>> >> ; >>>>> >> ;Result type: (a : ....) >>>>> >> ;Expected result: Integer >>>>> >> ; in: (foo-a x) >>>>> >> >>>>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>>>> >> wrote: >>>>> >> >>>>> >> What I?m trying to accomplish is something more like this: >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (require "dimensions.rkt") >>>>> >> >>>>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>>>> >> #:transparent >>>>> >> #:guard (lambda (name scalar dimension _) >>>>> >> (unless (dimension? dimension) >>>>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>>>> >> (values name scalar dimension))) >>>>> >> >>>>> >> (define-type (Unitof d) (unit d)) >>>>> >> >>>>> >> (define-type Unit (Unitof Dimension)) >>>>> >> >>>>> >> (define Unit? (make-predicate Unit)) >>>>> >> >>>>> >> (define-type Unitish >>>>> >> (U (Unitof Any) >>>>> >> Dimension >>>>> >> Positive-Real)) >>>>> >> >>>>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>>>> >> [Unitish -> Unit]))) >>>>> >> (define (->unit u) >>>>> >> (cond [(unit? u) >>>>> >> (unless (Unit? u) ; this should never happen anyway because of the >>>>> >> guard >>>>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>>>> >> u] >>>>> >> [(dimension? u) (unit u 1 u)] >>>>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>>>> >> >>>>> >> >>>>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>>>> >> wrote: >>>>> >> >>>>> >> No, I don't think you can do this. Can you say more about what you're >>>>> >> trying to accomplish? >>>>> >> >>>>> >> Sam >>>>> >> >>>>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>>>> >> wrote: >>>>> >> >>>>> >> Do any of you have any advice for getting a function like this to >>>>> >> type-check? >>>>> >> #lang typed/racket >>>>> >> >>>>> >> (: check-int : (All (a) (case-> [a -> a] >>>>> >> [Any -> Integer]))) >>>>> >> (define (check-int int) >>>>> >> (unless (exact-integer? int) >>>>> >> (error 'check-int "expected Integer, given ~v" int)) >>>>> >> int) >>>>> >> >>>>> >> ;. Type Checker: type mismatch >>>>> >> ; expected: a >>>>> >> ; given: Integer in: int >>>>> >> >>>>> >> >>>>> >> >>>>> >> ____________________ >>>>> >> Racket Users list: >>>>> >> http://lists.racket-lang.org/users >>>>> >> >>>>> >> >>>>> >> ____________________ >>>>> >> Racket Users list: >>>>> >> http://lists.racket-lang.org/users >>>>> >> >>>>> >> >>>>> >>>>> >>>>> ____________________ >>>>> Racket Users list: >>>>> http://lists.racket-lang.org/users >>>>> >>>>> >>>> >>>> ____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >>> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 72 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:47 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:47 -0400 Subject: [racket] users Digest, Vol 109, Issue 71 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 6:58 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: aws/glacier: credential scope (Greg Hendershott) > 2. Re: aws/glacier: credential scope (Greg Hendershott) > 3. Re: aws/glacier: credential scope (Norman Gray) > 4. Re: aws/glacier: credential scope (Greg Hendershott) > 5. Re: typed racket, filters, and polymorphism (Matthias Felleisen) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 17:15:21 -0400 > From: Greg Hendershott > To: Jay McCarthy > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > >> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >> than usual to refresh. After it does, you can `raco pkg update aws` to >> get the fix. > > Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: > > "update upload in progress: there may be inconsistencies below" > > It's been saying that for nearly an hour. > > In the past, clicking "update" would cause a successful refresh -- the > package would get a red star indicating it's updated -- within a > minute or two. > > > ------------------------------ > > Message: 2 > Date: Sun, 28 Sep 2014 17:17:32 -0400 > From: Greg Hendershott > To: Jay McCarthy > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > >>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>> than usual to refresh. After it does, you can `raco pkg update aws` to >>> get the fix. >> >> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >> >> "update upload in progress: there may be inconsistencies below" >> >> It's been saying that for nearly an hour. > > Sometimes instead it says: > > "update upload being computed: the information below may not > represent all recent changes and updates" > > It has switched between those two messages at various intervals over > the last hour. > > > ------------------------------ > > Message: 3 > Date: Sun, 28 Sep 2014 22:40:19 +0100 > From: Norman Gray > To: Greg Hendershott > Cc: Jay McCarthy , users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: <73617243-E0D5-43C6-872B-EA0121AD5142 at astro.gla.ac.uk> > Content-Type: text/plain; charset=us-ascii > > > On 2014 Sep 28, at 22:17, Greg Hendershott wrote: > >>>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>>> than usual to refresh. After it does, you can `raco pkg update aws` to >>>> get the fix. >>> >>> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >>> >>> "update upload in progress: there may be inconsistencies below" >>> >>> It's been saying that for nearly an hour. >> >> Sometimes instead it says: >> >> "update upload being computed: the information below may not >> represent all recent changes and updates" >> >> It has switched between those two messages at various intervals over >> the last hour. > > And in case it's a useful data point, I'm getting > > % raco pkg update aws > Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ > Resolving "aws" via http://pkgs.racket-lang.org > No updates available > % > > And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... > > Norman > > > -- > Norman Gray : http://nxg.me.uk > SUPA School of Physics and Astronomy, University of Glasgow, UK > > > > > ------------------------------ > > Message: 4 > Date: Sun, 28 Sep 2014 18:10:55 -0400 > From: Greg Hendershott > To: Norman Gray > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > If you're in a hurry you could remove and re-install directly from GitHub: > > $ raco pkg remove aws > $ raco pkg install git://github.com/greghendershott/aws > > On Sun, Sep 28, 2014 at 5:40 PM, Norman Gray wrote: >> >> On 2014 Sep 28, at 22:17, Greg Hendershott wrote: >> >>>>> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower >>>>> than usual to refresh. After it does, you can `raco pkg update aws` to >>>>> get the fix. >>>> >>>> Something seems wrong/stuck on pkgs.racket-lang.org. The top of the page says: >>>> >>>> "update upload in progress: there may be inconsistencies below" >>>> >>>> It's been saying that for nearly an hour. >>> >>> Sometimes instead it says: >>> >>> "update upload being computed: the information below may not >>> represent all recent changes and updates" >>> >>> It has switched between those two messages at various intervals over >>> the last hour. >> >> And in case it's a useful data point, I'm getting >> >> % raco pkg update aws >> Resolving "aws" via http://download.racket-lang.org/releases/6.1/catalog/ >> Resolving "aws" via http://pkgs.racket-lang.org >> No updates available >> % >> >> And Greg, your fix is close enough to what I guessed might be the problem that I'm now kicking myself for not just diving in and trying a fix myself. Garhhhh... >> >> Norman >> >> >> -- >> Norman Gray : http://nxg.me.uk >> SUPA School of Physics and Astronomy, University of Glasgow, UK >> > > > ------------------------------ > > Message: 5 > Date: Sun, 28 Sep 2014 18:58:20 -0400 > From: Matthias Felleisen > To: "Alexander D. Knauth" > Cc: Spencer florence , racket users list > , Sam Tobin-Hochstadt > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2 at ccs.neu.edu> > Content-Type: text/plain; charset="utf-8" > > > If you want the type checker to ensure your program is unit-correct, I assume you also want no run-time residual of the dimensions but that is in conflict with wanting a structure because it imposes a run-time cost. Are you sure you want a unit? -- Matthias > > > > > > > On Sep 28, 2014, at 1:37 PM, Alexander D. Knauth wrote: > >> No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. >> I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. >> >> I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. >> >> On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: >> >>> would something like this work? >>> >>> #lang typed/racket >>> >>> (struct (U) number+unit ([amount : Real] [unit : U])) >>> >>> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >>> (define-type Weight (number+unit Weight-Unit)) >>> (define-predicate weight? Weight) >>> >>> (: make-weight : Real Weight-Unit -> Weight) >>> (define (make-weight n u) >>> (number+unit n u)) >>> >>> (: +/weight : Weight Weight -> Weight) >>> ;; something something needs unit conversion >>> (define (+/weight w1 w2) >>> (number+unit (+ (number+unit-amount w1) >>> (number+unit-amount w1)) >>> (number+unit-unit w1))) >>> >>> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >>> >>> >>> >>> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >>> >>> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >>> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >>> >>> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >>> >>> > Why not do this with the type, instead of making this polymorphic? >>> > >>> > Sam >>> > >>> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >>> > wrote: >>> >> Is it possible to have a struct that does certain things according to the >>> >> guard? >>> >> #lang typed/racket >>> >> >>> >> (struct (a) foo ([a : a]) #:transparent >>> >> #:guard (lambda (a _) >>> >> (unless (exact-integer? a) >>> >> (error 'foo "expected Integer, given ~v" a)) >>> >> a)) >>> >> >>> >> (ann (foo (ann 1 Any)) (foo Integer)) >>> >> >>> >> (: x : (foo Any)) >>> >> (define x (foo 1)) >>> >> >>> >> (ann (foo-a x) Integer) >>> >> >>> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >>> >> arguments: >>> >> ;Argument 1: >>> >> ; Expected: a >>> >> ; Given: Any >>> >> ; >>> >> ;Result type: (foo a) >>> >> ;Expected result: (foo Integer) >>> >> ; in: (foo (ann 1 Any)) >>> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >>> >> arguments: >>> >> ;Argument 1: >>> >> ; Expected: (foo a) >>> >> ; Given: (foo Any) >>> >> ; >>> >> ;Result type: (a : ....) >>> >> ;Expected result: Integer >>> >> ; in: (foo-a x) >>> >> >>> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >>> >> wrote: >>> >> >>> >> What I?m trying to accomplish is something more like this: >>> >> #lang typed/racket >>> >> >>> >> (require "dimensions.rkt") >>> >> >>> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >>> >> #:transparent >>> >> #:guard (lambda (name scalar dimension _) >>> >> (unless (dimension? dimension) >>> >> (error 'unit "expected Dimension, given ~v" dimension)) >>> >> (values name scalar dimension))) >>> >> >>> >> (define-type (Unitof d) (unit d)) >>> >> >>> >> (define-type Unit (Unitof Dimension)) >>> >> >>> >> (define Unit? (make-predicate Unit)) >>> >> >>> >> (define-type Unitish >>> >> (U (Unitof Any) >>> >> Dimension >>> >> Positive-Real)) >>> >> >>> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >>> >> [Unitish -> Unit]))) >>> >> (define (->unit u) >>> >> (cond [(unit? u) >>> >> (unless (Unit? u) ; this should never happen anyway because of the >>> >> guard >>> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >>> >> u] >>> >> [(dimension? u) (unit u 1 u)] >>> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >>> >> >>> >> >>> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >>> >> wrote: >>> >> >>> >> No, I don't think you can do this. Can you say more about what you're >>> >> trying to accomplish? >>> >> >>> >> Sam >>> >> >>> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>> >> wrote: >>> >> >>> >> Do any of you have any advice for getting a function like this to >>> >> type-check? >>> >> #lang typed/racket >>> >> >>> >> (: check-int : (All (a) (case-> [a -> a] >>> >> [Any -> Integer]))) >>> >> (define (check-int int) >>> >> (unless (exact-integer? int) >>> >> (error 'check-int "expected Integer, given ~v" int)) >>> >> int) >>> >> >>> >> ;. Type Checker: type mismatch >>> >> ; expected: a >>> >> ; given: Integer in: int >>> >> >>> >> >>> >> >>> >> ____________________ >>> >> Racket Users list: >>> >> http://lists.racket-lang.org/users >>> >> >>> >> >>> >> ____________________ >>> >> Racket Users list: >>> >> http://lists.racket-lang.org/users >>> >> >>> >> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >>> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 71 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:41:57 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:41:57 -0400 Subject: [racket] users Digest, Vol 109, Issue 70 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 4:29 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: Help debugging a ffi crash (Eric Dobson) > 2. How to document a field? (Roman Klochkov) > 3. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > 4. Re: aws/glacier: credential scope (Greg Hendershott) > 5. Re: aws/glacier: credential scope (Norman Gray) > 6. Re: aws/glacier: credential scope (Greg Hendershott) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 11:15:33 -0700 > From: Eric Dobson > To: Matthew Flatt > Cc: "users at racket-lang.org" > Subject: Re: [racket] Help debugging a ffi crash > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > That is almost surely it, thanks for the second pair of eyes. I had > similar issues with a different type that I thought was a pointer but > was actually a struct, but that one I couldn't even get a single call > to work so it was much more obvious something was up. > > On Sun, Sep 28, 2014 at 11:08 AM, Matthew Flatt wrote: >> Looking at >> >> http://clang.llvm.org/doxygen/CXString_8h_source.html >> >> it seems that CXString as returned by clang_getCursorSpelling() is not >> a pointer: >> >> typedef struct { >> const void *data; >> unsigned private_flags; >> } CXString; >> >> If that's right, I'm a little surprised that `cursor-spelling` works >> --- but when you get representation wrong, strange things can happen, >> including something working when it shouldn't. >> >> Am I looking at the right library/definitions? >> >> At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote: >>> I'm trying to debug an FFI crash that I'm seeing, and because it is >>> dealing with C code the error just presents as a segfault. I believe I >>> have tracked down what is causing the problem, but don't understand >>> how it could be doing so. >>> >>> I have two racket functions which take a "cursor" (the foreign >>> libraries object) and return a string representation of it, which I'm >>> trying to use for debugging. >>> >>> (define raw-clang-get-cstring >>> (get-ffi-obj "clang_getCString" lib-clang >>> (_fun _pointer -> _string))) >>> >>> (define raw-cursor-spelling >>> (get-ffi-obj "clang_getCursorSpelling" lib-clang >>> (_fun _CXCursor -> _pointer))) >>> >>> (define (cursor-spelling c) >>> (raw-clang-get-cstring (raw-cursor-spelling c))) >>> >>> (define cursor-spelling2 >>> (get-ffi-obj "clang_getCursorSpelling" lib-clang >>> (_fun _CXCursor -> (make-ctype _pointer values (? (v) >>> (raw-clang-get-cstring v)))))) >>> >>> If I use cursor-spelling, I have not been able to trigger a crash. But >>> if I use cursor-spelling2 I can reliably trigger a crash. >>> >>> Is there anything obvious on how these functions are different? >>> Because they look to me like they should be doing the same thing. If >>> it would be helpful I can try to get my code in a portable enough >>> shape so that it will work/crash on another machine. >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users > > > > ------------------------------ > > Message: 2 > Date: Sun, 28 Sep 2014 22:39:54 +0400 > From: Roman Klochkov > To: racket users list > Subject: [racket] How to document a field? > Message-ID: <1411929594.923492574 at f67.i.mail.ru> > Content-Type: text/plain; charset="utf-8" > > At http://docs.racket-lang.org/scribble/doc-classes.html I see classes, interfaces, methods, but don't see fields. > > How to document them? Via @defthing or is there some syntax with (get-field ..) (set-field! ...) template like @defparam ? > > > -- > Roman Klochkov > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 3 > Date: Sun, 28 Sep 2014 13:51:26 -0500 > From: Bill Richter > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409281851.s8SIpQMx006764 at poisson.math.northwestern.edu> > > Matthias & Prabhakar, I think I see what you're saying now. I need the camlp parser to turn my dialect-expressions into trees. Then I turn my tree into standard expressions just as one does in Scheme. The only differences is that in Scheme we have the quote function that skips the parsing step. So your ML code > > MF> type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast > MF> type val = BASIC of int | FUNCTION of val -> val | ... > > looks a lot like the HOL Light definition of preterms: > > type preterm = Varp of string * pretype (* Variable - v *) > | Constp of string * pretype (* Constant - c *) > | Combp of preterm * preterm (* Combination - f x *) > | Absp of preterm * preterm (* Lambda-abstraction - \x. t *) > | Typing of preterm * pretype;; (* Type constraint - t : ty *) > > and so we can see one of these preterms in a standard term: > > # preterm_of_term `x + y`;; > val it : preterm = > Combp > (Combp > (Constp ("+", > Ptycon ("fun", > [Ptycon ("num", []); > Ptycon ("fun", [Ptycon ("num", []); Ptycon ("num", [])])])), > Varp ("x", Ptycon ("num", []))), > Varp ("y", Ptycon ("num", []))) > > So the Scheme story works fine except that I haven't understood camlp or how HOL Light turns expressions `[...]` into preterms. But I feel better about investing the time into learning camlp now that I see the Scheme story remains intact in HOL Light. And you're right about my ignorance: > > MF> 1. HtDP explains the above in a couple of sections. > > Right, there's something I seem not to have understood in either Scheme or ML, how when we create and evaluate our trees we retain the values of our variables. I can figure that out, and HtDP sounds like a good place to start. > > PR> A Racketeer would probably tell you to use macros to define your > PR> dialect, instead of using an eval hack. The corresponding tool for > PR> OCaml is camlp4, and it sounds as if it would be worth your time > PR> to learn it thoroughly. > > That's an interesting comparison, and since macros, maybe I can learn to like camlp. In fact, maybe I ought to learn something about racket macros first. > > -- > Best, > Bill > > > ------------------------------ > > Message: 4 > Date: Sun, 28 Sep 2014 16:01:20 -0400 > From: Greg Hendershott > To: Norman Gray > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Hi, Norman. > > I logged an issue for this: > > https://github.com/greghendershott/aws/issues/32 > > I see the problem (or at least the main problem) and will push a fix. > > The bug is embarrassing, not just because it's such a silly mistake, > but it's something a unit test could have caught. (I could say that > doing unit tests for Glacier is challenging, because the retrieval > process can take hours. Although that's true, I could have done more > to test _some_ operations working among various regions.) > > On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray wrote: >> >> Greetings. >> >> I'm trying to use the aws/glacier package, and running into a problem where I'm being told: >> >> Credential should be scoped to a valid region, not 'eu-west-1' >> >> I'm following the instructions at >> >> My test code is: >> >> % cat glacier.rkt >> #lang racket/base >> >> (require aws/glacier >> aws/keys) >> >> (define vault "testvault") >> (region "eu-west-1") >> (read-keys "aws-zbu-credentials") ; local file >> >> (module+ main >> (printf "region=~a~%" (region)) >> (printf "Vaults: ~s~%" (list-vaults)) >> (printf "...specifically: ~s~%" (describe-vault vault))) >> >> Running this produces: >> >> % racket glacier.rkt >> region=eu-west-1 >> aws: HTTP/1.1 403 Forbidden >> x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 >> Content-Type: application/json >> Content-Length: 129 >> Date: Sat, 27 Sep 2014 18:35:50 GMT >> >> {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} >> HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " >> context...: >> check-response >> /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 >> request/redirect/uri >> (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] >> >> Things I thought of: >> >> * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. >> * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. >> * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com >> * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. >> * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. >> * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. >> >> If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. >> >> I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? >> >> Thanks for any pointers. >> >> All the best, >> >> Norman >> >> >> -- >> Norman Gray : http://nxg.me.uk >> SUPA School of Physics and Astronomy, University of Glasgow, UK >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > ------------------------------ > > Message: 5 > Date: Sun, 28 Sep 2014 21:29:03 +0100 > From: Norman Gray > To: Greg Hendershott > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > Content-Type: text/plain; charset=us-ascii > > > Greg, hello. > > On 2014 Sep 28, at 21:01, Greg Hendershott wrote: > >> I logged an issue for this: >> >> https://github.com/greghendershott/aws/issues/32 > > Ah: I wondered if the problem might be related to that. > >> The bug is embarrassing, not just because it's such a silly mistake, >> but it's something a unit test could have caught. (I could say that >> doing unit tests for Glacier is challenging, because the retrieval >> process can take hours. > > I can imagine how protracted that would be ... *shudder*. > > Thanks for looking at this. > > Also, Frank: > >> What happens if you read-keys before setting the region? > > Thanks for this suggestion: I did try that just a little earlier, but it didn't make any difference. > > All the best, > > Norman > > > -- > Norman Gray : http://nxg.me.uk > SUPA School of Physics and Astronomy, University of Glasgow, UK > > > > > ------------------------------ > > Message: 6 > Date: Sun, 28 Sep 2014 16:29:12 -0400 > From: Greg Hendershott > To: Norman Gray > Cc: users at racket-lang.org > Subject: Re: [racket] aws/glacier: credential scope > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I pushed a fix, including running the tests across a few different AWS > regions. They pass. > > I clicked "update" on pkgs.racket-lang.org. But it seems to be slower > than usual to refresh. After it does, you can `raco pkg update aws` to > get the fix. > > On Sun, Sep 28, 2014 at 4:01 PM, Greg Hendershott > wrote: >> Hi, Norman. >> >> I logged an issue for this: >> >> https://github.com/greghendershott/aws/issues/32 >> >> I see the problem (or at least the main problem) and will push a fix. >> >> The bug is embarrassing, not just because it's such a silly mistake, >> but it's something a unit test could have caught. (I could say that >> doing unit tests for Glacier is challenging, because the retrieval >> process can take hours. Although that's true, I could have done more >> to test _some_ operations working among various regions.) >> >> On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray wrote: >>> >>> Greetings. >>> >>> I'm trying to use the aws/glacier package, and running into a problem where I'm being told: >>> >>> Credential should be scoped to a valid region, not 'eu-west-1' >>> >>> I'm following the instructions at >>> >>> My test code is: >>> >>> % cat glacier.rkt >>> #lang racket/base >>> >>> (require aws/glacier >>> aws/keys) >>> >>> (define vault "testvault") >>> (region "eu-west-1") >>> (read-keys "aws-zbu-credentials") ; local file >>> >>> (module+ main >>> (printf "region=~a~%" (region)) >>> (printf "Vaults: ~s~%" (list-vaults)) >>> (printf "...specifically: ~s~%" (describe-vault vault))) >>> >>> Running this produces: >>> >>> % racket glacier.rkt >>> region=eu-west-1 >>> aws: HTTP/1.1 403 Forbidden >>> x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 >>> Content-Type: application/json >>> Content-Length: 129 >>> Date: Sat, 27 Sep 2014 18:35:50 GMT >>> >>> {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} >>> HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " >>> context...: >>> check-response >>> /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 >>> request/redirect/uri >>> (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] >>> >>> Things I thought of: >>> >>> * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. >>> * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. >>> * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com >>> * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. >>> * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. >>> * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. >>> >>> If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. >>> >>> I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? >>> >>> Thanks for any pointers. >>> >>> All the best, >>> >>> Norman >>> >>> >>> -- >>> Norman Gray : http://nxg.me.uk >>> SUPA School of Physics and Astronomy, University of Glasgow, UK >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users > > > > End of users Digest, Vol 109, Issue 70 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:42:09 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:42:09 -0400 Subject: [racket] users Digest, Vol 109, Issue 69 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 2:08 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > 2. Help debugging a ffi crash (Eric Dobson) > 3. Re: [GENERAL] Off Topic: Anybody reading this via > news.gmane.org? (Adrian Klaver) > 4. Re: Help debugging a ffi crash (Matthew Flatt) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Sep 2014 13:37:30 -0400 > From: "Alexander D. Knauth" > To: Spencer florence > Cc: racket users list , Sam Tobin-Hochstadt > > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > Content-Type: text/plain; charset="utf-8" > > No because I want the unit to be a struct that has a dimension field, not a symbol with various dimensions defined as unions of units. > I want the unit to be based on the dimension, not the other way around, so that new units can be made that have the same dimension. > > I have something like the number+unit struct (I called it measure), but I?ll work on more that after I have the unit struct figured out. > > On Sep 28, 2014, at 12:13 PM, Spencer florence wrote: > >> would something like this work? >> >> #lang typed/racket >> >> (struct (U) number+unit ([amount : Real] [unit : U])) >> >> (define-type Weight-Unit (U 'kg 'g 'mg '?g)) >> (define-type Weight (number+unit Weight-Unit)) >> (define-predicate weight? Weight) >> >> (: make-weight : Real Weight-Unit -> Weight) >> (define (make-weight n u) >> (number+unit n u)) >> >> (: +/weight : Weight Weight -> Weight) >> ;; something something needs unit conversion >> (define (+/weight w1 w2) >> (number+unit (+ (number+unit-amount w1) >> (number+unit-amount w1)) >> (number+unit-unit w1))) >> >> (+/weight (make-weight 1 'kg) (make-weight 1 'kg)) >> >> >> >> On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth wrote: >> >> Because the struct is representing a unit (kilograms, meters, seconds, etc.), and a unit has a dimension (mass, length, time, etc.) and I want the type-checker to be able to know what the dimension of a unit is so that the types of functions can specify the dimension that something should have. >> The real solution to this would probably be bounded polymorphism, but I was wondering if there was some other way to do it with occurrence typing in the guard or something like that. >> >> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt wrote: >> >> > Why not do this with the type, instead of making this polymorphic? >> > >> > Sam >> > >> > On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth >> > wrote: >> >> Is it possible to have a struct that does certain things according to the >> >> guard? >> >> #lang typed/racket >> >> >> >> (struct (a) foo ([a : a]) #:transparent >> >> #:guard (lambda (a _) >> >> (unless (exact-integer? a) >> >> (error 'foo "expected Integer, given ~v" a)) >> >> a)) >> >> >> >> (ann (foo (ann 1 Any)) (foo Integer)) >> >> >> >> (: x : (foo Any)) >> >> (define x (foo 1)) >> >> >> >> (ann (foo-a x) Integer) >> >> >> >> ;. Type Checker: Polymorphic function `foo1' could not be applied to >> >> arguments: >> >> ;Argument 1: >> >> ; Expected: a >> >> ; Given: Any >> >> ; >> >> ;Result type: (foo a) >> >> ;Expected result: (foo Integer) >> >> ; in: (foo (ann 1 Any)) >> >> ;. Type Checker: Polymorphic function `foo-a' could not be applied to >> >> arguments: >> >> ;Argument 1: >> >> ; Expected: (foo a) >> >> ; Given: (foo Any) >> >> ; >> >> ;Result type: (a : ....) >> >> ;Expected result: Integer >> >> ; in: (foo-a x) >> >> >> >> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth >> >> wrote: >> >> >> >> What I?m trying to accomplish is something more like this: >> >> #lang typed/racket >> >> >> >> (require "dimensions.rkt") >> >> >> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) >> >> #:transparent >> >> #:guard (lambda (name scalar dimension _) >> >> (unless (dimension? dimension) >> >> (error 'unit "expected Dimension, given ~v" dimension)) >> >> (values name scalar dimension))) >> >> >> >> (define-type (Unitof d) (unit d)) >> >> >> >> (define-type Unit (Unitof Dimension)) >> >> >> >> (define Unit? (make-predicate Unit)) >> >> >> >> (define-type Unitish >> >> (U (Unitof Any) >> >> Dimension >> >> Positive-Real)) >> >> >> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >> >> [Unitish -> Unit]))) >> >> (define (->unit u) >> >> (cond [(unit? u) >> >> (unless (Unit? u) ; this should never happen anyway because of the >> >> guard >> >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >> >> u] >> >> [(dimension? u) (unit u 1 u)] >> >> [(positive-real? u) (unit u u dimensionless-dimension)])) >> >> >> >> >> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt >> >> wrote: >> >> >> >> No, I don't think you can do this. Can you say more about what you're >> >> trying to accomplish? >> >> >> >> Sam >> >> >> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >> >> wrote: >> >> >> >> Do any of you have any advice for getting a function like this to >> >> type-check? >> >> #lang typed/racket >> >> >> >> (: check-int : (All (a) (case-> [a -> a] >> >> [Any -> Integer]))) >> >> (define (check-int int) >> >> (unless (exact-integer? int) >> >> (error 'check-int "expected Integer, given ~v" int)) >> >> int) >> >> >> >> ;. Type Checker: type mismatch >> >> ; expected: a >> >> ; given: Integer in: int >> >> >> >> >> >> >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> >> >> >> >> >> ____________________ >> >> Racket Users list: >> >> http://lists.racket-lang.org/users >> >> >> >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Sun, 28 Sep 2014 10:48:06 -0700 > From: Eric Dobson > To: "users at racket-lang.org" > Subject: [racket] Help debugging a ffi crash > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I'm trying to debug an FFI crash that I'm seeing, and because it is > dealing with C code the error just presents as a segfault. I believe I > have tracked down what is causing the problem, but don't understand > how it could be doing so. > > I have two racket functions which take a "cursor" (the foreign > libraries object) and return a string representation of it, which I'm > trying to use for debugging. > > (define raw-clang-get-cstring > (get-ffi-obj "clang_getCString" lib-clang > (_fun _pointer -> _string))) > > (define raw-cursor-spelling > (get-ffi-obj "clang_getCursorSpelling" lib-clang > (_fun _CXCursor -> _pointer))) > > (define (cursor-spelling c) > (raw-clang-get-cstring (raw-cursor-spelling c))) > > (define cursor-spelling2 > (get-ffi-obj "clang_getCursorSpelling" lib-clang > (_fun _CXCursor -> (make-ctype _pointer values (? (v) > (raw-clang-get-cstring v)))))) > > If I use cursor-spelling, I have not been able to trigger a crash. But > if I use cursor-spelling2 I can reliably trigger a crash. > > Is there anything obvious on how these functions are different? > Because they look to me like they should be doing the same thing. If > it would be helpful I can try to get my code in a portable enough > shape so that it will work/crash on another machine. > > > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 17:25:15 -0700 > From: Adrian Klaver > To: George Neuner , neil at neilvandyke.org > Cc: "users at racket-lang.org >> users" > Subject: Re: [racket] [GENERAL] Off Topic: Anybody reading this via > news.gmane.org? > Message-ID: <5424B26B.9080504 at aklaver.com> > Content-Type: text/plain; charset=windows-1252; format=flowed > > On 09/25/2014 05:13 PM, George Neuner wrote: >> >> On 9/25/2014 5:26 PM, Neil Van Dyke wrote: >>> You can check your IP addr against the list at >>> "http://gmane.org/denied.php". >>> >>> Neil V. >> >> On 9/25/2014 7:08 PM, Adrian Klaver wrote: >>> >>> Take a look here: >>> >>> http://gmane.org/denied.php >>> >>> My guess is you are the fourth one from the bottom. >>> >>> >>> Might want to take a look at this thread to see what your options are >>> and what the turn around time is on your request: >>> >>> http://thread.gmane.org/gmane.discuss/16309 >> >> Thanks to both of you - I missed seeing the entry about the denied list >> in the FAQ. >> >> Adrian you were right - it seems that I have been blocked for some >> reason. Based on the description of infractions I really don't think I >> did anything to warrant it ... but there it is. I'll have to follow my >> lists by email until I can unblocked. > > I think the relevant part at gmane.org/denied.php is: > > "Since there is no way to identify users, news readers are denied on a > domain/IP basis. So if somebody on a machine close to you downloaded the > news spool yesterday, you're likely to be denied today" > >> >> Thanks again, >> George > > > -- > Adrian Klaver > adrian.klaver at aklaver.com > > > ------------------------------ > > Message: 4 > Date: Sun, 28 Sep 2014 12:08:23 -0600 > From: Matthew Flatt > To: Eric Dobson > Cc: "users at racket-lang.org" > Subject: Re: [racket] Help debugging a ffi crash > Message-ID: <20140928180825.80D74650196 at mail-svr1.cs.utah.edu> > Content-Type: text/plain; charset=UTF-8 > > Looking at > > http://clang.llvm.org/doxygen/CXString_8h_source.html > > it seems that CXString as returned by clang_getCursorSpelling() is not > a pointer: > > typedef struct { > const void *data; > unsigned private_flags; > } CXString; > > If that's right, I'm a little surprised that `cursor-spelling` works > --- but when you get representation wrong, strange things can happen, > including something working when it shouldn't. > > Am I looking at the right library/definitions? > > At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote: >> I'm trying to debug an FFI crash that I'm seeing, and because it is >> dealing with C code the error just presents as a segfault. I believe I >> have tracked down what is causing the problem, but don't understand >> how it could be doing so. >> >> I have two racket functions which take a "cursor" (the foreign >> libraries object) and return a string representation of it, which I'm >> trying to use for debugging. >> >> (define raw-clang-get-cstring >> (get-ffi-obj "clang_getCString" lib-clang >> (_fun _pointer -> _string))) >> >> (define raw-cursor-spelling >> (get-ffi-obj "clang_getCursorSpelling" lib-clang >> (_fun _CXCursor -> _pointer))) >> >> (define (cursor-spelling c) >> (raw-clang-get-cstring (raw-cursor-spelling c))) >> >> (define cursor-spelling2 >> (get-ffi-obj "clang_getCursorSpelling" lib-clang >> (_fun _CXCursor -> (make-ctype _pointer values (? (v) >> (raw-clang-get-cstring v)))))) >> >> If I use cursor-spelling, I have not been able to trigger a crash. But >> if I use cursor-spelling2 I can reliably trigger a crash. >> >> Is there anything obvious on how these functions are different? >> Because they look to me like they should be doing the same thing. If >> it would be helpful I can try to get my code in a portable enough >> shape so that it will work/crash on another machine. >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > End of users Digest, Vol 109, Issue 69 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:42:21 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:42:21 -0400 Subject: [racket] users Digest, Vol 109, Issue 65 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sat, Sep 27, 2014 at 9:11 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > 2. Re: proof assistants, DrRacket and Bootstrap (Prabhakar Ragde) > 3. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > 4. Re: problem with pict->bitmap and mrlib/write-animated-gif > (Martin DeMello) > 5. Re: proof assistants, DrRacket and Bootstrap (Prabhakar Ragde) > 6. Re: typed racket and generic interfaces, is there a > workaround using properties? (Anthony Carrico) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 27 Sep 2014 16:50:11 -0500 > From: Bill Richter > To: Prabhakar Ragde > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409272150.s8RLoBQW030663 at poisson.math.northwestern.edu> > > Thanks, Prabhakar, this is exactly what I wanted, and you know something about it (I was barely able to install Coq): > > I am teaching a grad course using Coq right now, and using Proof > General within Emacs for it. That is not bad, but I would love to > have a DrRacket interface. > > > OCaml doesn't have a quote feature, so the question arises how to > > write an OCaml interpreter inside OCaml. > > In my senior undergraduate programming language course, I have them > write various interpreters and typecheckers in various languages, > including Racket, OCaml, and Haskell. > [...] > > I know this is way off-topic, but it seems to me that Schemers are the only people who want an elegant solution here: > > But parsing an expression written in faux OCaml/Haskell is quite > complicated. [...] Parsing is much easier in Racket/Scheme because > of the similarity of code/data and the presence of 'read'. > > I think it's a parsing question I'm stuck on. I think I need to use camlp to avoid the following hack/kludge which I learned from the HOL Light experts, found in my file > hol_light/RichterHilbertAxiomGeometry/readable.ml > which is part of the HOL Light distribution: > > (* From update_database.ml: Execute any OCaml expression given as a string. *) > > let exec = ignore o Toploop.execute_phrase false Format.std_formatter > o !Toploop.parse_toplevel_phrase o Lexing.from_string;; > > (* Following miz3.ml, exec_thm returns the theorem representing a string, so *) > (* exec_thm "FORALL_PAIR_THM";; returns *) > (* val it : thm = |- !P. (!p. P p) <=> (!p1 p2. P (p1,p2)) *) > > let thm_ref = ref TRUTH;; > > let exec_thm s = > if Str.string_match (Str.regexp "[^;]*;") s 0 then raise Noparse > else > try exec ("thm_ref := (("^ s ^"): thm);;"); > !thm_ref > with _ -> raise Noparse;; > > When I posted my question on the OCaml list, the experts said don't ever use Obj.magic, but I think they didn't think much of me using Toploop either. > > -- > Best, > Bill > > > ------------------------------ > > Message: 2 > Date: Sat, 27 Sep 2014 18:00:24 -0400 > From: Prabhakar Ragde > To: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: <54273378.1070605 at uwaterloo.ca> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Bill Richter wrote: > >> >Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem >> >prover. >> >> Thanks, Ian! May I suggest that you try to handle Coq, Isabelle or >> HOL Light? I believe these are the foremost proof assistants. The >> fields medalist Vladimir Voevodsky uses Coq, in which the 4-color >> theorem and the Feit-Thompson theorem was formalized by Georges >> Gonthier. Tom Hales just finished formalizing his proof of Kepler >> conjecture in HOL Light and Isabelle (which is HOL as well). I'm no >> expert, but I think that ACL2 (also Prover9) is an FOL prover, and >> the bulk of activity in formal proofs uses type theories. HOL is >> simple, it's Church's simple types (a version of the Lambda >> Calculus), and Coq uses a much more complicated type theory. > > I'm sorry, I forgot about Carl's Dracula work when composing my earlier > reply. ACL2 is more limited, but its advantage (besides being probably > far and away the theorem prover that has had the most industrial impact) > is that its language (Applicative Common Lisp, hence the acronym) is > much closer to Racket, allowing for stronger integration both with > DrRacket and into a Racket-based curriculum. A DrRacket interface to Coq > or Isabelle would, in contrast, be more superficial, in the style of > Proof General. --PR > > > ------------------------------ > > Message: 3 > Date: Sat, 27 Sep 2014 17:26:44 -0500 > From: Bill Richter > To: Prabhakar Ragde > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409272226.s8RMQiEM030897 at poisson.math.northwestern.edu> > > ACL2 [is] probably far and away the theorem prover that has had the > most industrial impact > > Interesting, Prabhakar! I had not heard that before. > > A DrRacket interface to Coq or Isabelle would, in contrast, be more > superficial, in the style of Proof General. > > I think so, but interfaces are really important, and DrRacket has a beautiful interface. > > -- > Best, > Bill > > > ------------------------------ > > Message: 4 > Date: Sat, 27 Sep 2014 15:46:25 -0700 > From: Martin DeMello > To: Racket Users List > Subject: Re: [racket] problem with pict->bitmap and > mrlib/write-animated-gif > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Solved, with help from Jens Soegaard; I had to modify mrlib/write-gifs to > take a disposal argument, and use it in all calls to gif-add-control. > > martin > > On Sat, Sep 27, 2014 at 12:27 AM, Martin DeMello > wrote: > >> Can't figure it out, but something in the interaction between pict->bitmap >> and write-animated-gif is causing the frames to display one on top of the >> other when viewing the gif. >> >> #lang racket >> >> (require pict >> mrlib/gif) >> >> (define (draw-frame i) >> (pict->bitmap (circle (* 50 i)))) >> >> (write-animated-gif >> (map draw-frame (sequence->list (in-range 1 10))) >> 10 >> "test1.gif" >> #:loop? true >> #:one-at-a-time? true) >> >> martin >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 5 > Date: Sat, 27 Sep 2014 18:54:56 -0400 > From: Prabhakar Ragde > To: Bill Richter > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: <54274040.5070902 at uwaterloo.ca> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 2014-09-27, 5:50 PM, Bill Richter wrote: >> Thanks, Prabhakar, this is exactly what I wanted, and you know something about it (I was barely able to install Coq): > > I struggled with installing it also, especially since I'm using a Mac. > Racket has spoiled us in that respect. > >> But parsing an expression written in faux OCaml/Haskell is quite >> complicated. [...] Parsing is much easier in Racket/Scheme because >> of the similarity of code/data and the presence of 'read'. >> >> I think it's a parsing question I'm stuck on. I think I need to use camlp to avoid the following hack/kludge which I learned from the HOL Light experts, found in my file >> hol_light/RichterHilbertAxiomGeometry/readable.ml >> which is part of the HOL Light distribution: >> >> (* From update_database.ml: Execute any OCaml expression given as a string. *) > > I don't have enough practice in OCaml to grasp what your code does (and, > yes, it is way off-topic), but I do know that about once every month or > two, someone posts to this list about using 'eval' in Racket, and they > are warned not to use it unless they really know what they are doing and > have a suitable application (which is rare). That warning probably is > doubled in a statically-typed language, in which 'eval' should not even > be possible without subverting the type system (I gather this is what > you are doing). Translating the gist of suggestions to such posters, I > would say: do you really need to execute *any* expression? If not, use > OCamllex and/or OCamlyacc (maybe Menhir, or a smaller and cleaner parser > combinator library) to write a parser for your language subset, and then > write an interpreter for the resulting ASTs. --PR > > > ------------------------------ > > Message: 6 > Date: Sat, 27 Sep 2014 21:11:08 -0400 > From: Anthony Carrico > To: "Alexander D. Knauth" > Cc: racket users list > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: <5427602C.5010101 at memebeam.org> > Content-Type: text/plain; charset="windows-1252" > > On 09/27/2014 09:49 AM, Alexander D. Knauth wrote: >> Like this, I think: (but for some reason it seems to print it 3 times?) >> #lang typed/racket >> >> (struct foo () #:transparent >> #:property prop:custom-write >> (lambda (this out mode) >> (displayln "whatever"))) >> >> (print (foo)) > > I didn't realize #:property was legal in typed struct. I guess there > should be a documentation update here: > http://docs.racket-lang.org/ts-reference/special-forms.html > > BTW change your program to use the given port: (displayln "whatever" > out) to avoid the double printing problem, although I'm not exactly sure > why it would have that effect. > > Thanks! > > -- > Anthony Carrico > > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: signature.asc > Type: application/pgp-signature > Size: 181 bytes > Desc: OpenPGP digital signature > URL: > > End of users Digest, Vol 109, Issue 65 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:42:32 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:42:32 -0400 Subject: [racket] users Digest, Vol 109, Issue 64 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sat, Sep 27, 2014 at 5:08 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket and generic interfaces, is there a > workaround using properties? (Alexander D. Knauth) > 2. Re: proof assistants, DrRacket and Bootstrap (J. Ian Johnson) > 3. aws/glacier: credential scope (Norman Gray) > 4. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 27 Sep 2014 13:55:12 -0400 > From: "Alexander D. Knauth" > To: Spencer florence > Cc: racket users list > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: <38E7C628-8FA0-4F07-ABAD-E271E2A66426 at knauth.org> > Content-Type: text/plain; charset="windows-1252" > > Actually using prop:dict works (I hadn?t found prop:dict yet when I first asked this) > #lang typed/racket > > (define-type Dict-Ref ([Dict Any] [Any] . ->* . Any)) > (define-type Dict-Set! (Dict Any Any . -> . Void)) > (define-type Dict-Set (Dict Any Any . -> . Dict)) > (define-type Dict-Remove! (Dict Any . -> . Void)) > (define-type Dict-Remove (Dict Any . -> . Dict)) > (define-type Dict-Iterate-First (Dict . -> . Any)) > (define-type Dict-Iterate-Next (Dict Any . -> . Any)) > (define-type Dict-Iterate-Key (Dict Any . -> . Any)) > (define-type Dict-Iterate-Value (Dict Any . -> . Any)) > (define-type Dict-Count (Dict . -> . Natural)) > > (require/typed racket/dict > [#:opaque Dict dict?] > [dict-ref Dict-Ref] > [dict-set! Dict-Set!] > [dict-set Dict-Set] > [dict-remove! Dict-Remove!] > [dict-remove Dict-Remove] > [dict-iterate-first Dict-Iterate-First] > [dict-iterate-next Dict-Iterate-Next] > [dict-iterate-key Dict-Iterate-Key] > [dict-iterate-value Dict-Iterate-Value] > [dict-count Dict-Count] > [prop:dict Struct-Type-Property]) > > (define (make-dict-prop #:dict-ref [dict-ref : Dict-Ref] > #:dict-set! [dict-set! : (U Dict-Set! #f) #f] > #:dict-set [dict-set : (U Dict-Set #f) #f] > #:dict-remove! [dict-remove! : (U Dict-Remove! #f) #f] > #:dict-remove [dict-remove : (U Dict-Remove #f) #f] > #:dict-count [dict-count : Dict-Count] > #:dict-iterate-first [dict-iterate-first : Dict-Iterate-First] > #:dict-iterate-next [dict-iterate-next : Dict-Iterate-Next] > #:dict-iterate-key [dict-iterate-key : Dict-Iterate-Key] > #:dict-iterate-value [dict-iterate-value : Dict-Iterate-Value]) > (vector-immutable dict-ref > dict-set! > dict-set > dict-remove! > dict-remove > dict-count > dict-iterate-first > dict-iterate-next > dict-iterate-key > dict-iterate-value)) > > (struct foo () #:transparent > #:property prop:dict > (make-dict-prop #:dict-ref (lambda (this key [failure #f]) "whatever") > #:dict-count (lambda (this) 0) > #:dict-iterate-first (lambda (this) #f) > #:dict-iterate-next (lambda (this pos) 0) > #:dict-iterate-key (lambda (this pos) pos) > #:dict-iterate-value (lambda (this pos) "whatever"))) > > (dict-ref (assert (foo) dict?) "idontkare") > > > On Sep 27, 2014, at 1:07 AM, Spencer florence wrote: > >> I don?t think you can. You would need define the struct in an untyped module then require it via require/typed. This is why dict?s don?t work in typed/racket either. >> >> >> >> On Sat, May 24, 2014 at 9:39 PM, Alexander D. Knauth wrote: >> >> Do generic interfaces work using structure type properties, and if they do, is there a way to use generic interfaces through properties so that I can do it in typed racket? >> >> Specifically I?m trying to use the gen:custom-write and gen:dict generic interfaces. I can use prop:custom-write for the first one, but I don?t know what to do for gen:dict. >> >> Otherwise I?ll just put it in an untyped submodule. >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> >> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Sat, 27 Sep 2014 16:09:09 -0400 (EDT) > From: "J. Ian Johnson" > To: Bill Richter > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: <28884853.169131411848549503.JavaMail.root at zimbra> > Content-Type: text/plain; charset=utf-8 > > To answer the first part of your email, yes. Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem prover. > -Ian > ----- Original Message ----- > From: Bill Richter > To: users at racket-lang.org > Sent: Sat, 27 Sep 2014 03:38:48 -0400 (EDT) > Subject: [racket] proof assistants, DrRacket and Bootstrap > > I have a few questions that might be off-topic. Are you interested in formal proofs? Have you considered adapting DrRacket to give an integrated editor for a proof assistant? The proof assistants Coq and Isabelle use jedit and ProofGeneral, which I think aren't nearly as nice as DrRacket. I actually use HOL Light, which nobody uses an integrated editor for. Here are the slides for a talk I gave at the Institut Henri Poincar? in the workshop ``Formalization of mathematics in proof assistants'' > http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf > > HOL Light and Coq are written in OCaml, a dialect of ML, which is therefore similar to Scheme, but it has one difference that I wonder if anyone here's knows how to deal with. Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. > > I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? > > -- > Best, > Bill > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > > > > ------------------------------ > > Message: 3 > Date: Sat, 27 Sep 2014 21:14:55 +0100 > From: Norman Gray > To: racket users list > Subject: [racket] aws/glacier: credential scope > Message-ID: <0CA916BA-DD1E-47E9-BFA1-7092EC3F17F5 at astro.gla.ac.uk> > Content-Type: text/plain; charset=us-ascii > > > Greetings. > > I'm trying to use the aws/glacier package, and running into a problem where I'm being told: > > Credential should be scoped to a valid region, not 'eu-west-1' > > I'm following the instructions at > > My test code is: > > % cat glacier.rkt > #lang racket/base > > (require aws/glacier > aws/keys) > > (define vault "testvault") > (region "eu-west-1") > (read-keys "aws-zbu-credentials") ; local file > > (module+ main > (printf "region=~a~%" (region)) > (printf "Vaults: ~s~%" (list-vaults)) > (printf "...specifically: ~s~%" (describe-vault vault))) > > Running this produces: > > % racket glacier.rkt > region=eu-west-1 > aws: HTTP/1.1 403 Forbidden > x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 > Content-Type: application/json > Content-Length: 129 > Date: Sat, 27 Sep 2014 18:35:50 GMT > > {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} > HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. " > context...: > check-response > /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 > request/redirect/uri > (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] > > Things I thought of: > > * Printing (public-key)/(private-key) indicates that the credentials are being read correctly. > * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message. > * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in and which does have a host at http://glacier.eu-west-1.amazonaws.com > * As far as I can see, credentials are _not_ scoped, but are all at us-east-1. > * says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region. > * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what. > > If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service. > > I don't see any other (region) equivalents for the other services supported by the package. Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration? > > Thanks for any pointers. > > All the best, > > Norman > > > -- > Norman Gray : http://nxg.me.uk > SUPA School of Physics and Astronomy, University of Glasgow, UK > > > > > ------------------------------ > > Message: 4 > Date: Sat, 27 Sep 2014 16:08:49 -0500 > From: Bill Richter > To: "J. Ian Johnson" > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409272108.s8RL8nqh030467 at poisson.math.northwestern.edu> > > Carl Eastlund developed Dracula for Rackety use of the ACL2 theorem prover. > > Thanks, Ian! May I suggest that you try to handle Coq, Isabelle or HOL Light? I believe these are the foremost proof assistants. The fields medalist Vladimir Voevodsky uses Coq, in which the 4-color theorem and the Feit-Thompson theorem was formalized by Georges Gonthier. Tom Hales just finished formalizing his proof of Kepler conjecture in HOL Light and Isabelle (which is HOL as well). I'm no expert, but I think that ACL2 (also Prover9) is an FOL prover, and the bulk of activity in formal proofs uses type theories. HOL is simple, it's Church's simple types (a version of the Lambda Calculus), and Coq uses a much more complicated type theory. > > -- > Best, > Bill > > > End of users Digest, Vol 109, Issue 64 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:42:42 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:42:42 -0400 Subject: [racket] users Digest, Vol 109, Issue 66 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sun, Sep 28, 2014 at 11:29 AM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket and generic interfaces, is there a > workaround using properties? (Sam Tobin-Hochstadt) > 2. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > 3. Re: proof assistants, DrRacket and Bootstrap (Matthias Felleisen) > 4. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > 5. (fourth RacketCon) videos (Asumu Takikawa) > 6. Re: proof assistants, DrRacket and Bootstrap (Prabhakar Ragde) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 27 Sep 2014 21:58:14 -0400 > From: Sam Tobin-Hochstadt > To: Anthony Carrico > Cc: racket users list > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > On Sat, Sep 27, 2014 at 9:11 PM, Anthony Carrico wrote: >> On 09/27/2014 09:49 AM, Alexander D. Knauth wrote: >>> Like this, I think: (but for some reason it seems to print it 3 times?) >>> #lang typed/racket >>> >>> (struct foo () #:transparent >>> #:property prop:custom-write >>> (lambda (this out mode) >>> (displayln "whatever"))) >>> >>> (print (foo)) >> >> I didn't realize #:property was legal in typed struct. I guess there >> should be a documentation update here: >> http://docs.racket-lang.org/ts-reference/special-forms.html > > No, instead we need to change typed racket to reject those programs. > However, that would break a bunch of code with no easy fix that relies > on getting away with this, so we'll probably have to wait till we have > a real story here. > >> BTW change your program to use the given port: (displayln "whatever" >> out) to avoid the double printing problem, although I'm not exactly sure >> why it would have that effect. > > It prints multiple times (to hidden output ports) to detect cycles > among other things. > > Sam > >> Thanks! >> >> -- >> Anthony Carrico >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > > > ------------------------------ > > Message: 2 > Date: Sat, 27 Sep 2014 23:57:12 -0500 > From: Bill Richter > To: Prabhakar Ragde > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409280457.s8S4vCrp000773 at poisson.math.northwestern.edu> > > Translating the gist of suggestions to such posters, I would say: > do you really need to execute *any* expression? If not, use > OCamllex and/or OCamlyacc (maybe Menhir, or a smaller and cleaner > parser combinator library) to write a parser for your language > subset, and then write an interpreter for the resulting ASTs. > > Thanks, Prabhakar! I think something like what you're saying is true. HOL Light is based on quite a lot of the OCaml parser camlp, and I've thought for a long time that I had to learn it myself. > > I don't have enough practice in OCaml to grasp what your code does > > I'm making a dialect ofHOL Light with different syntax by interpreting one of my programs as a string and then breaking the string up into the component pieces, but then I need this Toploop/exec hack to evaluate my variables. That sounds like the Scheme eval, and in Scheme you can solve that problem nicely with the quote feature. > > -- > Best, > Bill > > > ------------------------------ > > Message: 3 > Date: Sat, 27 Sep 2014 16:00:35 -0600 > From: Matthias Felleisen > To: Bill Richter > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > Content-Type: text/plain; charset=us-ascii > > > On Sep 27, 2014, at 1:38 AM, Bill Richter wrote: > >> Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. > > Decouple parsing from interpreting and your ML interpreter for ML won't look too different from your Lisp/Racket/Scheme interpreter for Lisp/Racket/Scheme. Indeed, almost everyone who does the latter actually does some form of decoupling usually. > > In general, > > (1) pick a representation for your chosen programming language that is tree-oriented, call it AST > (2) pick a representation for the values that your programs may return, call it VAL > (3) design a function > > interpreter : AST -> VAL > > (4) for a typed language, also design a function > > type_check : AST -> Boolean > > In ML, you might try > > type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast > type val = BASIC of int | FUNCTION of val -> val | ... > > >> I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? > > > 1. HtDP explains the above in a couple of sections. > > 2. HtDP is for college freshmen (roughly) and for high school students who have the patience to read. The occasional 7th and 8th grader work their way thru HtDP with adults who understand HtDP or learn to understand HtDP that way. The basic 7th grader will benefit from the material at bootstrap-world.org, which is what we use with many middle school students around the country. > > -- Matthias > > > > > > > > > ------------------------------ > > Message: 4 > Date: Sun, 28 Sep 2014 00:39:20 -0500 > From: Bill Richter > To: Matthias Felleisen > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409280539.s8S5dKcx001372 at poisson.math.northwestern.edu> > Content-Type: text/plain; charset=utf-8 > > type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast > type val = BASIC of int | FUNCTION of val -> val | ... > > Thanks, Matthias! I know this is way off topic, but I think it's the sort of thing only Schemers understand, and I think HOL Light would be a lot better off my problem got solved. There's a lot I didn't understand with your ML explanation. Is this written down somewhere? How to write a ML interpreter in ML using your type ideas? Are you saying I don't need camlp parsing? I would find that hard to believe. Formal proofs in HOL Light are really just OCaml programs where a lot of code has already been evaluated. Here's a simple Hilbert geometry program in my dialect: > > let ExistsPointOffLine = theorem `; > ?l. Line l ? ?Q. Q ? l > > proof > intro_TAC ?l, H1; > consider A B C such that > ?(A = B) ? ?(A = C) ? ?(B = C) ? ?Collinear A B C [Distinct] by fol I3; > assume (A ? l) ? (B ? l) ? (C ? l) [all_on] by fol ?; > Collinear A B C [] by fol H1 - Collinear_DEF; > fol - Distinct; > qed; > `;; > > I think I need the `;[...]` construct, which at present just turns my proof into a string without any backslash or newline problems, which is then passed to my function theorem. The usual HOL Light style is like this, using instead a function prove: > > let MULT_0 = prove > (`!m. m * 0 = 0`, > INDUCT_TAC THEN ASM_REWRITE_TAC[MULT; ADD_CLAUSES]);; > > Notice the related `[...]` construct, which I think sends the ordered pair off to heavy camlp parsing. > > Thanks for the 7th and 8th advice. I think my student is smart and hard-working, and I (finally!) learned how to program reading your book HtDP, so it sounds like you're saying that I should be able to teach it to my student. I went to bootstrap-world.org and, uh, maybe I didn't look hard enough, but I didn't find anything that looked juicy. > > -- > Best, > Bill > > > ------------------------------ > > Message: 5 > Date: Sun, 28 Sep 2014 11:17:15 -0400 > From: Asumu Takikawa > To: Racket Users > Subject: [racket] (fourth RacketCon) videos > Message-ID: <20140928151714.GH30398 at localhost> > Content-Type: text/plain; charset=us-ascii > > Hi all, > > The hi-res talk recordings for (fourth RacketCon) are now up on Youtube. > You can watch all of them via this playlist: > > https://www.youtube.com/playlist?list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2Gdh > > Let me know if you find any glitches. > > Cheers, > Asumu > > > ------------------------------ > > Message: 6 > Date: Sun, 28 Sep 2014 11:29:32 -0400 > From: Prabhakar Ragde > To: Bill Richter > Cc: users at racket-lang.org > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: <5428295C.5050006 at uwaterloo.ca> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 2014-09-28, 12:57 AM, Bill Richter wrote: > >> I'm making a dialect of HOL Light with different syntax by >> interpreting one of my programs as a string and then breaking the >> string up into the component pieces, but then I need this >> Toploop/exec hack to evaluate my variables. That sounds like the >> Scheme eval, and in Scheme you can solve that problem nicely with the >> quote feature. > > A Racketeer would probably tell you to use macros to define your > dialect, instead of using an eval hack. The corresponding tool for OCaml > is camlp4, and it sounds as if it would be worth your time to learn it > thoroughly. --PR > > > End of users Digest, Vol 109, Issue 66 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:42:52 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:42:52 -0400 Subject: [racket] users Digest, Vol 109, Issue 61 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Fri, Sep 26, 2014 at 11:08 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > 2. Re: ANN: DOS, Delimited-continuation-based Operating-system > Simulator (Jay McCarthy) > 3. Re: web server: module servlets (Jay McCarthy) > 4. Re: typed racket and generic interfaces, is there a > workaround using properties? (Anthony Carrico) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 26 Sep 2014 19:35:24 -0400 > From: "Alexander D. Knauth" > To: racket users list > Cc: Sam Tobin-Hochstadt > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352 at knauth.org> > Content-Type: text/plain; charset="windows-1252" > > Is it possible to have a struct that does certain things according to the guard? > #lang typed/racket > > (struct (a) foo ([a : a]) #:transparent > #:guard (lambda (a _) > (unless (exact-integer? a) > (error 'foo "expected Integer, given ~v" a)) > a)) > > (ann (foo (ann 1 Any)) (foo Integer)) > > (: x : (foo Any)) > (define x (foo 1)) > > (ann (foo-a x) Integer) > > ;. Type Checker: Polymorphic function `foo1' could not be applied to arguments: > ;Argument 1: > ; Expected: a > ; Given: Any > ; > ;Result type: (foo a) > ;Expected result: (foo Integer) > ; in: (foo (ann 1 Any)) > ;. Type Checker: Polymorphic function `foo-a' could not be applied to arguments: > ;Argument 1: > ; Expected: (foo a) > ; Given: (foo Any) > ; > ;Result type: (a : ....) > ;Expected result: Integer > ; in: (foo-a x) > > On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth wrote: > >> What I?m trying to accomplish is something more like this: >> #lang typed/racket >> >> (require "dimensions.rkt") >> >> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent >> #:guard (lambda (name scalar dimension _) >> (unless (dimension? dimension) >> (error 'unit "expected Dimension, given ~v" dimension)) >> (values name scalar dimension))) >> >> (define-type (Unitof d) (unit d)) >> >> (define-type Unit (Unitof Dimension)) >> >> (define Unit? (make-predicate Unit)) >> >> (define-type Unitish >> (U (Unitof Any) >> Dimension >> Positive-Real)) >> >> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] >> [Unitish -> Unit]))) >> (define (->unit u) >> (cond [(unit? u) >> (unless (Unit? u) ; this should never happen anyway because of the guard >> (error '->unit "expected (Unitof Dimension), given ~v" u)) >> u] >> [(dimension? u) (unit u 1 u)] >> [(positive-real? u) (unit u u dimensionless-dimension)])) >> >> >> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt wrote: >> >>> No, I don't think you can do this. Can you say more about what you're >>> trying to accomplish? >>> >>> Sam >>> >>> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >>> wrote: >>>> Do any of you have any advice for getting a function like this to >>>> type-check? >>>> #lang typed/racket >>>> >>>> (: check-int : (All (a) (case-> [a -> a] >>>> [Any -> Integer]))) >>>> (define (check-int int) >>>> (unless (exact-integer? int) >>>> (error 'check-int "expected Integer, given ~v" int)) >>>> int) >>>> >>>> ;. Type Checker: type mismatch >>>> ; expected: a >>>> ; given: Integer in: int >>>> >>>> >>>> >>>> ____________________ >>>> Racket Users list: >>>> http://lists.racket-lang.org/users >>>> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Fri, 26 Sep 2014 20:03:57 -0400 > From: Jay McCarthy > To: "Michael Bradley, Jr." > Cc: users > Subject: Re: [racket] ANN: DOS, Delimited-continuation-based > Operating-system Simulator > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Sure, I can make a post about it. However, the core idea is already in > this post: > > http://jeapostrophe.github.io/2012-07-12-cont-sys-post.html > > I can make another one, however, to rehash it and talk about the > benefits of monoid states. > > Jay > > On Fri, Sep 26, 2014 at 2:15 PM, Michael Bradley, Jr. > wrote: >> Jay McCarthy writes: >> >>> >>> I've just released the game architecture library I talked about in >>> part 2 of my RacketCon talk. >>> >>> The big picture of this library is to make World-style programs more >>> compositional by (a) using continuations to hide the internal state >>> (including control state) of components and (b) using environments as >>> a standard monoid-based inter-component communication channel. A >>> monoid is used to ensure that the components can be evaluated in any >>> order. Despite assumptions some have about continuations and pure >>> functional programming, it is incredibly efficient and can run at >>> 60FPS, as demonstrated in get-bonus. >>> >>> You can get it with >>> >>> raco pkg install dos >>> >>> And you can try out the demo with >>> >>> racket -l dos/examples/win >>> >>> The demo source is a bare 39 lines: >>> >>> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt >>> >>> and I provide the non-DOS version for comparison: >>> >>> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt >>> >>> The core library has a mere 36 lines: >>> >>> https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt >>> >> >> >> >> Hi Jay, >> >> I really enjoyed your talk on get-bonus at RacketCon last weekend, and >> appreciate your sharing DOS with all of us. Also, your presentation at >> Strange Loop 2013 was my first introduction to delimited continuations in >> Racket! >> >> I have benefited from a number of your blog posts in the past, e.g. the one >> on an improved threading macro, and was wondering if you would consider >> doing a write-up on DOS? >> >> Best regards, >> >> -- >> Michael Bradley, Jr. >> @michaelsbradley >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > -- > Jay McCarthy > 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&C 64:33 > > > ------------------------------ > > Message: 3 > Date: Fri, 26 Sep 2014 20:08:30 -0400 > From: Jay McCarthy > To: George Neuner > Cc: users > Subject: Re: [racket] web server: module servlets > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > Hi George, > > I suggest that all Racket web-server apps not use the dynamic features > of serve/servlet either, but instead write the servlet as the single > "request -> response" function that serve/servlet provides. This would > ensure that all the libraries are loaded the one time and has the best > performance out of all the options of the Web server. Furthermore, > there are many features (such as total URL control) that are only > available in this model. > > In case it is not completely clear, here's a little example (<500 > lines) of a Web application that works this way: > > https://github.com/plt/racket/blob/master/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt#L423 > > Here's another that uses 'serve' directly for non-servlet needs: > > https://github.com/jeapostrophe/exp/blob/master/dir-serve.rkt > > And here's a considerably longer one: > > https://github.com/jeapostrophe/grade-samurai/blob/master/app.rkt#L2020 > > I highly recommend using serve/servlet like this over any other > options. In particular, many of the problems you're talking about were > the reason that I made serve/servlet in the first place. > > Jay > > On Fri, Sep 26, 2014 at 12:16 AM, George Neuner wrote: >> On 9/25/2014 6:26 PM, Jay McCarthy wrote: >> >> web-server/servlet is NOT shared, nor is any net library or common >> racket library like racket/list. They are all totally unique per >> servlet. >> >> This, by the way, is part of why I don't recommend using dynamic >> servlets at all and suggest using serve/servlet. >> >> >> But ... IIUC ... a listener started by serve/servlet will still >> dynamically load from , /htdocs/*, etc. if the >> request doesn't match a hard coded dispatch URL - the regex of the initial >> servlet or an entry in a dispatcher table. At least that's the behavior I >> see with my own application: my initial servlet returns 404 when called - >> the call to serve/servlet just sets up the environment and and all the >> "real" servlets are demand loaded from disk when first touched. >> >> Are you advocating *static* linking and essentially just dispatching to >> internal functions by URL? ISTM that that defeats the purpose. >> >> George > > > > -- > Jay McCarthy > 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&C 64:33 > > > ------------------------------ > > Message: 4 > Date: Fri, 26 Sep 2014 23:07:55 -0400 > From: Anthony Carrico > To: users at racket-lang.org > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: <54262A0B.2010901 at memebeam.org> > Content-Type: text/plain; charset="windows-1252" > > Dredging up an old thread: So how exactly do you define custom-write for > a typed racket struct? > > On 05/25/2014 03:30 PM, Alexander D. Knauth wrote: >> Never mind I just found prop:dict. >> >> By the way it would probably be helpful if instead of the value for >> prop:dict being a vector, it was a hash table with the method names >> as the keys, so then it would be a lot easier to tell which procedure >> goes with which method, and also a lot easier to extend it while >> maintaining backwards compatibility. >> >> On May 24, 2014, at 10:38 PM, Alexander D. Knauth >> wrote: >> >>> Do generic interfaces work using structure type properties, and if >>> they do, is there a way to use generic interfaces through >>> properties so that I can do it in typed racket? >>> >>> Specifically I?m trying to use the gen:custom-write and gen:dict >>> generic interfaces. I can use prop:custom-write for the first one, >>> but I don?t know what to do for gen:dict. >>> >>> Otherwise I?ll just put it in an untyped submodule. > > -- > Anthony Carrico > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: signature.asc > Type: application/pgp-signature > Size: 181 bytes > Desc: OpenPGP digital signature > URL: > > End of users Digest, Vol 109, Issue 61 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:01 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:01 -0400 Subject: [racket] users Digest, Vol 109, Issue 63 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sat, Sep 27, 2014 at 12:00 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. proof assistants, DrRacket and Bootstrap (Prabhakar Ragde) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 27 Sep 2014 10:33:15 -0400 > From: Prabhakar Ragde > To: "users at racket-lang.org" > Subject: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: <5426CAAB.2010400 at uwaterloo.ca> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >> I have a few questions that might be off-topic. Are you interested >> in formal proofs? Have you considered adapting DrRacket to give an >> integrated editor for a proof assistant? The proof assistants Coq >> and Isabelle use jedit and ProofGeneral, which I think aren't nearly >> as nice as DrRacket. I actually use HOL Light, which nobody uses an >> integrated editor for. Here are the slides for a talk I gave at the >> Institut Henri Poincar? in the workshop ``Formalization of >> mathematics in proof assistants'' >> http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf > > I am teaching a grad course using Coq right now, and using Proof General > within Emacs for it. That is not bad, but I would love to have a > DrRacket interface. I know something like this is possible, because at > Brown they used DrRacket to prepare and run OCaml programs, a few years > ago. I really don't have the time to work on this, though. (And if I > did, I would first work on teaching language subsets of Haskell, which I > also would like to have inside DrRacket.) > >> HOL Light and Coq are written in OCaml, a dialect of ML, which is >> therefore similar to Scheme, but it has one difference that I wonder >> if anyone here's knows how to deal with. Scheme is well-suited for >> writing a Scheme interpreter, because of the quote feature. OCaml >> doesn't have a quote feature, so the question arises how to write an >> OCaml interpreter inside OCaml. That's not quite what I want to do, >> but if anyone could explain how to do it, I'd be grateful. > > In my senior undergraduate programming language course, I have them > write various interpreters and typecheckers in various languages, > including Racket, OCaml, and Haskell. In the latter two, you need to use > algebraic datatypes to build an abstract syntax tree, and interpret > that. So the expression (* (+ 1 2) (- 3 4)) might become > > (Mult (Plus (Num 1) (Num 2)) (Minus (Num 3) (Num 4))) > > Writing an interpreter for such an AST is even easier than in > Racket/Scheme, due to concise pattern-matching syntax. But parsing an > expression written in faux OCaml/Haskell is quite complicated. I don't > ask students to do that, since it really is part of a separate course > (both languages come with general parsing tools that can be used). > Parsing is much easier in Racket/Scheme because of the similarity of > code/data and the presence of 'read'. > >> I have a 7th grade student I'm trying to teach Racket, and I'm a bit >> confused about Bootstrap and Program By Design. Is there any reason >> for my student not to just read HtDP? > > You should view word from the authors/developers as definitive, but I > would say that if your student has good algebraic skills, then using > HtDP/2e is the right path. If not, Bootstrap may be a way to help > develop those skills. --PR > > > End of users Digest, Vol 109, Issue 63 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:12 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:12 -0400 Subject: [racket] users Digest, Vol 109, Issue 60 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Fri, Sep 26, 2014 at 2:20 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Tricky case of occurrence typing in Typed Racket (Konrad Hinsen) > 2. Re: Tricky case of occurrence typing in Typed Racket (Andrew Kent) > 3. Re: Tricky case of occurrence typing in Typed Racket > (Konrad Hinsen) > 4. Re: Tricky case of occurrence typing in Typed Racket (Andrew Kent) > 5. Re: ANN: DOS, Delimited-continuation-based Operating-system > Simulator (Michael Bradley, Jr.) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 26 Sep 2014 18:07:19 +0200 > From: Konrad Hinsen > To: users at racket-lang.org > Subject: [racket] Tricky case of occurrence typing in Typed Racket > Message-ID: > <21541.36663.168649.25871 at Konrad-Hinsens-MacBook-Pro-2.local> > Content-Type: text/plain; charset=us-ascii > > Hi everyone, > > I am trying to convince Typed Racket that after a run-time check on > some list, its elements are all of a given type. This is just like > occurrence typing based on a predicate, except that my predicate > is more complicated. > > My first attempt was this: > > > #lang typed/racket > > (struct: foo ()) > (struct: bar ()) > (define-type FooOrBar (U foo bar)) > > (: f-bar (-> (Listof bar) Void)) > (define (f-bar xs) > (void)) > > (: f-mixed (-> (Listof FooOrBar) Void)) > (define (f-mixed xs) > (void)) > > (: f (-> (Listof FooOrBar) Void)) > (define (f xs) > (if (for/and : Boolean ([x xs]) (bar? x)) > (f-bar xs) ; contains only bars > (f-mixed xs) ; may contain foos as well > )) > > This yields a type error: > > ; /Users/hinsen/projects/racket/foobar.rkt:18:13: Type Checker: type mismatch > ; expected: (Listof bar) > ; given: (Listof FooOrBar) > ; in: xs > > After reading section 5 of the Typed Racket Guide, in particular section > 5.2 entitled "Filters and Predicates", I thought I could simply define my > own predicate with a type annotation: > > #lang typed/racket > > (struct: foo ()) > (struct: bar ()) > (define-type FooOrBar (U foo bar)) > > (: f-bar (-> (Listof bar) Void)) > (define (f-bar xs) > (void)) > > (: f-mixed (-> (Listof FooOrBar) Void)) > (define (f-mixed xs) > (void)) > > (: pure-bars? (-> (Listof FooOrBar) Boolean : (Listof bar))) > (define (pure-bars? xs) > (for/and : Boolean ([x xs]) (bar? x))) > > (: f (-> (Listof FooOrBar) Void)) > (define (f xs) > (if (pure-bars? xs) > (f-bar xs) ; contains only bars > (f-mixed xs) ; may contain foos as well > )) > > But this got me only into more trouble - now I don't even understand the > error message any more: > > ; /Users/hinsen/projects/racket/foobar.rkt:17:2: Type Checker: type mismatch; > ; mismatch in filter > ; expected: (((Listof bar) @ xs) | (! (Listof bar) @ xs)) > ; given: (Top | Top) > ; in: (for/and : Boolean ((x xs)) (bar? x)) > > Is there a way to do this kind of test? > > Konrad. > > > ------------------------------ > > Message: 2 > Date: Fri, 26 Sep 2014 12:12:29 -0400 > From: Andrew Kent > To: Konrad Hinsen > Cc: users at racket-lang.org > Subject: Re: [racket] Tricky case of occurrence typing in Typed Racket > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Will andmap work for you? > > (struct: foo ()) > (struct: bar ()) > (define-type FooOrBar (U foo bar)) > > (: f-bar (-> (Listof bar) Void)) > (define (f-bar xs) > (void)) > > (: f-mixed (-> (Listof FooOrBar) Void)) > (define (f-mixed xs) > (void)) > > (: f (-> (Listof FooOrBar) Void)) > (define (f xs) > (if (andmap bar? xs) > (f-bar xs) ; contains only bars > (f-mixed xs) ; may contain foos as well > )) > > On Fri, Sep 26, 2014 at 12:07 PM, Konrad Hinsen > wrote: > >> Hi everyone, >> >> I am trying to convince Typed Racket that after a run-time check on >> some list, its elements are all of a given type. This is just like >> occurrence typing based on a predicate, except that my predicate >> is more complicated. >> >> My first attempt was this: >> >> >> #lang typed/racket >> >> (struct: foo ()) >> (struct: bar ()) >> (define-type FooOrBar (U foo bar)) >> >> (: f-bar (-> (Listof bar) Void)) >> (define (f-bar xs) >> (void)) >> >> (: f-mixed (-> (Listof FooOrBar) Void)) >> (define (f-mixed xs) >> (void)) >> >> (: f (-> (Listof FooOrBar) Void)) >> (define (f xs) >> (if (for/and : Boolean ([x xs]) (bar? x)) >> (f-bar xs) ; contains only bars >> (f-mixed xs) ; may contain foos as well >> )) >> >> This yields a type error: >> >> ; /Users/hinsen/projects/racket/foobar.rkt:18:13: Type Checker: type >> mismatch >> ; expected: (Listof bar) >> ; given: (Listof FooOrBar) >> ; in: xs >> >> After reading section 5 of the Typed Racket Guide, in particular section >> 5.2 entitled "Filters and Predicates", I thought I could simply define my >> own predicate with a type annotation: >> >> #lang typed/racket >> >> (struct: foo ()) >> (struct: bar ()) >> (define-type FooOrBar (U foo bar)) >> >> (: f-bar (-> (Listof bar) Void)) >> (define (f-bar xs) >> (void)) >> >> (: f-mixed (-> (Listof FooOrBar) Void)) >> (define (f-mixed xs) >> (void)) >> >> (: pure-bars? (-> (Listof FooOrBar) Boolean : (Listof bar))) >> (define (pure-bars? xs) >> (for/and : Boolean ([x xs]) (bar? x))) >> >> (: f (-> (Listof FooOrBar) Void)) >> (define (f xs) >> (if (pure-bars? xs) >> (f-bar xs) ; contains only bars >> (f-mixed xs) ; may contain foos as well >> )) >> >> But this got me only into more trouble - now I don't even understand the >> error message any more: >> >> ; /Users/hinsen/projects/racket/foobar.rkt:17:2: Type Checker: type >> mismatch; >> ; mismatch in filter >> ; expected: (((Listof bar) @ xs) | (! (Listof bar) @ xs)) >> ; given: (Top | Top) >> ; in: (for/and : Boolean ((x xs)) (bar? x)) >> >> Is there a way to do this kind of test? >> >> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 3 > Date: Fri, 26 Sep 2014 18:28:03 +0200 > From: Konrad Hinsen > To: users at racket-lang.org > Subject: Re: [racket] Tricky case of occurrence typing in Typed Racket > Message-ID: > <21541.37907.627925.114871 at Konrad-Hinsens-MacBook-Pro-2.local> > Content-Type: text/plain; charset=us-ascii > > Andrew Kent writes: > > > Will andmap work for you? > > Interesting... I didn't know about that one. > > For my demonstration code, that's indeed a good solution. In my real > application, the test is more complicated. I need to check all > elements of a list for conformance to a union type, so I have no > prefabricated predicate, not even for the elements of my list. > > Konrad. > > > ------------------------------ > > Message: 4 > Date: Fri, 26 Sep 2014 12:48:05 -0400 > From: Andrew Kent > To: Konrad Hinsen > Cc: users at racket-lang.org > Subject: Re: [racket] Tricky case of occurrence typing in Typed Racket > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Does using andmap with the custom predicates you alluded to for that union > you mentioned work? > > Something like this perhaps?: > > #lang typed/racket > > (struct: T1 ()) > (struct: T2 ()) > (define-type T1or2 (U T1 T2)) > > (: T1or2? (-> Any Boolean : T1or2)) > (define (T1or2? a) > (or (T1? a) (T2? a))) > > > (: listof-T1or2 (-> Any Boolean : (Listof T1or2))) > (define (listof-T1or2 l) > (and (list? l) (andmap T1or2? l))) > > > > On Fri, Sep 26, 2014 at 12:28 PM, Konrad Hinsen > wrote: > >> Andrew Kent writes: >> >> > Will andmap work for you? >> >> Interesting... I didn't know about that one. >> >> For my demonstration code, that's indeed a good solution. In my real >> application, the test is more complicated. I need to check all >> elements of a list for conformance to a union type, so I have no >> prefabricated predicate, not even for the elements of my list. >> >> Konrad. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 5 > Date: Fri, 26 Sep 2014 18:15:31 +0000 (UTC) > From: "Michael Bradley, Jr." > To: users at racket-lang.org > Subject: Re: [racket] ANN: DOS, Delimited-continuation-based > Operating-system Simulator > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Jay McCarthy writes: > >> >> I've just released the game architecture library I talked about in >> part 2 of my RacketCon talk. >> >> The big picture of this library is to make World-style programs more >> compositional by (a) using continuations to hide the internal state >> (including control state) of components and (b) using environments as >> a standard monoid-based inter-component communication channel. A >> monoid is used to ensure that the components can be evaluated in any >> order. Despite assumptions some have about continuations and pure >> functional programming, it is incredibly efficient and can run at >> 60FPS, as demonstrated in get-bonus. >> >> You can get it with >> >> raco pkg install dos >> >> And you can try out the demo with >> >> racket -l dos/examples/win >> >> The demo source is a bare 39 lines: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt >> >> and I provide the non-DOS version for comparison: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt >> >> The core library has a mere 36 lines: >> >> https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt >> > > > > Hi Jay, > > I really enjoyed your talk on get-bonus at RacketCon last weekend, and > appreciate your sharing DOS with all of us. Also, your presentation at > Strange Loop 2013 was my first introduction to delimited continuations in > Racket! > > I have benefited from a number of your blog posts in the past, e.g. the one > on an improved threading macro, and was wondering if you would consider > doing a write-up on DOS? > > Best regards, > > -- > Michael Bradley, Jr. > @michaelsbradley > > > > > End of users Digest, Vol 109, Issue 60 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:22 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:22 -0400 Subject: [racket] users Digest, Vol 109, Issue 62 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Sat, Sep 27, 2014 at 9:50 AM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. "do what i mean" for https://github links (Martin DeMello) > 2. Re: typed racket and generic interfaces, is there a > workaround using properties? (Spencer florence) > 3. problem with pict->bitmap and mrlib/write-animated-gif > (Martin DeMello) > 4. proof assistants, DrRacket and Bootstrap (Bill Richter) > 5. Fwd: JFP CFP (Robby Findler) > 6. Re: typed racket and generic interfaces, is there a > workaround using properties? (Alexander D. Knauth) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 26 Sep 2014 21:56:52 -0700 > From: Martin DeMello > To: Racket Users List > Subject: [racket] "do what i mean" for https://github links > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > It took me a while of reading through the docs to figure out why trying to > install a package via "https://github.com/user/pkg" failed for want of a > MANIFEST file. I think the "do what I mean" installer should have > autoconverted it to git:// , seeing as how github is already special-cased. > > (Also my first try of installing via the git clone url > https://github.com/user/pkg.git should ideally have been supported too, > since that's what github encourages you to copy/paste as a reference) > > martin > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Fri, 26 Sep 2014 22:07:43 -0700 (PDT) > From: "Spencer florence" > To: "Alexander D. Knauth" > Cc: Racket Users > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: <1411794462639.6720ba81 at Nodemailer> > Content-Type: text/plain; charset="utf-8" > > I don?t think you can. You would need define the struct in an untyped module then require it via require/typed. This is why dict?s don?t work in typed/racket either. > > On Sat, May 24, 2014 at 9:39 PM, Alexander D. Knauth > wrote: > >> Do generic interfaces work using structure type properties, and if they do, is there a way to use generic interfaces through properties so that I can do it in typed racket? >> Specifically I?m trying to use the gen:custom-write and gen:dict generic interfaces. I can use prop:custom-write for the first one, but I don?t know what to do for gen:dict. >> Otherwise I?ll just put it in an untyped submodule. >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 3 > Date: Sat, 27 Sep 2014 00:27:29 -0700 > From: Martin DeMello > To: Racket Users List > Subject: [racket] problem with pict->bitmap and > mrlib/write-animated-gif > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Can't figure it out, but something in the interaction between pict->bitmap > and write-animated-gif is causing the frames to display one on top of the > other when viewing the gif. > > #lang racket > > (require pict > mrlib/gif) > > (define (draw-frame i) > (pict->bitmap (circle (* 50 i)))) > > (write-animated-gif > (map draw-frame (sequence->list (in-range 1 10))) > 10 > "test1.gif" > #:loop? true > #:one-at-a-time? true) > > martin > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 4 > Date: Sat, 27 Sep 2014 02:38:48 -0500 > From: Bill Richter > To: users at racket-lang.org > Subject: [racket] proof assistants, DrRacket and Bootstrap > Message-ID: > <201409270738.s8R7cmcd022184 at poisson.math.northwestern.edu> > Content-Type: text/plain; charset=utf-8 > > I have a few questions that might be off-topic. Are you interested in formal proofs? Have you considered adapting DrRacket to give an integrated editor for a proof assistant? The proof assistants Coq and Isabelle use jedit and ProofGeneral, which I think aren't nearly as nice as DrRacket. I actually use HOL Light, which nobody uses an integrated editor for. Here are the slides for a talk I gave at the Institut Henri Poincar? in the workshop ``Formalization of mathematics in proof assistants'' > http://www.math.northwestern.edu/~richter/RichterIHPslide.pdf > > HOL Light and Coq are written in OCaml, a dialect of ML, which is therefore similar to Scheme, but it has one difference that I wonder if anyone here's knows how to deal with. Scheme is well-suited for writing a Scheme interpreter, because of the quote feature. OCaml doesn't have a quote feature, so the question arises how to write an OCaml interpreter inside OCaml. That's not quite what I want to do, but if anyone could explain how to do it, I'd be grateful. > > I have a 7th grade student I'm trying to teach Racket, and I'm a bit confused about Bootstrap and Program By Design. Is there any reason for my student not to just read HtDP? > > -- > Best, > Bill > > > ------------------------------ > > Message: 5 > Date: Sat, 27 Sep 2014 07:38:54 -0500 > From: Robby Findler > To: Racket Users > Subject: [racket] Fwd: JFP CFP > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > If you're working on parallel or concurrent programming, consider submitting! > > Robby > > > ------------------------------------------------------------------------------ > CALL FOR PAPERS > > JFP Special Issue > on > Parallel and Concurrent Programming > > Submission Deadline: 22 December 2014 > Expected Publication Date: November/December issue 2015 > > > * Scope > > Functional languages are uniquely suited to provide programmers with a > programming model for parallel and concurrent computing. This is reflected in > the wide range of work that is currently underway, both on parallel and > concurrent functional languages, but also on bringing functional language > features to other programming languages. This has resulted in a rapidly > growing number of practical applications. > > The Journal of Functional Programming will devote a special issue to > functional programming for concurrent and parallel computing. The purpose of > this special issue is to showcase the state of the art on how functional > languages and functional concepts currently assist programmers with the task > of managing the challenges of creating parallel and concurrent systems. > > Language designers as well as systems builders and application programmers are > invited to submit papers describing the current state of the art of language > support and experiences with functional programming in building real-world > systems. > > We encourage the submission of consolidated, condensed and extended work based > on prior conference and workshop publications. > > * Submission Details > > Manuscripts should be submitted to CUP's Manuscript Central formatted > according to JFP's standards. Authors should specify in their cover message > that the paper is intended for the special issue and choose the appropriate > desired editor from the menu. For submission and formatting details, please > consult the Journal of Functional Programming [ http://bit.ly/jfpadvice ] > website. > > > Guest Editors > --------------------------------------------------------------------------------- > Gabriele Keller Fritz Henglein > keller @cse.unsw.edu.au henglein at diku.dk > School of Computer Science & Engineering Department of Computer > Science (DIKU) > UNSW Sydney NSW 2052 University of Copenhagen > and Universitetsparken 5 > The Software Systems Research Group@ NICTA DK-2100 Copenhagen > Australia Denmark > --------------------------------------------------------------------------------- > > > ------------------------------ > > Message: 6 > Date: Sat, 27 Sep 2014 09:49:48 -0400 > From: "Alexander D. Knauth" > To: Anthony Carrico > Cc: racket users list > Subject: Re: [racket] typed racket and generic interfaces, is there a > workaround using properties? > Message-ID: <39AEBCAD-6138-4FE6-84A5-6AFF1A1A466C at knauth.org> > Content-Type: text/plain; charset=windows-1252 > > Like this, I think: (but for some reason it seems to print it 3 times?) > #lang typed/racket > > (struct foo () #:transparent > #:property prop:custom-write > (lambda (this out mode) > (displayln "whatever"))) > > (print (foo)) > > > On Sep 26, 2014, at 11:07 PM, Anthony Carrico wrote: > >> Dredging up an old thread: So how exactly do you define custom-write for >> a typed racket struct? >> >> On 05/25/2014 03:30 PM, Alexander D. Knauth wrote: >>> Never mind I just found prop:dict. >>> >>> By the way it would probably be helpful if instead of the value for >>> prop:dict being a vector, it was a hash table with the method names >>> as the keys, so then it would be a lot easier to tell which procedure >>> goes with which method, and also a lot easier to extend it while >>> maintaining backwards compatibility. >>> >>> On May 24, 2014, at 10:38 PM, Alexander D. Knauth >>> wrote: >>> >>>> Do generic interfaces work using structure type properties, and if >>>> they do, is there a way to use generic interfaces through >>>> properties so that I can do it in typed racket? >>>> >>>> Specifically I?m trying to use the gen:custom-write and gen:dict >>>> generic interfaces. I can use prop:custom-write for the first one, >>>> but I don?t know what to do for gen:dict. >>>> >>>> Otherwise I?ll just put it in an untyped submodule. >> >> -- >> Anthony Carrico >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > > End of users Digest, Vol 109, Issue 62 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:33 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:33 -0400 Subject: [racket] users Digest, Vol 109, Issue 59 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Fri, Sep 26, 2014 at 12:16 AM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Re: typed racket, filters, and polymorphism (Sam Tobin-Hochstadt) > 2. Re: web server: module servlets (Jay McCarthy) > 3. Re: [GENERAL] Off Topic: Anybody reading this via > news.gmane.org? (George Neuner) > 4. Re: typed racket, filters, and polymorphism (Alexander D. Knauth) > 5. Re: web server: module servlets (George Neuner) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 25 Sep 2014 18:19:37 -0400 > From: Sam Tobin-Hochstadt > To: "Alexander D. Knauth" > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > No, I don't think you can do this. Can you say more about what you're > trying to accomplish? > > Sam > > On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth > wrote: >> Do any of you have any advice for getting a function like this to >> type-check? >> #lang typed/racket >> >> (: check-int : (All (a) (case-> [a -> a] >> [Any -> Integer]))) >> (define (check-int int) >> (unless (exact-integer? int) >> (error 'check-int "expected Integer, given ~v" int)) >> int) >> >> ;. Type Checker: type mismatch >> ; expected: a >> ; given: Integer in: int >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > > > ------------------------------ > > Message: 2 > Date: Thu, 25 Sep 2014 18:26:58 -0400 > From: Jay McCarthy > To: George Neuner > Cc: users > Subject: Re: [racket] web server: module servlets > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > On Thu, Sep 25, 2014 at 4:34 PM, George Neuner wrote: >> Hi Jay, >> >> On 9/25/2014 1:04 PM, Jay McCarthy wrote: >> >>> If a Racket library is deliberately put into the servlet-namespace, does >>> that streamline linking? >> >> Your assumption about the purpose of this is not correct. Anything in >> the servlet-namespace will be shared between all servlets, and thus >> not loaded per-servlet. >> >> >> I think you misunderstood my question, but you may have answered it anyway. >> >> What I really was asking was whether each custodian was having to >> individually load common Racket libraries [ web-server/*, net/*, etc. ] for >> a new servlet rather than all servlet custodians sharing libraries that are >> already loaded. Or, if not actually "loading" the libraries, then having to >> go to disk to check dependencies. >> >> So if I create a shared servlet namespace and put, e.g., >> "web-server/servlet" into it, would that in any way speed up starting a new >> dynamically loaded servlet? > > There is a very small set that is automatically shared: > racket/base > web-server/private/servlet > web-server/http > web-server/servlet/web > ... > > web-server/servlet is NOT shared, nor is any net library or common > racket library like racket/list. They are all totally unique per > servlet. > > This, by the way, is part of why I don't recommend using dynamic > servlets at all and suggest using serve/servlet. > > Jay > > > > -- > Jay McCarthy > 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&C 64:33 > > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 20:13:54 -0400 > From: George Neuner > To: Adrian Klaver , neil at neilvandyke.org > Cc: "users at racket-lang.org >> users" > Subject: Re: [racket] [GENERAL] Off Topic: Anybody reading this via > news.gmane.org? > Message-ID: <5424AFC2.6020302 at comcast.net> > Content-Type: text/plain; charset="windows-1252"; Format="flowed" > > > On 9/25/2014 5:26 PM, Neil Van Dyke wrote: >> You can check your IP addr against the list at >> "http://gmane.org/denied.php". >> >> Neil V. > > On 9/25/2014 7:08 PM, Adrian Klaver wrote: >> >> Take a look here: >> >> http://gmane.org/denied.php >> >> My guess is you are the fourth one from the bottom. >> >> >> Might want to take a look at this thread to see what your options are >> and what the turn around time is on your request: >> >> http://thread.gmane.org/gmane.discuss/16309 > > Thanks to both of you - I missed seeing the entry about the denied list > in the FAQ. > > Adrian you were right - it seems that I have been blocked for some > reason. Based on the description of infractions I really don't think I > did anything to warrant it ... but there it is. I'll have to follow my > lists by email until I can unblocked. > > Thanks again, > George > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 4 > Date: Thu, 25 Sep 2014 21:42:00 -0400 > From: "Alexander D. Knauth" > To: Sam Tobin-Hochstadt > Cc: racket users list > Subject: Re: [racket] typed racket, filters, and polymorphism > Message-ID: > Content-Type: text/plain; charset="windows-1252" > > What I?m trying to accomplish is something more like this: > #lang typed/racket > > (require "dimensions.rkt") > > (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent > #:guard (lambda (name scalar dimension _) > (unless (dimension? dimension) > (error 'unit "expected Dimension, given ~v" dimension)) > (values name scalar dimension))) > > (define-type (Unitof d) (unit d)) > > (define-type Unit (Unitof Dimension)) > > (define Unit? (make-predicate Unit)) > > (define-type Unitish > (U (Unitof Any) > Dimension > Positive-Real)) > > (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)] > [Unitish -> Unit]))) > (define (->unit u) > (cond [(unit? u) > (unless (Unit? u) ; this should never happen anyway because of the guard > (error '->unit "expected (Unitof Dimension), given ~v" u)) > u] > [(dimension? u) (unit u 1 u)] > [(positive-real? u) (unit u u dimensionless-dimension)])) > > > On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt wrote: > >> No, I don't think you can do this. Can you say more about what you're >> trying to accomplish? >> >> Sam >> >> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth >> wrote: >>> Do any of you have any advice for getting a function like this to >>> type-check? >>> #lang typed/racket >>> >>> (: check-int : (All (a) (case-> [a -> a] >>> [Any -> Integer]))) >>> (define (check-int int) >>> (unless (exact-integer? int) >>> (error 'check-int "expected Integer, given ~v" int)) >>> int) >>> >>> ;. Type Checker: type mismatch >>> ; expected: a >>> ; given: Integer in: int >>> >>> >>> >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 5 > Date: Fri, 26 Sep 2014 00:16:56 -0400 > From: George Neuner > To: Jay McCarthy > Cc: users > Subject: Re: [racket] web server: module servlets > Message-ID: <5424E8B8.8040501 at comcast.net> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > On 9/25/2014 6:26 PM, Jay McCarthy wrote: >> web-server/servlet is NOT shared, nor is any net library or common >> racket library like racket/list. They are all totally unique per >> servlet. >> >> This, by the way, is part of why I don't recommend using dynamic >> servlets at all and suggest using serve/servlet. > > But ... IIUC ... a listener started by serve/servlet will still > dynamically load from , /htdocs/*, etc. if > the request doesn't match a hard coded dispatch URL - the regex of the > initial servlet or an entry in a dispatcher table. At least that's the > behavior I see with my own application: my initial servlet returns 404 > when called - the call to serve/servlet just sets up the environment > and and all the "real" servlets are demand loaded from disk when first > touched. > > Are you advocating *static* linking and essentially just dispatching to > internal functions by URL? ISTM that that defeats the purpose. > > George > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > End of users Digest, Vol 109, Issue 59 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:44 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:44 -0400 Subject: [racket] users Digest, Vol 109, Issue 57 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Thu, Sep 25, 2014 at 1:04 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. htdp: exercise 21.1.3 (Daniel Bastos) > 2. Re: web server: module servlets (George Neuner) > 3. ANN: DOS, Delimited-continuation-based Operating-system > Simulator (Jay McCarthy) > 4. Re: web server: module servlets (Jay McCarthy) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 25 Sep 2014 13:48:05 -0300 > From: Daniel Bastos > To: Racket Users > Subject: [racket] htdp: exercise 21.1.3 > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > The solution is missing, but I thought of exposing this one here so that it > gets scrutinized before sending it to Robby Findler. > > ;; Exercise 21.1.3. Define natural-f, which is the abstraction of the > ;; following two functions: > ;; > ;; ;; copy : N X -> (listof X) > ;; ;; to create a list that contains > ;; ;; obj n times > ;; (define (copy n obj) > ;; (cond > ;; [(zero? n) empty] > ;; [else (cons obj > ;; (copy (sub1 n) obj))])) > ;; > ;; ;; n-adder : N number -> number > ;; ;; to add n to x using > ;; ;; (+ 1 ...) only > ;; (define (n-adder n x) > ;; (cond > ;; [(zero? n) x] > ;; [else (+ 1 > ;; (n-adder (sub1 n) x))])) > ;; > ;; Don't forget to test natural-f. Also use natural-f to define > ;; n-multiplier, which consumes n and x and produces n times x with > ;; additions only. Use the examples to formulate a contract. > ;; > ;; Hint: The two function differ more than, say, the functions sum and > ;; product in exercise 21.1.2. In particular, the base case in one > ;; instance is a argument of the function, where in the other it is just > ;; a constant value. > ;; > ;; (*) Solution > ;; > ;; After following the design recipe for abstraction, we get natural-f as > ;; shown below. To write the contract, let's first only consider copy, > ;; then we consider only n-adder and then we consider both. > ;; > ;; ;; natural-f-copy: Nat X (X (listof X) -> (listof X)) (listof X) -> > (listof X) > ;; ;; natural-f-adder: Nat number (number number -> number) number -> number > ;; > ;; The contract for natural-f-adder is more specific than > ;; natural-f-copy. The difference between these is that in the first, two > ;; different types are involved --- X and (listof X). Therefore, (listof > ;; X) works as another variable, so let's call it Y in the final version. > > ;; natural-f: Nat X (X Y -> Y) Y -> Y > (define (natural-f n x f init) > (cond > [(zero? n) init] > [else (f x > (natural-f (sub1 n) x f init))])) > > ;; (*) Tests > > ;; Let's use two different types in copy, say symbol and then number. > > (check-expect (copy 3 'a) '(a a a)) > (check-expect (natural-f 3 'a cons empty) (copy 3 'a)) > > (check-expect (copy 0 'a) empty) > (check-expect (natural-f 0 'a cons empty) (copy 0 'a)) > > (check-expect (copy 3 1) (list 1 1 1)) > (check-expect (natural-f 3 1 cons empty) (copy 3 1)) > > ;; For n-adder, let's make sure to test different init-values. > > (check-expect (n-adder 3 3.14) 6.14) > (check-expect (natural-f 3 1 + 3.14) (n-adder 3 3.14)) > > (check-expect (n-adder 3 1) 4) > (check-expect (natural-f 3 1 + 1) (n-adder 3 1)) > > (check-expect (n-adder 3 2) 5) > (check-expect (natural-f 3 1 + 2) (n-adder 3 2)) > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Thu, 25 Sep 2014 12:51:56 -0400 > From: George Neuner > To: Jay McCarthy > Cc: users > Subject: Re: [racket] web server: module servlets > Message-ID: <5424482C.1030901 at comcast.net> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > Hi Jay, > > On 9/23/2014 10:03 PM, Jay McCarthy wrote: >> The command-line tool is basically deprecated and only provided for >> backwards compatibility. There is a huge amount that it can't do at >> all and it hasn't been the primary way that we recommend using the Web >> server for a very long time. > > I'm not using the plt-web-server app - I created a minimal application > that set up the environment: directories, ports, etc. and a start > function that just returns a 404 if called. My server sits behind > Apache and only handles servlets, which I would like to be demand load > modules so they can be added to and updated easily. That's why I am > interested in being able to unload servlets on command, though not > necessarily all of them at once (although that also is helpful). > > >> > Not really knowing much about Racket's internals he naively asks: >> >Coulda server pre-load the commonly used webserver modules and make >> >themavailableto new module servlets, or does the custodian >> >implementation make doing thatdifficult/impossible? >> >> This is the purpose of the make-servlet-namespace argument of >> configuration-table->web-config@ but there is no option in the >> configuration file for that argument. >> >> http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 > > The namespace facility seems designed more for user written modules than > for library modules. > > My analysis may be off-base as I have very little experience working > directly with custodians, but it seems that when a dynamic servlet is > first loaded, its custodian spends a lot of additional time (re)loading > library modules that already exist in other custodians. [ Though I can't > tell exactly what's happening, I can see a lot of disk activity when I > think I'm loading a 5KB servlet. ] Reasonably I would have expected > that after loading/linking the first servlet, the libraries common to > the servlets would be already in memory. But loading additional servlets > is no quicker [ and causes a similar disk hit ] so clearly I don't > understand what is happening internally with the custodians. > > If a Racket library is deliberately put into the servlet-namespace, does > that streamline linking? > > >> > My application so far is based on stateful servlets and AJAX ... stateful >> > mainly because it's easier for me to understand. Currently there is >> >little use ofcontinuations, but some planned functionality will use them >> > extensively and it certainly wouldhelp if debugging didn't always mean >> >starting over setting up conditions in theapplication. >> >> This comment/question is related to questions 4 and 5 from the FAQ: >> >> http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 > > That link leads to a "troubleshooting" page 8-). I didn't consider the > issue to be a "problem" per se - I already knew that restarting a > stateful servlet would lose saved state. Most of my existing servlets > are one-shots that don't save any state, but they are written using the > stateful language. Only a few use continuations and not extensively (so > far). I was just thinking ahead to stuff that will need to use > continuations more extensively. > > Thanks for putting up with my questions. > George > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 13:02:00 -0400 > From: Jay McCarthy > To: users > Subject: [racket] ANN: DOS, Delimited-continuation-based > Operating-system Simulator > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I've just released the game architecture library I talked about in > part 2 of my RacketCon talk. > > The big picture of this library is to make World-style programs more > compositional by (a) using continuations to hide the internal state > (including control state) of components and (b) using environments as > a standard monoid-based inter-component communication channel. A > monoid is used to ensure that the components can be evaluated in any > order. Despite assumptions some have about continuations and pure > functional programming, it is incredibly efficient and can run at > 60FPS, as demonstrated in get-bonus. > > You can get it with > > raco pkg install dos > > And you can try out the demo with > > racket -l dos/examples/win > > The demo source is a bare 39 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt > > and I provide the non-DOS version for comparison: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt > > The core library has a mere 36 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt > > -- > Jay McCarthy > 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&C 64:33 > > > ------------------------------ > > Message: 4 > Date: Thu, 25 Sep 2014 13:04:44 -0400 > From: Jay McCarthy > To: George Neuner > Cc: users > Subject: Re: [racket] web server: module servlets > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > On Thu, Sep 25, 2014 at 12:51 PM, George Neuner wrote: >> Hi Jay, >> >> On 9/23/2014 10:03 PM, Jay McCarthy wrote: >> >> The command-line tool is basically deprecated and only provided for >> backwards compatibility. There is a huge amount that it can't do at >> all and it hasn't been the primary way that we recommend using the Web >> server for a very long time. >> >> >> I'm not using the plt-web-server app - I created a minimal application that >> set up the environment: directories, ports, etc. and a start function that >> just returns a 404 if called. My server sits behind Apache and only handles >> servlets, which I would like to be demand load modules so they can be added >> to and updated easily. That's why I am interested in being able to unload >> servlets on command, though not necessarily all of them at once (although >> that also is helpful). >> >> >>> Not really knowing much about Racket's internals he naively asks: >>> Could a server pre-load the commonly used webserver modules and make >>> them available to new module servlets, or does the custodian >>> implementation make doing that difficult/impossible? >> >> This is the purpose of the make-servlet-namespace argument of >> configuration-table->web-config@ but there is no option in the >> configuration file for that argument. >> >> http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 >> >> >> The namespace facility seems designed more for user written modules than for >> library modules. >> >> My analysis may be off-base as I have very little experience working >> directly with custodians, but it seems that when a dynamic servlet is first >> loaded, its custodian spends a lot of additional time (re)loading library >> modules that already exist in other custodians. [ Though I can't tell >> exactly what's happening, I can see a lot of disk activity when I think I'm >> loading a 5KB servlet. ] Reasonably I would have expected that after >> loading/linking the first servlet, the libraries common to the servlets >> would be already in memory. But loading additional servlets is no quicker [ >> and causes a similar disk hit ] so clearly I don't understand what is >> happening internally with the custodians. >> >> If a Racket library is deliberately put into the servlet-namespace, does >> that streamline linking? >> > > Your assumption about the purpose of this is not correct. Anything in > the servlet-namespace will be shared between all servlets, and thus > not loaded per-servlet. > >>> My application so far is based on stateful servlets and AJAX ... stateful >>> mainly because it's easier for me to understand. Currently there is >>> little use of continuations, but some planned functionality will use them >>> extensively and it certainly would help if debugging didn't always mean >>> starting over setting up conditions in the application. >> >> This comment/question is related to questions 4 and 5 from the FAQ: >> >> http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 >> >> >> That link leads to a "troubleshooting" page 8-). I didn't consider the >> issue to be a "problem" per se - I already knew that restarting a stateful >> servlet would lose saved state. Most of my existing servlets are one-shots >> that don't save any state, but they are written using the stateful language. >> Only a few use continuations and not extensively (so far). I was just >> thinking ahead to stuff that will need to use continuations more >> extensively. >> >> Thanks for putting up with my questions. >> George >> > > > > -- > Jay McCarthy > 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&C 64:33 > > > End of users Digest, Vol 109, Issue 57 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:43:54 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:43:54 -0400 Subject: [racket] users Digest, Vol 109, Issue 56 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Thu, Sep 25, 2014 at 12:00 PM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. Unquoting a variable without unquoting its contents? (J Arcane) > 2. Re: macro question (Jay McCarthy) > 3. Re: macro question (Alejandro Zamora) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 25 Sep 2014 16:52:47 +0300 > From: J Arcane > To: Racket Users > Subject: [racket] Unquoting a variable without unquoting its > contents? > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > http://try-racket.org continues to splutter to life, but there's still > something of a glaring error in that it doesn't really like list or quote > at all. > > AlexKnauth has narrowed the problem down here: > https://github.com/jarcane/try-racket/issues/4#issuecomment-56751603 > > It seems that unquoting a variable does funny things to the variable's > contents when they contain a bare quoted list or symbol, so we get weird > results and errors. Quotes get lost, and then the eval finds itself looking > at mangled forms. > > The best I can think of to do is maybe make a simple macro rather than > using quasiquote? Any ideas? > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Thu, 25 Sep 2014 10:17:49 -0400 > From: Jay McCarthy > To: Alejandro Zamora > Cc: Racket Users > Subject: Re: [racket] macro question > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I won't answer the question about R5RS, but in Racket you can do this > fairly succinctly: > > #lang racket/base > (require (for-syntax racket/base > racket/syntax)) > > (define-syntax (vars stx) > (syntax-case stx () > [(_ id count val) > (with-syntax > ([(id_i ...) > (for/list ([i (in-range 1 (add1 (syntax->datum #'count)))]) > (format-id #'id "~a~a" #'id i))]) > (syntax/loc stx > (begin (define id_i val) > ...)))])) > > (vars id 5 null) > > (vector id1 id2 id3 id4 id5) > > 2014-09-24 22:35 GMT-04:00 Alejandro Zamora : >> Hi Racket people: >> I have a (maybe too simple) question: >> How I create one macro like this (but using define-macro & >> R5RS language only)?: >> >> (vars sym var-cant val-of-vars) >> >> Example: >> (vars id 5 null) -> (prog (define id1 null) >> (define id2 null) >> (define id3 null) >> (define id4 null) >> (define id5 null)) >> >> -- >> Nunca digas nunca, di mejor: gracias, permiso, disculpe. >> >> Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas >> >> Infomed: http://www.sld.cu/ >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > > > -- > Jay McCarthy > 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&C 64:33 > > > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 10:49:15 -0400 > From: Alejandro Zamora > To: Jay McCarthy > Cc: Racket Users > Subject: Re: [racket] macro question > Message-ID: <20140925104915.59291dc0 at alejandro-H61H2-CM> > Content-Type: text/plain; charset=UTF-8 > > Thanks Jay!! > nice solution!! > I'm asking for define-macro & R5RS because I'm trying to use one > R5RS Embedded Scheme Interpreter on Python that have only define-macro > construction for make macros and I want to use it. > > greetings! > > El Thu, 25 Sep 2014 10:17:49 -0400 > Jay McCarthy escribi?: >> I won't answer the question about R5RS, but in Racket you can do this >> fairly succinctly: >> >> #lang racket/base >> (require (for-syntax racket/base >> racket/syntax)) >> >> (define-syntax (vars stx) >> (syntax-case stx () >> [(_ id count val) >> (with-syntax >> ([(id_i ...) >> (for/list ([i (in-range 1 (add1 (syntax->datum #'count)))]) >> (format-id #'id "~a~a" #'id i))]) >> (syntax/loc stx >> (begin (define id_i val) >> ...)))])) >> >> (vars id 5 null) >> >> (vector id1 id2 id3 id4 id5) >> >> 2014-09-24 22:35 GMT-04:00 Alejandro Zamora : >> > Hi Racket people: >> > I have a (maybe too simple) question: >> > How I create one macro like this (but using define-macro & >> > R5RS language only)?: >> > >> > (vars sym var-cant val-of-vars) >> > >> > Example: >> > (vars id 5 null) -> (prog (define id1 null) >> > (define id2 null) >> > (define id3 null) >> > (define id4 null) >> > (define id5 null)) >> > >> > -- >> > Nunca digas nunca, di mejor: gracias, permiso, disculpe. >> > >> > Este mensaje le ha llegado mediante el servicio de correo >> > electronico que ofrece Infomed para respaldar el cumplimiento de >> > las misiones del Sistema Nacional de Salud. La persona que envia >> > este correo asume el compromiso de usar el servicio a tales fines y >> > cumplir con las regulaciones establecidas >> > >> > Infomed: http://www.sld.cu/ >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> >> >> > > > -- > Nunca digas nunca, di mejor: gracias, permiso, disculpe. > > Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > > > > End of users Digest, Vol 109, Issue 56 > ************************************** From moshedeutsch115 at gmail.com Mon Sep 29 16:44:05 2014 From: moshedeutsch115 at gmail.com (Moshe Deutsch) Date: Mon, 29 Sep 2014 16:44:05 -0400 Subject: [racket] users Digest, Vol 109, Issue 55 In-Reply-To: References: Message-ID: Please take me off the list Thanks On Thu, Sep 25, 2014 at 8:57 AM, wrote: > Send users mailing list submissions to > users at racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-request at racket-lang.org > > You can reach the person managing the list at > users-owner at racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. macro question (Alejandro Zamora) > 2. Re: ranking items by their appearance in sets (David T. Pierson) > 3. Switching from editor to repl (C K Kashyap) > 4. Re: Switching from editor to repl (Jay McCarthy) > 5. Re: Switching from editor to repl (C K Kashyap) > 6. Re: Switching from editor to repl (Robby Findler) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 24 Sep 2014 22:35:49 -0400 > From: Alejandro Zamora > To: Racket Users > Subject: [racket] macro question > Message-ID: <20140924223549.7f15c912 at alejandro-H61H2-CM> > Content-Type: text/plain; charset=US-ASCII > > Hi Racket people: > I have a (maybe too simple) question: > How I create one macro like this (but using define-macro & > R5RS language only)?: > > (vars sym var-cant val-of-vars) > > Example: > (vars id 5 null) -> (prog (define id1 null) > (define id2 null) > (define id3 null) > (define id4 null) > (define id5 null)) > > -- > Nunca digas nunca, di mejor: gracias, permiso, disculpe. > > Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > > > ------------------------------ > > Message: 2 > Date: Wed, 24 Sep 2014 23:07:13 -0400 > From: "David T. Pierson" > To: Matthias Felleisen > Cc: users at racket-lang.org > Subject: Re: [racket] ranking items by their appearance in sets > Message-ID: <1411613699.19584%dtp at mindstory.com> > Content-Type: text/plain; charset=us-ascii > > On Wed, Sep 24, 2014 at 10:44:45AM -0400, Matthias Felleisen wrote: >> Style: Here is my rewrite with style suggestions. I liked to have a >> single point that tests all versions of a function when I conduct such >> design experiments. I also want to have all my test code in the test >> submodule so that it doesn't get deployed. That's why I am using a >> syntactic abstraction that unfolds into a submodule rather than a >> function that calls things. > > Thanks for the style suggestions. I am reminded I need to reread the > style guide. > >> Performance: I have not checked their performance but I cannot imagine >> the first version to be performant. See my annotations. > > Good point. I had put performance out of my mind because my real data > is relatively small and I just wanted to play a bit with the methods, > but I definitely appreciate the notes. > >> My choice: Your second version is what I would have written. > > Glad to know I was on the right track. > > Thank you. > > David > > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 11:47:57 +0530 > From: C K Kashyap > To: users at racket-lang.org > Subject: [racket] Switching from editor to repl > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Hi, > I am new to racket (but am really excited by the idea - everything is a > program) - need a quick help with Dr Racket - > > What's the keyboard shortcut to switch between editor and repl? > > I got to know from a video on youtube that I could use C-e to toggle the > repl visibility but not able to find out how to get to the rpl using the > keyboard. > Regards, > Kashyap > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 4 > Date: Thu, 25 Sep 2014 02:33:55 -0400 > From: Jay McCarthy > To: C K Kashyap > Cc: users > Subject: Re: [racket] Switching from editor to repl > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I use C-e and C-d to do this and I just hit it twice, once hides the > side and the second shows it and focuses it. > > On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: >> Hi, >> I am new to racket (but am really excited by the idea - everything is a >> program) - need a quick help with Dr Racket - >> >> What's the keyboard shortcut to switch between editor and repl? >> >> I got to know from a video on youtube that I could use C-e to toggle the >> repl visibility but not able to find out how to get to the rpl using the >> keyboard. >> Regards, >> Kashyap >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > > > > -- > Jay McCarthy > 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&C 64:33 > > > ------------------------------ > > Message: 5 > Date: Thu, 25 Sep 2014 13:13:58 +0530 > From: C K Kashyap > To: Jay McCarthy > Cc: users > Subject: Re: [racket] Switching from editor to repl > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > C-d works for me ... thanks Jay. > I was wondering though if I could've found this out in the documentation > somewhere. I could not find it in the guide/google. > > Regards, > Kashyap > > On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy > wrote: > >> I use C-e and C-d to do this and I just hit it twice, once hides the >> side and the second shows it and focuses it. >> >> On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: >> > Hi, >> > I am new to racket (but am really excited by the idea - everything is a >> > program) - need a quick help with Dr Racket - >> > >> > What's the keyboard shortcut to switch between editor and repl? >> > >> > I got to know from a video on youtube that I could use C-e to toggle the >> > repl visibility but not able to find out how to get to the rpl using the >> > keyboard. >> > Regards, >> > Kashyap >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > >> >> >> >> -- >> Jay McCarthy >> 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&C 64:33 >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 6 > Date: Thu, 25 Sep 2014 07:56:53 -0500 > From: Robby Findler > To: C K Kashyap > Cc: Jay McCarthy , users > > Subject: Re: [racket] Switching from editor to repl > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > The guide focuses on the language, not the DrRacket IDE. This is a > link to the IDE docs that has a list of keyboard shortcuts. > > You might also try looking at the menu items; things are a little more > discoverable that way too. > > http://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html > > hth, > Robby > > On Thu, Sep 25, 2014 at 2:43 AM, C K Kashyap wrote: >> C-d works for me ... thanks Jay. >> I was wondering though if I could've found this out in the documentation >> somewhere. I could not find it in the guide/google. >> >> Regards, >> Kashyap >> >> On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy >> wrote: >>> >>> I use C-e and C-d to do this and I just hit it twice, once hides the >>> side and the second shows it and focuses it. >>> >>> On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap wrote: >>> > Hi, >>> > I am new to racket (but am really excited by the idea - everything is a >>> > program) - need a quick help with Dr Racket - >>> > >>> > What's the keyboard shortcut to switch between editor and repl? >>> > >>> > I got to know from a video on youtube that I could use C-e to toggle the >>> > repl visibility but not able to find out how to get to the rpl using the >>> > keyboard. >>> > Regards, >>> > Kashyap >>> > >>> > ____________________ >>> > Racket Users list: >>> > http://lists.racket-lang.org/users >>> > >>> >>> >>> >>> -- >>> Jay McCarthy >>> 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&C 64:33 >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > > > End of users Digest, Vol 109, Issue 55 > ************************************** From matthias at ccs.neu.edu Mon Sep 29 17:15:20 2014 From: matthias at ccs.neu.edu (Matthias Felleisen) Date: Mon, 29 Sep 2014 17:15:20 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> Message-ID: <076C047A-DC0A-49DE-A32A-1C64551DBF9B@ccs.neu.edu> Why don't you see whether it jives with TR? That would be a nice reproducability study. On Sep 29, 2014, at 4:32 PM, Benjamin Greenman wrote: > Could Andrew Myer's work on masked types (to eliminate nulls for object initialization) be relevant? > http://www.cs.cornell.edu/Projects/jmask/ > > On Mon, Sep 29, 2014 at 3:30 PM, Matthias Felleisen wrote: > > I guess the real problem is to create suitable default values so > that the pass the type checker or to figure out a cast that forces > TR to accept some other value as the default value (and making sure > you never use the object). > > Undefined not completely solved. Argh. -- Matthias > > > > > > On Sep 29, 2014, at 12:52 PM, Sam Tobin-Hochstadt wrote: > > > Ah, if you want to create truly cyclic structure with no base case > > like this, then you'll have to do more work. Either you'll need to > > expand the type of the `x` field in `foo` to allow an initial value, > > or you'll need to create a dummy `foo` with that extended type, and > > then copy the cyclic data once you've created it to a new version of > > `foo`, using hash tables to track cycles. That's basically how > > `shared` works, although I haven't tried implementing it in TR and it > > might not be possible. > > > > Sam > > > > On Mon, Sep 29, 2014 at 12:33 PM, Konrad Hinsen > > wrote: > >> Sam Tobin-Hochstadt writes: > >> > >>> I recommend doing the mutation yourself, and not using `shared`. > >>> That's the most obvious solution. > >> > >> Not for me, unfortunately, but probably I am missing something > >> obvious. > >> > >> Here's explicit mutation in untyped Racket: > >> > >> #lang racket > >> > >> (struct foo (x) #:mutable) > >> (struct bar (x)) > >> > >> (define f (foo (void))) > >> (define b (bar f)) > >> (set-foo-x! f b) > >> > >> (eq? (bar-x b) f) > >> (eq? (foo-x f) b) > >> > >> That works fine. Moving to Typed Racket, this is rejected by the type > >> checker because (void) is of type Void. Since I need a bar to make a > >> foo and a foo to make a bar, I don't see how I can ever initialize my > >> foo structure. > >> > >>> The reason that your `require/typed` doesn't work is that it creates > >>> new versions of the placeholder functions, but those aren't the ones > >>> that `shared` uses internally, so Typed Racket doesn't use the types > >>> you've given. > >> > >> That makes sense, thanks for the explanation! > >> > >> Konrad. > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > From nickmshelley at gmail.com Mon Sep 29 17:21:34 2014 From: nickmshelley at gmail.com (Nick Shelley) Date: Mon, 29 Sep 2014 15:21:34 -0600 Subject: [racket] users Digest, Vol 109, Issue 70 In-Reply-To: References: Message-ID: I'm not certain, but I'm pretty sure following the instructions at the top of the emails you are receiving would be a faster way to get what you want, rather than spamming the whole list for every email you receive. I'll quote them for your convenience (copied from the email you are replying to): To subscribe or unsubscribe via the World Wide Web, visit http://lists.racket-lang.org/users/listinfo or, via email, send a message with subject or body 'help' to users-request at racket-lang.org On Mon, Sep 29, 2014 at 2:41 PM, Moshe Deutsch wrote: > Please take me off the list > > Thanks > > On Sun, Sep 28, 2014 at 4:29 PM, wrote: > > Send users mailing list submissions to > > users at racket-lang.org > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.racket-lang.org/users/listinfo > > or, via email, send a message with subject or body 'help' to > > users-request at racket-lang.org > > > > You can reach the person managing the list at > > users-owner at racket-lang.org > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of users digest..." > > > > > > [Racket Users list: > > http://lists.racket-lang.org/users ] > > > > > > Today's Topics: > > > > 1. Re: Help debugging a ffi crash (Eric Dobson) > > 2. How to document a field? (Roman Klochkov) > > 3. Re: proof assistants, DrRacket and Bootstrap (Bill Richter) > > 4. Re: aws/glacier: credential scope (Greg Hendershott) > > 5. Re: aws/glacier: credential scope (Norman Gray) > > 6. Re: aws/glacier: credential scope (Greg Hendershott) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Sun, 28 Sep 2014 11:15:33 -0700 > > From: Eric Dobson > > To: Matthew Flatt > > Cc: "users at racket-lang.org" > > Subject: Re: [racket] Help debugging a ffi crash > > Message-ID: > > < > CAAEHQ5tWAKzi5AizADUH9smVsNXpYTbmxtO3teGm9Zj8ZDUnLg at mail.gmail.com> > > Content-Type: text/plain; charset=UTF-8 > > > > That is almost surely it, thanks for the second pair of eyes. I had > > similar issues with a different type that I thought was a pointer but > > was actually a struct, but that one I couldn't even get a single call > > to work so it was much more obvious something was up. > > > > On Sun, Sep 28, 2014 at 11:08 AM, Matthew Flatt > wrote: > >> Looking at > >> > >> http://clang.llvm.org/doxygen/CXString_8h_source.html > >> > >> it seems that CXString as returned by clang_getCursorSpelling() is not > >> a pointer: > >> > >> typedef struct { > >> const void *data; > >> unsigned private_flags; > >> } CXString; > >> > >> If that's right, I'm a little surprised that `cursor-spelling` works > >> --- but when you get representation wrong, strange things can happen, > >> including something working when it shouldn't. > >> > >> Am I looking at the right library/definitions? > >> > >> At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote: > >>> I'm trying to debug an FFI crash that I'm seeing, and because it is > >>> dealing with C code the error just presents as a segfault. I believe I > >>> have tracked down what is causing the problem, but don't understand > >>> how it could be doing so. > >>> > >>> I have two racket functions which take a "cursor" (the foreign > >>> libraries object) and return a string representation of it, which I'm > >>> trying to use for debugging. > >>> > >>> (define raw-clang-get-cstring > >>> (get-ffi-obj "clang_getCString" lib-clang > >>> (_fun _pointer -> _string))) > >>> > >>> (define raw-cursor-spelling > >>> (get-ffi-obj "clang_getCursorSpelling" lib-clang > >>> (_fun _CXCursor -> _pointer))) > >>> > >>> (define (cursor-spelling c) > >>> (raw-clang-get-cstring (raw-cursor-spelling c))) > >>> > >>> (define cursor-spelling2 > >>> (get-ffi-obj "clang_getCursorSpelling" lib-clang > >>> (_fun _CXCursor -> (make-ctype _pointer values (? (v) > >>> (raw-clang-get-cstring v)))))) > >>> > >>> If I use cursor-spelling, I have not been able to trigger a crash. But > >>> if I use cursor-spelling2 I can reliably trigger a crash. > >>> > >>> Is there anything obvious on how these functions are different? > >>> Because they look to me like they should be doing the same thing. If > >>> it would be helpful I can try to get my code in a portable enough > >>> shape so that it will work/crash on another machine. > >>> > >>> ____________________ > >>> Racket Users list: > >>> http://lists.racket-lang.org/users > > > > > > > > ------------------------------ > > > > Message: 2 > > Date: Sun, 28 Sep 2014 22:39:54 +0400 > > From: Roman Klochkov > > To: racket users list > > Subject: [racket] How to document a field? > > Message-ID: <1411929594.923492574 at f67.i.mail.ru> > > Content-Type: text/plain; charset="utf-8" > > > > At http://docs.racket-lang.org/scribble/doc-classes.html I see > classes, interfaces, methods, but don't see fields. > > > > How to document them? Via @defthing or is there some syntax with > (get-field ..) (set-field! ...) template like @defparam ? > > > > > > -- > > Roman Klochkov > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: < > http://lists.racket-lang.org/users/archive/attachments/20140928/ac478807/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 3 > > Date: Sun, 28 Sep 2014 13:51:26 -0500 > > From: Bill Richter > > Cc: users at racket-lang.org > > Subject: Re: [racket] proof assistants, DrRacket and Bootstrap > > Message-ID: > > <201409281851.s8SIpQMx006764 at poisson.math.northwestern.edu> > > > > Matthias & Prabhakar, I think I see what you're saying now. I need the > camlp parser to turn my dialect-expressions into trees. Then I turn my > tree into standard expressions just as one does in Scheme. The only > differences is that in Scheme we have the quote function that skips the > parsing step. So your ML code > > > > MF> type ast = VAR of String | LAM of String * ast | APP of ast * ast > | CONST of int | ADD of ast * ast > > MF> type val = BASIC of int | FUNCTION of val -> val | ... > > > > looks a lot like the HOL Light definition of preterms: > > > > type preterm = Varp of string * pretype (* Variable - v > *) > > | Constp of string * pretype (* Constant - c > *) > > | Combp of preterm * preterm (* Combination - f > x *) > > | Absp of preterm * preterm (* Lambda-abstraction - > \x. t *) > > | Typing of preterm * pretype;; (* Type constraint - t > : ty *) > > > > and so we can see one of these preterms in a standard term: > > > > # preterm_of_term `x + y`;; > > val it : preterm = > > Combp > > (Combp > > (Constp ("+", > > Ptycon ("fun", > > [Ptycon ("num", []); > > Ptycon ("fun", [Ptycon ("num", []); Ptycon ("num", [])])])), > > Varp ("x", Ptycon ("num", []))), > > Varp ("y", Ptycon ("num", []))) > > > > So the Scheme story works fine except that I haven't understood camlp or > how HOL Light turns expressions `[...]` into preterms. But I feel better > about investing the time into learning camlp now that I see the Scheme > story remains intact in HOL Light. And you're right about my ignorance: > > > > MF> 1. HtDP explains the above in a couple of sections. > > > > Right, there's something I seem not to have understood in either Scheme > or ML, how when we create and evaluate our trees we retain the values of > our variables. I can figure that out, and HtDP sounds like a good place to > start. > > > > PR> A Racketeer would probably tell you to use macros to define your > > PR> dialect, instead of using an eval hack. The corresponding tool for > > PR> OCaml is camlp4, and it sounds as if it would be worth your time > > PR> to learn it thoroughly. > > > > That's an interesting comparison, and since macros, maybe I can learn to > like camlp. In fact, maybe I ought to learn something about racket macros > first. > > > > -- > > Best, > > Bill > > > > > > ------------------------------ > > > > Message: 4 > > Date: Sun, 28 Sep 2014 16:01:20 -0400 > > From: Greg Hendershott > > To: Norman Gray > > Cc: users at racket-lang.org > > Subject: Re: [racket] aws/glacier: credential scope > > Message-ID: > > < > CAGspUn0tqgSVUaDuk1C3Wb6hm6s6nQ2ps-j42pkJJSY2UESL0A at mail.gmail.com> > > Content-Type: text/plain; charset=UTF-8 > > > > Hi, Norman. > > > > I logged an issue for this: > > > > https://github.com/greghendershott/aws/issues/32 > > > > I see the problem (or at least the main problem) and will push a fix. > > > > The bug is embarrassing, not just because it's such a silly mistake, > > but it's something a unit test could have caught. (I could say that > > doing unit tests for Glacier is challenging, because the retrieval > > process can take hours. Although that's true, I could have done more > > to test _some_ operations working among various regions.) > > > > On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray > wrote: > >> > >> Greetings. > >> > >> I'm trying to use the aws/glacier package, and running into a problem > where I'm being told: > >> > >> Credential should be scoped to a valid region, not 'eu-west-1' > >> > >> I'm following the instructions at < > https://github.com/greghendershott/aws/blob/master/aws/manual.md> > >> > >> My test code is: > >> > >> % cat glacier.rkt > >> #lang racket/base > >> > >> (require aws/glacier > >> aws/keys) > >> > >> (define vault "testvault") > >> (region "eu-west-1") > >> (read-keys "aws-zbu-credentials") ; local file > >> > >> (module+ main > >> (printf "region=~a~%" (region)) > >> (printf "Vaults: ~s~%" (list-vaults)) > >> (printf "...specifically: ~s~%" (describe-vault vault))) > >> > >> Running this produces: > >> > >> % racket glacier.rkt > >> region=eu-west-1 > >> aws: HTTP/1.1 403 Forbidden > >> x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 > >> Content-Type: application/json > >> Content-Length: 129 > >> Date: Sat, 27 Sep 2014 18:35:50 GMT > >> > >> {"message":"Credential should be scoped to a valid region, not > 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} > >> HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" > Message="Credential should be scoped to a valid region, not 'eu-west-1'. " > >> context...: > >> check-response > >> /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: > temp68 > >> request/redirect/uri > >> (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] > >> > >> Things I thought of: > >> > >> * Printing (public-key)/(private-key) indicates that the credentials > are being read correctly. > >> * When I change the argument of (region) to "us-west-1", that's the > region that appears in the error message. > >> * My "testvault" vault is in eu-west-1 (and this is indeed one of the > valid regions for glacier, reported in < > http://docs.aws.amazon.com/general/latest/gr/rande.html> and which does > have a host at http://glacier.eu-west-1.amazonaws.com > >> * As far as I can see, credentials are _not_ scoped, but are all at > us-east-1. > >> * < > http://docs.aws.amazon.com/general/latest/gr/signature-v4-troubleshooting.html> > says that "IAM [...] accepts only us-east-1 as its region specification", > so I'm taking it that (region) is for setting the _vault_'s region. > >> * I'm not a great AWS expert, so I could have something in my setup > broken; but if so, I've no clue what. > >> > >> If, however, I change the (region) argument to "us-east-1", I get a > different error message "User: arn:aws:iam::786725553169:user/zbu is not > authorized to perform: glacier:ListVaults on resource: > arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since > there's no such vault, but it's interesting that it gets _further_ when the > (region) matches the region for the IAM service. > >> > >> I don't see any other (region) equivalents for the other services > supported by the package. Is that because all of the other services > supported by the package are supported by all the AWS regions, or am I > missing a configuration? > >> > >> Thanks for any pointers. > >> > >> All the best, > >> > >> Norman > >> > >> > >> -- > >> Norman Gray : http://nxg.me.uk > >> SUPA School of Physics and Astronomy, University of Glasgow, UK > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > > > > > > > > ------------------------------ > > > > Message: 5 > > Date: Sun, 28 Sep 2014 21:29:03 +0100 > > From: Norman Gray > > To: Greg Hendershott > > Cc: users at racket-lang.org > > Subject: Re: [racket] aws/glacier: credential scope > > Message-ID: > > Content-Type: text/plain; charset=us-ascii > > > > > > Greg, hello. > > > > On 2014 Sep 28, at 21:01, Greg Hendershott > wrote: > > > >> I logged an issue for this: > >> > >> https://github.com/greghendershott/aws/issues/32 > > > > Ah: I wondered if the problem might be related to that. > > > >> The bug is embarrassing, not just because it's such a silly mistake, > >> but it's something a unit test could have caught. (I could say that > >> doing unit tests for Glacier is challenging, because the retrieval > >> process can take hours. > > > > I can imagine how protracted that would be ... *shudder*. > > > > Thanks for looking at this. > > > > Also, Frank: > > > >> What happens if you read-keys before setting the region? > > > > Thanks for this suggestion: I did try that just a little earlier, but it > didn't make any difference. > > > > All the best, > > > > Norman > > > > > > -- > > Norman Gray : http://nxg.me.uk > > SUPA School of Physics and Astronomy, University of Glasgow, UK > > > > > > > > > > ------------------------------ > > > > Message: 6 > > Date: Sun, 28 Sep 2014 16:29:12 -0400 > > From: Greg Hendershott > > To: Norman Gray > > Cc: users at racket-lang.org > > Subject: Re: [racket] aws/glacier: credential scope > > Message-ID: > > < > CAGspUn2au5xydsH+o9E2Y3JTA1iQbPRX58zRcitywAPWh5Djng at mail.gmail.com> > > Content-Type: text/plain; charset=UTF-8 > > > > I pushed a fix, including running the tests across a few different AWS > > regions. They pass. > > > > I clicked "update" on pkgs.racket-lang.org. But it seems to be slower > > than usual to refresh. After it does, you can `raco pkg update aws` to > > get the fix. > > > > On Sun, Sep 28, 2014 at 4:01 PM, Greg Hendershott > > wrote: > >> Hi, Norman. > >> > >> I logged an issue for this: > >> > >> https://github.com/greghendershott/aws/issues/32 > >> > >> I see the problem (or at least the main problem) and will push a fix. > >> > >> The bug is embarrassing, not just because it's such a silly mistake, > >> but it's something a unit test could have caught. (I could say that > >> doing unit tests for Glacier is challenging, because the retrieval > >> process can take hours. Although that's true, I could have done more > >> to test _some_ operations working among various regions.) > >> > >> On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray > wrote: > >>> > >>> Greetings. > >>> > >>> I'm trying to use the aws/glacier package, and running into a problem > where I'm being told: > >>> > >>> Credential should be scoped to a valid region, not 'eu-west-1' > >>> > >>> I'm following the instructions at < > https://github.com/greghendershott/aws/blob/master/aws/manual.md> > >>> > >>> My test code is: > >>> > >>> % cat glacier.rkt > >>> #lang racket/base > >>> > >>> (require aws/glacier > >>> aws/keys) > >>> > >>> (define vault "testvault") > >>> (region "eu-west-1") > >>> (read-keys "aws-zbu-credentials") ; local file > >>> > >>> (module+ main > >>> (printf "region=~a~%" (region)) > >>> (printf "Vaults: ~s~%" (list-vaults)) > >>> (printf "...specifically: ~s~%" (describe-vault vault))) > >>> > >>> Running this produces: > >>> > >>> % racket glacier.rkt > >>> region=eu-west-1 > >>> aws: HTTP/1.1 403 Forbidden > >>> x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4 > >>> Content-Type: application/json > >>> Content-Length: 129 > >>> Date: Sat, 27 Sep 2014 18:35:50 GMT > >>> > >>> {"message":"Credential should be scoped to a valid region, not > 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"} > >>> HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" > Message="Credential should be scoped to a valid region, not 'eu-west-1'. " > >>> context...: > >>> check-response > >>> > /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68 > >>> request/redirect/uri > >>> (submod /checkouts/me/code/zbu/glacier.rkt main): [running body] > >>> > >>> Things I thought of: > >>> > >>> * Printing (public-key)/(private-key) indicates that the credentials > are being read correctly. > >>> * When I change the argument of (region) to "us-west-1", that's the > region that appears in the error message. > >>> * My "testvault" vault is in eu-west-1 (and this is indeed one of > the valid regions for glacier, reported in < > http://docs.aws.amazon.com/general/latest/gr/rande.html> and which does > have a host at http://glacier.eu-west-1.amazonaws.com > >>> * As far as I can see, credentials are _not_ scoped, but are all at > us-east-1. > >>> * < > http://docs.aws.amazon.com/general/latest/gr/signature-v4-troubleshooting.html> > says that "IAM [...] accepts only us-east-1 as its region specification", > so I'm taking it that (region) is for setting the _vault_'s region. > >>> * I'm not a great AWS expert, so I could have something in my setup > broken; but if so, I've no clue what. > >>> > >>> If, however, I change the (region) argument to "us-east-1", I get a > different error message "User: arn:aws:iam::786725553169:user/zbu is not > authorized to perform: glacier:ListVaults on resource: > arn:aws:glacier:us-east-1:786725553169:vaults/" That makes sense, since > there's no such vault, but it's interesting that it gets _further_ when the > (region) matches the region for the IAM service. > >>> > >>> I don't see any other (region) equivalents for the other services > supported by the package. Is that because all of the other services > supported by the package are supported by all the AWS regions, or am I > missing a configuration? > >>> > >>> Thanks for any pointers. > >>> > >>> All the best, > >>> > >>> Norman > >>> > >>> > >>> -- > >>> Norman Gray : http://nxg.me.uk > >>> SUPA School of Physics and Astronomy, University of Glasgow, UK > >>> > >>> > >>> ____________________ > >>> Racket Users list: > >>> http://lists.racket-lang.org/users > > > > > > > > End of users Digest, Vol 109, Issue 70 > > ************************************** > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From neil at neilvandyke.org Mon Sep 29 17:34:55 2014 From: neil at neilvandyke.org (Neil Van Dyke) Date: Mon, 29 Sep 2014 17:34:55 -0400 Subject: [racket] users Digest, Vol 109, Issue 79 In-Reply-To: References: Message-ID: <5429D07F.1070408@neilvandyke.org> I had privately pointed him to the URL to unsubscribe himself, but he says it didn't work. It appears that tensions have escalated. :) Neil V. From nickmshelley at gmail.com Mon Sep 29 18:32:27 2014 From: nickmshelley at gmail.com (Nick Shelley) Date: Mon, 29 Sep 2014 16:32:27 -0600 Subject: [racket] users Digest, Vol 109, Issue 79 In-Reply-To: <5429D07F.1070408@neilvandyke.org> References: <5429D07F.1070408@neilvandyke.org> Message-ID: I did so privately as well, but he said he doesn't have his password I guess. I replied to that and pointed him to the users-request email option. Hopefully that will help. On Mon, Sep 29, 2014 at 3:34 PM, Neil Van Dyke wrote: > I had privately pointed him to the URL to unsubscribe himself, but he says > it didn't work. It appears that tensions have escalated. :) > > Neil V. > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eli at barzilay.org Mon Sep 29 19:14:28 2014 From: eli at barzilay.org (Eli Barzilay) Date: Mon, 29 Sep 2014 19:14:28 -0400 Subject: [racket] users Digest, Vol 109, Issue 79 In-Reply-To: References: <5429D07F.1070408@neilvandyke.org> Message-ID: On Mon, Sep 29, 2014 at 3:34 PM, Neil Van Dyke wrote: > I had privately pointed him to the URL to unsubscribe himself, but he > says it didn't work. It appears that tensions have escalated. :) He eventually did unsubscribe. On Mon, Sep 29, 2014 at 6:32 PM, Nick Shelley wrote: > I did so privately as well, but he said he doesn't have his password I > guess. I replied to that and pointed him to the users-request email > option. Hopefully that will help. Note that every email has, at the bottom (or at the top for digest emails), that link that lets you unsubscribe (and change other options). There is no need for a password: if you don't have it just use the unsubscribe button without it, the mailing list will send you an email with a link to get you off. (Plus, there's a button under that which will send you the password. Overall, Mailman is doing its best to not require your password, and make it easy to get it if you do need it.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! From mflatt at cs.utah.edu Mon Sep 29 19:15:05 2014 From: mflatt at cs.utah.edu (Matthew Flatt) Date: Mon, 29 Sep 2014 17:15:05 -0600 Subject: [racket] users Digest, Vol 109, Issue 79 In-Reply-To: References: <5429D07F.1070408@neilvandyke.org> Message-ID: <20140929231507.22A69650197@mail-svr1.cs.utah.edu> I unsubscribed him manually after the first few messages reached me (I had been away from e-mail for a while), and I think the rest were in the out queue already. Thanks for your help! At Mon, 29 Sep 2014 16:32:27 -0600, Nick Shelley wrote: > I did so privately as well, but he said he doesn't have his password I > guess. I replied to that and pointed him to the users-request email option. > Hopefully that will help. > > On Mon, Sep 29, 2014 at 3:34 PM, Neil Van Dyke wrote: > > > I had privately pointed him to the URL to unsubscribe himself, but he says > > it didn't work. It appears that tensions have escalated. :) > > > > Neil V. > > > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users From emanonhere at gmail.com Mon Sep 29 21:52:17 2014 From: emanonhere at gmail.com (rrandom) Date: Tue, 30 Sep 2014 09:52:17 +0800 Subject: [racket] Is there any way to get the bit depth of a bitmap? In-Reply-To: <20140929152408.F0E42650192@mail-svr1.cs.utah.edu> References: <54297763.3020407@gmx.com> <20140929152408.F0E42650192@mail-svr1.cs.utah.edu> Message-ID: <542A0CD1.6080507@gmail.com> sorry, I do not understand, Does that mean I must set the bit depth of a bitmap manually? ? 2014/9/29 23:24, Matthew Flatt ??: > Racket libraries can read and write images of various formats and > pixels depths, but a `bitmap%` object always represents an image using > 1 or 32 bits per pixel in memory. > > At Mon, 29 Sep 2014 23:14:43 +0800, rrandom wrote: >> Hi,I am recently working in the book Digital Image Processing with >> racket. I want to know is there any way to get the bit depth or color >> depth of a input bitmap in Racket? I found the get-depth method in >> racket/draw,bitmap%, but it only return 1 and 32, that's not what i >> really want.I input a bitmap whose bit depth is 8 but i got 32. >> following is the code: >> >>> (send (read-bitmap "Fig0305(a)(DFT_no_log).tif") >> get-depth) >> 32 >> >> Is there anything I am wrong? Thank you! >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users From alex.mclin at gmail.com Mon Sep 29 22:44:36 2014 From: alex.mclin at gmail.com (Alexander McLin) Date: Mon, 29 Sep 2014 22:44:36 -0400 Subject: [racket] users Digest, Vol 109, Issue 55 In-Reply-To: References: Message-ID: Good grief, was it necessary to spam the list with your requests? You could have just sent one email instead of replying to like 20 different threads? And it would have been nice if you'd read the basic instructions which tells you exactly how to unsubscribe yourself without flooding my inbox. On Mon, Sep 29, 2014 at 4:44 PM, Moshe Deutsch wrote: > Please take me off the list > > Thanks > > On Thu, Sep 25, 2014 at 8:57 AM, wrote: > > Send users mailing list submissions to > > users at racket-lang.org > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.racket-lang.org/users/listinfo > > or, via email, send a message with subject or body 'help' to > > users-request at racket-lang.org > > > > You can reach the person managing the list at > > users-owner at racket-lang.org > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of users digest..." > > > > > > [Racket Users list: > > http://lists.racket-lang.org/users ] > > > > > > Today's Topics: > > > > 1. macro question (Alejandro Zamora) > > 2. Re: ranking items by their appearance in sets (David T. Pierson) > > 3. Switching from editor to repl (C K Kashyap) > > 4. Re: Switching from editor to repl (Jay McCarthy) > > 5. Re: Switching from editor to repl (C K Kashyap) > > 6. Re: Switching from editor to repl (Robby Findler) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Wed, 24 Sep 2014 22:35:49 -0400 > > From: Alejandro Zamora > > To: Racket Users > > Subject: [racket] macro question > > Message-ID: <20140924223549.7f15c912 at alejandro-H61H2-CM> > > Content-Type: text/plain; charset=US-ASCII > > > > Hi Racket people: > > I have a (maybe too simple) question: > > How I create one macro like this (but using define-macro & > > R5RS language only)?: > > > > (vars sym var-cant val-of-vars) > > > > Example: > > (vars id 5 null) -> (prog (define id1 null) > > (define id2 null) > > (define id3 null) > > (define id4 null) > > (define id5 null)) > > > > -- > > Nunca digas nunca, di mejor: gracias, permiso, disculpe. > > > > Este mensaje le ha llegado mediante el servicio de correo electronico > que ofrece Infomed para respaldar el cumplimiento de las misiones del > Sistema Nacional de Salud. La persona que envia este correo asume el > compromiso de usar el servicio a tales fines y cumplir con las regulaciones > establecidas > > > > Infomed: http://www.sld.cu/ > > > > > > > > ------------------------------ > > > > Message: 2 > > Date: Wed, 24 Sep 2014 23:07:13 -0400 > > From: "David T. Pierson" > > To: Matthias Felleisen > > Cc: users at racket-lang.org > > Subject: Re: [racket] ranking items by their appearance in sets > > Message-ID: <1411613699.19584%dtp at mindstory.com> > > Content-Type: text/plain; charset=us-ascii > > > > On Wed, Sep 24, 2014 at 10:44:45AM -0400, Matthias Felleisen wrote: > >> Style: Here is my rewrite with style suggestions. I liked to have a > >> single point that tests all versions of a function when I conduct such > >> design experiments. I also want to have all my test code in the test > >> submodule so that it doesn't get deployed. That's why I am using a > >> syntactic abstraction that unfolds into a submodule rather than a > >> function that calls things. > > > > Thanks for the style suggestions. I am reminded I need to reread the > > style guide. > > > >> Performance: I have not checked their performance but I cannot imagine > >> the first version to be performant. See my annotations. > > > > Good point. I had put performance out of my mind because my real data > > is relatively small and I just wanted to play a bit with the methods, > > but I definitely appreciate the notes. > > > >> My choice: Your second version is what I would have written. > > > > Glad to know I was on the right track. > > > > Thank you. > > > > David > > > > > > ------------------------------ > > > > Message: 3 > > Date: Thu, 25 Sep 2014 11:47:57 +0530 > > From: C K Kashyap > > To: users at racket-lang.org > > Subject: [racket] Switching from editor to repl > > Message-ID: > > < > CAGdT1gqUp-0hdF15FYo2T_Qpm+qf9AkKMak_iLV9HTC4WkDrtQ at mail.gmail.com> > > Content-Type: text/plain; charset="utf-8" > > > > Hi, > > I am new to racket (but am really excited by the idea - everything is a > > program) - need a quick help with Dr Racket - > > > > What's the keyboard shortcut to switch between editor and repl? > > > > I got to know from a video on youtube that I could use C-e to toggle the > > repl visibility but not able to find out how to get to the rpl using the > > keyboard. > > Regards, > > Kashyap > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: < > http://lists.racket-lang.org/users/archive/attachments/20140925/39d4382b/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 4 > > Date: Thu, 25 Sep 2014 02:33:55 -0400 > > From: Jay McCarthy > > To: C K Kashyap > > Cc: users > > Subject: Re: [racket] Switching from editor to repl > > Message-ID: > > < > CAJYbDamt+_RvG1utwzjJ1KW-m5ynRDxPr2xVivTOGQj8Y2R3DA at mail.gmail.com> > > Content-Type: text/plain; charset=UTF-8 > > > > I use C-e and C-d to do this and I just hit it twice, once hides the > > side and the second shows it and focuses it. > > > > On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap > wrote: > >> Hi, > >> I am new to racket (but am really excited by the idea - everything is a > >> program) - need a quick help with Dr Racket - > >> > >> What's the keyboard shortcut to switch between editor and repl? > >> > >> I got to know from a video on youtube that I could use C-e to toggle the > >> repl visibility but not able to find out how to get to the rpl using the > >> keyboard. > >> Regards, > >> Kashyap > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > >> > > > > > > > > -- > > Jay McCarthy > > 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&C 64:33 > > > > > > ------------------------------ > > > > Message: 5 > > Date: Thu, 25 Sep 2014 13:13:58 +0530 > > From: C K Kashyap > > To: Jay McCarthy > > Cc: users > > Subject: Re: [racket] Switching from editor to repl > > Message-ID: > > g at mail.gmail.com> > > Content-Type: text/plain; charset="utf-8" > > > > C-d works for me ... thanks Jay. > > I was wondering though if I could've found this out in the documentation > > somewhere. I could not find it in the guide/google. > > > > Regards, > > Kashyap > > > > On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy > > wrote: > > > >> I use C-e and C-d to do this and I just hit it twice, once hides the > >> side and the second shows it and focuses it. > >> > >> On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap > wrote: > >> > Hi, > >> > I am new to racket (but am really excited by the idea - everything is > a > >> > program) - need a quick help with Dr Racket - > >> > > >> > What's the keyboard shortcut to switch between editor and repl? > >> > > >> > I got to know from a video on youtube that I could use C-e to toggle > the > >> > repl visibility but not able to find out how to get to the rpl using > the > >> > keyboard. > >> > Regards, > >> > Kashyap > >> > > >> > ____________________ > >> > Racket Users list: > >> > http://lists.racket-lang.org/users > >> > > >> > >> > >> > >> -- > >> Jay McCarthy > >> 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&C 64:33 > >> > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: < > http://lists.racket-lang.org/users/archive/attachments/20140925/93aa6ef8/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 6 > > Date: Thu, 25 Sep 2014 07:56:53 -0500 > > From: Robby Findler > > To: C K Kashyap > > Cc: Jay McCarthy , users > > > > Subject: Re: [racket] Switching from editor to repl > > Message-ID: > > U8EibFfxLYDNVVW0+SEo9+Do5ZuMSu2bLQRm8y8A at mail.gmail.com> > > Content-Type: text/plain; charset=UTF-8 > > > > The guide focuses on the language, not the DrRacket IDE. This is a > > link to the IDE docs that has a list of keyboard shortcuts. > > > > You might also try looking at the menu items; things are a little more > > discoverable that way too. > > > > http://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html > > > > hth, > > Robby > > > > On Thu, Sep 25, 2014 at 2:43 AM, C K Kashyap > wrote: > >> C-d works for me ... thanks Jay. > >> I was wondering though if I could've found this out in the documentation > >> somewhere. I could not find it in the guide/google. > >> > >> Regards, > >> Kashyap > >> > >> On Thu, Sep 25, 2014 at 12:03 PM, Jay McCarthy > >> wrote: > >>> > >>> I use C-e and C-d to do this and I just hit it twice, once hides the > >>> side and the second shows it and focuses it. > >>> > >>> On Thu, Sep 25, 2014 at 2:17 AM, C K Kashyap > wrote: > >>> > Hi, > >>> > I am new to racket (but am really excited by the idea - everything > is a > >>> > program) - need a quick help with Dr Racket - > >>> > > >>> > What's the keyboard shortcut to switch between editor and repl? > >>> > > >>> > I got to know from a video on youtube that I could use C-e to toggle > the > >>> > repl visibility but not able to find out how to get to the rpl using > the > >>> > keyboard. > >>> > Regards, > >>> > Kashyap > >>> > > >>> > ____________________ > >>> > Racket Users list: > >>> > http://lists.racket-lang.org/users > >>> > > >>> > >>> > >>> > >>> -- > >>> Jay McCarthy > >>> 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&C 64:33 > >> > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > >> > > > > > > End of users Digest, Vol 109, Issue 55 > > ************************************** > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Tue Sep 30 03:32:58 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Tue, 30 Sep 2014 09:32:58 +0200 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <3597E44F-0EF5-4837-AA2D-E06E728B8B71@ccs.neu.edu> Message-ID: <21546.23722.89229.703426@Ordinateur-de-Catherine-Konrad.local> Matthias Felleisen writes: > I guess the real problem is to create suitable default values so > that the pass the type checker or to figure out a cast that forces > TR to accept some other value as the default value (and making sure > you never use the object). > > Undefined not completely solved. Argh. -- Matthias A related issue is the requirement to make data structures mutable in order to allow cyclic data. That's a lot of risk to take for a one-time use. Could single-assignment cells be part of a solution to both issues? Instead of mutable cells in a struct (or list ...) , one would have single-assignment cells. They are initialized to undefined, and assignment is only allowed from undefined to some other value, which means it can happen only once. A special code block (Racket's share) would allow the creation and initialization and guarantee that everything is fully initialized in the end, meaning that the type checker doesn't have to worry about possible undefined values in the rest of the code. A variant on this idea is Clojure's transients: data structures that are created mutable, but are locked explicitly after initialization to become immutable. That's much more general, but probably also much harder to trace by a type checker. Konrad. From konrad.hinsen at fastmail.net Tue Sep 30 03:38:14 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Tue, 30 Sep 2014 09:38:14 +0200 Subject: [racket] typed racket, filters, and polymorphism In-Reply-To: References: <1FB59E1F-0D4F-4276-BAB7-C6328866CE70@knauth.org> <1411920801296.55e3aa5@Nodemailer> <2B2B37BB-377F-4D28-8E69-EFEFCF8181A2@ccs.neu.edu> <21545.7176.252047.613404@Ordinateur-de-Catherine-Konrad.local> Message-ID: <21546.24038.422390.24048@Ordinateur-de-Catherine-Konrad.local> Robby Findler writes: > Whoops, sorry: this is the same thing Konrad was talking about! Duh. > Well, hopefully the link is useful. It is, thanks! There's a lot of material explaining the background of F#'s unit checker. The problem is highly relevant in science and engineering, where dimensional analysis is the equivalent of type checking in programming, with the added benefit that no one questions its utility or importance. There is also some interesting material on the Haskell Wiki: http://www.haskell.org/haskellwiki/Physical_units Unfortunately it is hard to see what exactly is going on there, since every package on that list requires some arcane GHC extensions whose precise impact on the type system is known only to Haskell insiders. Konrad. From ckkashyap at gmail.com Tue Sep 30 03:53:55 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 30 Sep 2014 13:23:55 +0530 Subject: [racket] rsound docs In-Reply-To: <20140929152815.C87E6650194@mail-svr1.cs.utah.edu> References: <20140929152815.C87E6650194@mail-svr1.cs.utah.edu> Message-ID: Thank you so much Matthew! Regards, Kashyap On Mon, Sep 29, 2014 at 8:58 PM, Matthew Flatt wrote: > When you install the package, you also install documentation for > RSound. You should be able to find it by selecting "Racket > Documentation" from the "Help" menu in DrRacket, by right-clicking on > an identifier in DrRacket that is provided by the package's library, or > by running `raco docs` on the command line. > > You can also find documentation linked from the "rsound" entry at > http://pkgs.racket-lang.org/, which goes to > > http://pkg-build.racket-lang.org/doc/rsound/index.html > > > At Mon, 29 Sep 2014 19:09:17 +0530, C K Kashyap wrote: > > Hi, > > > > I saw this nice racketcon video ( > > > https://www.youtube.com/watch?v=DkIVzHNjNEA&list=PLXr4KViVC0qI9t3lizitiFJ1cFIeN2 > > Gdh&index=9) > > on rsound. I've installed the rsound package and have been able to run > the > > example from the video. > > > > Is there a place that has mode documentation/tutorial on rsound? > > > > Regards, > > Kashyap > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Tue Sep 30 07:12:19 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Tue, 30 Sep 2014 13:12:19 +0200 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: <21546.36883.42112.592373@Konrad-Hinsens-MacBook-Pro-2.local> Sam Tobin-Hochstadt writes: > Ah, if you want to create truly cyclic structure with no base case > like this, then you'll have to do more work. Either you'll need to > expand the type of the `x` field in `foo` to allow an initial value, > or you'll need to create a dummy `foo` with that extended type, and > then copy the cyclic data once you've created it to a new version In my specific application, I ended up replacing the cyclic data structure, which was a singleton, by a function that simulates it. But for another project, which involves graphs, I'll stick to untyped Racket for now. Konrad. From samth at cs.indiana.edu Tue Sep 30 07:21:06 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Tue, 30 Sep 2014 07:21:06 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <21546.36883.42112.592373@Konrad-Hinsens-MacBook-Pro-2.local> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <21546.36883.42112.592373@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: On Sep 30, 2014 7:12 AM, "Konrad Hinsen" wrote: > > Sam Tobin-Hochstadt writes: > > > Ah, if you want to create truly cyclic structure with no base case > > like this, then you'll have to do more work. Either you'll need to > > expand the type of the `x` field in `foo` to allow an initial value, > > or you'll need to create a dummy `foo` with that extended type, and > > then copy the cyclic data once you've created it to a new version > > In my specific application, I ended up replacing the cyclic data > structure, which was a singleton, by a function that simulates it. > But for another project, which involves graphs, I'll stick to > untyped Racket for now. Robby reminds me that we wrote a paper about another trick that might be useful here: http://www.ece.northwestern.edu/~robby/pubs/papers/stop2009-tf.pdf Sam -------------- next part -------------- An HTML attachment was scrubbed... URL: From konrad.hinsen at fastmail.net Tue Sep 30 08:50:01 2014 From: konrad.hinsen at fastmail.net (Konrad Hinsen) Date: Tue, 30 Sep 2014 14:50:01 +0200 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <21546.36883.42112.592373@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: <21546.42745.458056.221096@Konrad-Hinsens-MacBook-Pro-2.local> Sam Tobin-Hochstadt writes: > Robby reminds me that we wrote a paper about another trick that might be useful here: > http://www.ece.northwestern.edu/~robby/pubs/papers/stop2009-tf.pdf Thanks, that's a nice approach. I had tried something similar (doing the equivalent of a typecast), but hadn't thought of using the module interface for this. I am also surprised to see that require/typed can be used to import typed modules, but I am not complaining that it works ;-) It actually works fine when I use two modules in two separate files, but when I tried using a submodule for the data definition, to keep it with the client code, I ran into what is probably an unrelated issue: #lang typed/racket (module cyclic typed/racket (provide (except-out (all-defined-out)) set-foo-x! set-bar-x!) (struct foo ([x : (U bar Void)]) #:mutable) (struct bar ([x : (U foo Void)]) #:mutable) (define f (foo (void))) (define b (bar (void))) (set-foo-x! f b) (set-bar-x! b f)) (require/typed 'cyclic [#:struct foo ([x : bar])] [#:struct bar ([x : foo])] [f foo] [b bar]) (eq? (bar-x b) f) (eq? (foo-x f) b) require: unknown module module name: # If I convert the outer module to plain Racket and use a plain require, this works fine. Are the rules for module references different in Typed Racket? Konrad. From samth at cs.indiana.edu Tue Sep 30 09:02:53 2014 From: samth at cs.indiana.edu (Sam Tobin-Hochstadt) Date: Tue, 30 Sep 2014 09:02:53 -0400 Subject: [racket] Cyclic data structures in Typed Racket In-Reply-To: <21546.42745.458056.221096@Konrad-Hinsens-MacBook-Pro-2.local> References: <21545.33909.430329.240145@Konrad-Hinsens-MacBook-Pro-2.local> <21545.35298.582248.45625@Konrad-Hinsens-MacBook-Pro-2.local> <21546.36883.42112.592373@Konrad-Hinsens-MacBook-Pro-2.local> <21546.42745.458056.221096@Konrad-Hinsens-MacBook-Pro-2.local> Message-ID: On Tue, Sep 30, 2014 at 8:50 AM, Konrad Hinsen wrote: > > If I convert the outer module to plain Racket and use a plain require, > this works fine. Are the rules for module references different in > Typed Racket? No, there's a problem with submodules and Typed Racket. I recommend just using separate files. Sam From tomi.pievilainen+racket at iki.fi Tue Sep 30 11:11:49 2014 From: tomi.pievilainen+racket at iki.fi (Tomi =?iso-8859-1?Q?Pievil=E4inen?=) Date: Tue, 30 Sep 2014 18:11:49 +0300 Subject: [racket] Preliminary support for Racket on EV3 Message-ID: <20140930151149.GW15446@shirio> First apologies to Alexsandro Soares, if I'm intruding, but I wasn't sure if you were on the mailing list and you were asking about this in June. I tested how well Racket runs on the Lego Mindstorms EV3 (with ev3dev), and found out that there is enough memory on the device to get a REPL running. The loading time is somewhat annoying, but not prohibitive. I also started creating a library for using the ev3dev kernel exposed file based API. I tested that I can use the color and ultrasonic sensors, and motors. The rest is simple from those. I'm a bit stuck by trying to grok Racket better. I'm thinking about possibility to have some kind of "typed literals" for distance, time and angle, so that I could use (move-robot 11cm) or (move-robot 11s) like calls, instead of having separate functions for time and distance variables, or having to create the values with (cm 11) or such. Not sure if that makes any sense, but I was thinking that it might feel more natural and also I'm interested in seeing how easily it could be done. -- Tomi Pievil?inen, +358 400 487 504 A: Because it disrupts the natural way of thinking. Q: Why is top posting frowned upon? From deren.dohoda at gmail.com Tue Sep 30 11:51:56 2014 From: deren.dohoda at gmail.com (Deren Dohoda) Date: Tue, 30 Sep 2014 11:51:56 -0400 Subject: [racket] Preliminary support for Racket on EV3 In-Reply-To: <20140930151149.GW15446@shirio> References: <20140930151149.GW15446@shirio> Message-ID: Straightforward to use a struct, or a a tagged value like (cons 'cm 10) and then have your procedure parse the argument. Deren On Sep 30, 2014 11:14 AM, "Tomi Pievil?inen" < tomi.pievilainen+racket at iki.fi> wrote: > First apologies to Alexsandro Soares, if I'm intruding, but I wasn't > sure if you were on the mailing list and you were asking about this in > June. > > I tested how well Racket runs on the Lego Mindstorms EV3 (with > ev3dev), and found out that there is enough memory on the device to > get a REPL running. The loading time is somewhat annoying, but not > prohibitive. I also started creating a library for using the ev3dev > kernel exposed file based API. I tested that I can use the color and > ultrasonic sensors, and motors. The rest is simple from those. > > I'm a bit stuck by trying to grok Racket better. I'm thinking about > possibility to have some kind of "typed literals" for distance, time > and angle, so that I could use (move-robot 11cm) or (move-robot 11s) > like calls, instead of having separate functions for time and distance > variables, or having to create the values with (cm 11) or such. > > Not sure if that makes any sense, but I was thinking that it might > feel more natural and also I'm interested in seeing how easily it > could be done. > > -- > Tomi Pievil?inen, +358 400 487 504 > A: Because it disrupts the natural way of thinking. > Q: Why is top posting frowned upon? > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jensaxel at soegaard.net Tue Sep 30 12:31:18 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Tue, 30 Sep 2014 18:31:18 +0200 Subject: [racket] Preliminary support for Racket on EV3 In-Reply-To: <20140930151149.GW15446@shirio> References: <20140930151149.GW15446@shirio> Message-ID: Hej Tomi, I have attached an example, in which 30s evaluates to (sec 30). The idea is a follows: 30s is an identifier, therefore if 30s is unbound, then 30s is a reference to a top-level variable. References top top-level variables expand to (#%top . 30s). The standard #%top will raise an error (identifier unbound). The trick is now to redefined #%top to treat identifiers that end with s in a special way. See attached for details. /Jens Axel 2014-09-30 17:11 GMT+02:00 Tomi Pievil?inen : > First apologies to Alexsandro Soares, if I'm intruding, but I wasn't > sure if you were on the mailing list and you were asking about this in > June. > > I tested how well Racket runs on the Lego Mindstorms EV3 (with > ev3dev), and found out that there is enough memory on the device to > get a REPL running. The loading time is somewhat annoying, but not > prohibitive. I also started creating a library for using the ev3dev > kernel exposed file based API. I tested that I can use the color and > ultrasonic sensors, and motors. The rest is simple from those. > > I'm a bit stuck by trying to grok Racket better. I'm thinking about > possibility to have some kind of "typed literals" for distance, time > and angle, so that I could use (move-robot 11cm) or (move-robot 11s) > like calls, instead of having separate functions for time and distance > variables, or having to create the values with (cm 11) or such. > > Not sure if that makes any sense, but I was thinking that it might > feel more natural and also I'm interested in seeing how easily it > could be done. > > -- > Tomi Pievil?inen, +358 400 487 504 > A: Because it disrupts the natural way of thinking. > Q: Why is top posting frowned upon? > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- -- Jens Axel S?gaard -------------- next part -------------- A non-text attachment was scrubbed... Name: units-for-lego.rkt Type: application/octet-stream Size: 1680 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: use-units-for-lego.rkt Type: application/octet-stream Size: 49 bytes Desc: not available URL: From jensaxel at soegaard.net Tue Sep 30 13:02:28 2014 From: jensaxel at soegaard.net (=?UTF-8?Q?Jens_Axel_S=C3=B8gaard?=) Date: Tue, 30 Sep 2014 19:02:28 +0200 Subject: [racket] problem with pict->bitmap and mrlib/write-animated-gif In-Reply-To: References: Message-ID: Hi Martin, 2014-09-28 0:46 GMT+02:00 Martin DeMello : > Solved, with help from Jens Soegaard; I had to modify mrlib/write-gifs to > take a disposal argument, and use it in all calls to gif-add-control. You can submit your changes here: https://github.com/plt/racket/blob/master/pkgs/gui-pkgs/gui-lib/mrlib/gif.rkt Click at the pen to the right of the history button. /Jens Axel From mb at mbtype.com Tue Sep 30 15:24:01 2014 From: mb at mbtype.com (Matthew Butterick) Date: Tue, 30 Sep 2014 12:24:01 -0700 Subject: [racket] Constraint satisfaction problems Message-ID: What are the options for modeling & solving CSPs in Racket? Would Datalog be suitable? cKanren? From jay.mccarthy at gmail.com Tue Sep 30 15:28:32 2014 From: jay.mccarthy at gmail.com (Jay McCarthy) Date: Tue, 30 Sep 2014 15:28:32 -0400 Subject: [racket] Constraint satisfaction problems In-Reply-To: References: Message-ID: cKanren would be best. datalog in particular isn't great because its data is first-order, which can be awkward. A prolog (like racklog or parenlog) might be good, but cKanren is nicer to program in. Jay On Tue, Sep 30, 2014 at 3:24 PM, Matthew Butterick wrote: > What are the options for modeling & solving CSPs in Racket? > > Would Datalog be suitable? cKanren? > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy 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&C 64:33 From spdegabrielle at gmail.com Tue Sep 30 20:00:13 2014 From: spdegabrielle at gmail.com (Stephen De Gabrielle) Date: Wed, 1 Oct 2014 01:00:13 +0100 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: I'm sure there is a course at Middlesex university too... Can't find the link. :( On Monday, 29 September 2014, wrote: > On Wed, Sep 17, 2014 at 10:51 AM, Sam Tobin-Hochstadt < > samth at cs.indiana.edu > > wrote: > >> I've now created a wiki page for this, with some initial content: >> https://github.com/plt/racket/wiki/Courses-using-Racket >> > > And now it's up to 22 revisions! Thanks for creating, Sam, and to everyone > who added to it. > > On Tue, Sep 16, 2014 at 8:43 PM, Matthias Felleisen >> > > wrote: >> > Do you imagine listing college courses such as Brown's 17, which uses >> > DrRacket and the teaching languages? Or do you want Coursera courses >> that >> > everyone can access? >> > > I think linking to any class that makes educational materials publicly > available is valuable, but they should be divided into one section for > classes that don't require being admitted into a larger institution to > participate in (e.g. Bootstrap World, Coursera, summer programs for teens, > etc.), and another section for those that do. > > >> > And yes, we should probably create a wiki like thing for such an effort >> or >> > perhaps something like packages.racket-lang.org. I'll bring it up as >> we meet >> > in St Louis. >> > > Thanks, Matthias, and hope you all had a great time in St Louis. Looks > like it was a wonderful conference. > > Can the wiki page above be directly linked off racket-lang.org, perhaps a > bit more prominently? I hadn't even noticed > https://github.com/plt/racket/wiki before; now I see the link to it kind > of buried under the Contributing column of the Community section. Perhaps > it's not easy to find for others too. > > Thanks again for following up on this. > -- Sent from Gmail Mobile -------------- next part -------------- An HTML attachment was scrubbed... URL: From jab at math.brown.edu Tue Sep 30 22:09:10 2014 From: jab at math.brown.edu (jab at math.brown.edu) Date: Tue, 30 Sep 2014 22:09:10 -0400 Subject: [racket] canonical index of Racket courses? [was: Summer programs learning Racket for a student] In-Reply-To: References: Message-ID: First just want to reiterate that the new wiki page for Racket courses is great, thanks to all who contributed! Reread my initial post and noticed this bit: On Wed, Apr 16, 2014 at 4:45 PM, wrote: > (Similarly, linking to a canonical index of Racket meetup groups (? la > http://clojure.meetup.com/ and > https://wiki.python.org/moin/LocalUserGroups) would be great too. Google > turned up http://racket.meetup.com/ but 2 of the 3 results there are for > racket sports.) > Taking a cue from Sam, I started a new wiki page for this at https://github.com/plt/racket/wiki/Racket-Meetups, and added some initial content following the template from http://dev.clojure.org/display/community/Clojure+User+Groups. From there I linked to another new page I started, https://github.com/plt/racket/wiki/Start-a-Meetup, which for now is just a stub suggesting http://clojure.org/start_group as prior art. Hope it's okay I took the liberty of adding the new pages, that other people will edit them liberally, and that even more people will find this helpful. If we can get the ball rolling here, would be great if we could then get some links up to the new pages from racket-lang.org. Just might inspire more people to start new Racket meetups. The power of suggestion! :) -------------- next part -------------- An HTML attachment was scrubbed... URL: