Re: [racket] sound + universe report: success.

2011-10-20 Thread Bloch Stephen
I wrote: "to-play" MIGHT be a good way to do things, but in many cases (including the above "accelerate" example) it'll be more natural to specify a sound as you determine the new world, rather than as a separate function of the state of the world. It's analogous to the difference between

[racket] @RealmOfRacket (eom)

2011-10-20 Thread David Van Horn
_ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

Re: [racket] [typed racket] type case

2011-10-20 Thread Eric Tanter
Thanks for the answers. I am very interested in Eli's extension, because my scenario is basically the same: I teach PLAI, and I am considering to do it with typed racket. But, type-case is pervasively used in the book, and students like it ;) -- Éric On Oct 20, 2011, at 3:39 PM, Sam Tobin-Ho

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Eric Tanter
On Oct 20, 2011, at 5:09 PM, Sam Tobin-Hochstadt wrote: > > Unfortunately, Typed Racket doesn't support higher-kinded type > parameters, which is what you would need here. That's what we thought/feared. > If you have an example of how you want to use this where the solution > I gave earlier does

Re: [racket] sound + universe report: success.

2011-10-20 Thread Jay McCarthy
FWIW, my sound system does all this. Jay On Thu, Oct 20, 2011 at 12:51 PM, John Clements wrote: > > On Oct 20, 2011, at 11:42 AM, Matthias Felleisen wrote: > >> >> On Oct 20, 2011, at 2:37 PM, John Clements wrote: >> >>> Are you saying that multiple sounds could be occurring at once? This is >>

Re: [racket] sound + universe report: success.

2011-10-20 Thread Neil Toronto
On 10/20/2011 12:49 PM, John Clements wrote: To frame the discussion better, I think that we should probably divide the set of possible sounds into "momentary" and "ongoing" sounds. If I associate a "pop" with a ball hitting the ground, I'm probably not interested in thinking about whether the

Re: [racket] sound + universe report: success.

2011-10-20 Thread Stephen Bloch
One of the reasons that overlapping sounds tends to be unpleasant is that most sound drivers take amplitude input in the range [-1,1]. If you simply add two sounds that are each in this range, the resulting sound will occasionally have an amplitude outside the range. The simple (and common) so

Re: [racket] sound + universe report: success.

2011-10-20 Thread Viera Proulx
On Oct 20, 2011, at 2:49 PM, John Clements wrote: > I see several (short-term?) problems with this. > > 1) To the best of my knowledge, the existing MIDI interfaces don't support > playing arbitrary sampled sounds, which I think is vital for the kinds of > games that I imagine students creati

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Sam Tobin-Hochstadt
On Thu, Oct 20, 2011 at 2:52 PM, Eric Tanter wrote: > Thanks Sam, > > Actually, that's not what we're after. > > In untyped Racket, we have a struct monad: > > (struct monad >  (;; A -> M A >   return >   ;; A -> (A -> M B) -> M B >   bind)) > > Then we have several instantiations (exception, stat

Re: [racket] [typed racket] type case

2011-10-20 Thread Sam Tobin-Hochstadt
On Thu, Oct 20, 2011 at 3:08 PM, J. Ian Johnson wrote: > Does typed racket fail to typecheck because cond will return void on negative > numbers or something more related to exhaustive checking regardless of return > value? The former. Since there's no pattern matching in "core" Racket, it's n

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Ryan Culpepper
On 10/20/2011 01:27 PM, Jay McCarthy wrote: On Thu, Oct 20, 2011 at 12:52 PM, Eric Tanter wrote: Thanks Sam, Actually, that's not what we're after. In untyped Racket, we have a struct monad: (struct monad (;; A -> M A return ;; A -> (A -> M B) -> M B bind)) Then we have sever

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Jay McCarthy
On Thu, Oct 20, 2011 at 12:52 PM, Eric Tanter wrote: > Thanks Sam, > > Actually, that's not what we're after. > > In untyped Racket, we have a struct monad: > > (struct monad >  (;; A -> M A >   return >   ;; A -> (A -> M B) -> M B >   bind)) > > Then we have several instantiations (exception, sta

Re: [racket] [typed racket] type case

2011-10-20 Thread J. Ian Johnson
Does typed racket fail to typecheck because cond will return void on negative numbers or something more related to exhaustive checking regardless of return value? -Ian - Original Message - From: Sam Tobin-Hochstadt To: Eric Tanter Cc: Racket Users Sent: Thu, 20 Oct 2011 14:39:19 -0400

Re: [racket] sound + universe report: success.

2011-10-20 Thread Matthias Felleisen
Q: is it possible to test the length of 'momentary' sounds programmatically? Proposed design: big-bang accepts another clause: [sounds pop meow bark] -- constraint: pop.wav, meow.wav, bark.wav exist in the current directory -- constraint: they are momentary sounds a

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Eric Tanter
Thanks Sam, Actually, that's not what we're after. In untyped Racket, we have a struct monad: (struct monad (;; A -> M A return ;; A -> (A -> M B) -> M B bind)) Then we have several instantiations (exception, state, what-have-you): (define my-fancy-monad (monad (lambda ...) (lambda .

Re: [racket] sound + universe report: success.

2011-10-20 Thread John Clements
On Oct 20, 2011, at 11:42 AM, Matthias Felleisen wrote: > > On Oct 20, 2011, at 2:37 PM, John Clements wrote: > >> Are you saying that multiple sounds could be occurring at once? This is >> true, but doesn't strike me as a priori unpleasant. > > Yes. Supposed your first tick launches Beethov

Re: [racket] sound + universe report: success.

2011-10-20 Thread John Clements
On Oct 20, 2011, at 6:47 AM, Viera Proulx wrote: > This is why I think that playing MIDI sounds is the correct model for the > world. > On tick we add to the world the sounds that are to be played - they stop > playing when the next tick starts. (Or, if we control the duration, we > include th

Re: [racket] sound + universe report: success.

2011-10-20 Thread Matthias Felleisen
On Oct 20, 2011, at 2:37 PM, John Clements wrote: > Are you saying that multiple sounds could be occurring at once? This is true, > but doesn't strike me as a priori unpleasant. Yes. Supposed your first tick launches Beethoven's fifth. And the second prefers Smoke on the Water. They will over

Re: [racket] [typed racket] type case

2011-10-20 Thread Sam Tobin-Hochstadt
There are basically two options here: 1. If you just use `cond' with no `else', you get a type error when your cases are not exhaustive. For example: (: f ((U String Integer) -> Boolean)) (define (f x) [(string? x) (string=? x "hi")] [(exact-nonnegative-integer? x) (= x 7)]) This program wil

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Robby Findler
What I'm saying is that parameter-list* and parameter-list-append do not seem like things that belong in this API. And it isn't really a "list" in the sense that it is least fixed point of an inductive definition like X = nil | (cons parameter X). Really, there is a new type of data whose purpose

Re: [racket] sound + universe report: success.

2011-10-20 Thread John Clements
On Oct 20, 2011, at 4:59 AM, Matthias Felleisen wrote: > > I think you rather mean the difference between event handlers in Worlds and > event handlers for Universe Worlds: return a package that may include a sound > to be played. Sounds depend too much on the exact action you took. > > What

Re: [racket] sound + universe report: success.

2011-10-20 Thread John Clements
On Oct 20, 2011, at 3:53 AM, Stephen Bloch wrote: > > On Oct 20, 2011, at 1:20 AM, John Clements wrote: > >> I'm pleased to report that the sound library works pretty transparently with >> the universe teachpack. >> ... >> (define (accelerate b) >> (cond [(and (<= (ball-posn b) 6) >>

Re: [racket] [typed racket] type case

2011-10-20 Thread J. Ian Johnson
One way is to write an else branch that returns a value that is not the expected result type. Exhaustion of the elements of a union by previous branches would cause the typechecker to determine the reachability of that branch impossible and not report an error. -Ian - Original Message -

Re: [racket] [typed racket] typing monads

2011-10-20 Thread Sam Tobin-Hochstadt
On Thu, Oct 20, 2011 at 10:45 AM, Eric Tanter wrote: > Hi, > > Is there a way to type a monad? > > For example in OCaml: > > module type MonadRequirements = sig >    type ‘a t >    val bind : ‘a t -> (‘a -> ‘b t) -> ‘b t >    val return : ‘a -> ‘a t > end;; > > In Typed Racket we can use a polymor

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Neil Toronto
Is there a better data type to tangle them with? I considered multiple values, but those were cumbersome to save because (values v ...) isn't a first-class value. Saving and restoring multiple parameters is the main reason to use a parameter list. I tried making structs, but that forced me in

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Vincent St-Amour
At Thu, 20 Oct 2011 09:54:56 -0600, Neil Toronto wrote: > I know Blake has wanted these before, so I might throw them into unstable. Please do. I've wanted these before as well. Vincent _ For list-related administrative tasks: http://lists.racke

Re: [racket] port open or closed?

2011-10-20 Thread Jos Koot
Thanks, I'll try that. Jos -Original Message- From: Matthew Flatt [mailto:mfl...@cs.utah.edu] Sent: jueves, 20 de octubre de 2011 16:58 To: Jos Koot Cc: users@racket-lang.org Subject: Re: [racket] port open or closed? At Thu, 20 Oct 2011 15:35:39 +0200, "Jos Koot" wrote: > May be I am m

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Robby Findler
Good. I'm glad we avoided the unknown boogeyman. But I don't see why you need tangle lists and these things. Robby On Thu, Oct 20, 2011 at 10:54 AM, Neil Toronto wrote: > On 10/20/2011 08:08 AM, Robby Findler wrote: >> >> Well, what about the current-namespace? The output ports? It seems >> dan

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Neil Toronto
On 10/20/2011 08:08 AM, Robby Findler wrote: Well, what about the current-namespace? The output ports? It seems dangerous and leak introducing (possibly). I don't actually have an example where it could cause a problem tho. But you might try to think thru the ramifications by searing for "curren

Re: [racket] port open or closed?

2011-10-20 Thread Matthew Flatt
At Thu, 20 Oct 2011 15:35:39 +0200, "Jos Koot" wrote: > May be I am myopic, but I have not found any tools in the docs to check > whether a port is open or closed. After a port is closed, it may survive. It > would be handy to have: > > 1: a procedure that tells whether or not a port is open. Th

[racket] [typed racket] type case

2011-10-20 Thread Eric Tanter
Hi again, Is there a mechanism to do an exhaustive type case? I know I can use (cond [(type-pred? v) ...] [...]) but of course I have no guarantee that I am exhaustive (and of course, doing pattern matching to destruct the value would be even nicer). Basically, I guess

[racket] [typed racket] typing monads

2011-10-20 Thread Eric Tanter
Hi, Is there a way to type a monad? For example in OCaml: module type MonadRequirements = sig type ‘a t val bind : ‘a t -> (‘a -> ‘b t) -> ‘b t val return : ‘a -> ‘a t end;; In Typed Racket we can use a polymorphic struct to have the parametrization by 'a and 'b, but is it possible

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Robby Findler
Well, what about the current-namespace? The output ports? It seems dangerous and leak introducing (possibly). I don't actually have an example where it could cause a problem tho. But you might try to think thru the ramifications by searing for "current-" in the docs. Robby On Tuesday, October 18

Re: [racket] sound + universe report: success.

2011-10-20 Thread Viera Proulx
This is why I think that playing MIDI sounds is the correct model for the world. On tick we add to the world the sounds that are to be played - they stop playing when the next tick starts. (Or, if we control the duration, we include the information for how many ticks should the sound be played an

[racket] port open or closed?

2011-10-20 Thread Jos Koot
May be I am myopic, but I have not found any tools in the docs to check whether a port is open or closed. After a port is closed, it may survive. It would be handy to have: 1: a procedure that tells whether or not a port is open. 2: a procedure that given a closed port, reopens it or returns its

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Sam Tobin-Hochstadt
But without this bug, I never would have learned how to use 'gdb --pid=...'. ;) On Thu, Oct 20, 2011 at 8:41 AM, Robby Findler wrote: > Perhaps worth pointing out: this PR > >   http://bugs.racket-lang.org/query/?cmd=view&pr=12280 > > is an example of how getting an unexpected parameter setting c

Re: [racket] Saving and restoring many parameters

2011-10-20 Thread Robby Findler
Perhaps worth pointing out: this PR http://bugs.racket-lang.org/query/?cmd=view&pr=12280 is an example of how getting an unexpected parameter setting can lead to strange behavior. (This one is a relatively easy one, too; I knew what was going on right away.) Robby On Wed, Oct 19, 2011 at 4:

Re: [racket] sound + universe report: success.

2011-10-20 Thread Matthias Felleisen
I think you rather mean the difference between event handlers in Worlds and event handlers for Universe Worlds: return a package that may include a sound to be played. Sounds depend too much on the exact action you took. What I dont understand is why John thinks it's simple. I don't understand

Re: [racket] sound + universe report: success.

2011-10-20 Thread Stephen Bloch
On Oct 20, 2011, at 1:20 AM, John Clements wrote: > I'm pleased to report that the sound library works pretty transparently with > the universe teachpack. > ... > (define (accelerate b) > (cond [(and (<= (ball-posn b) 6) > (<= (ball-vel b) 0)) > (begin (play pop) >