[racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Neil Toronto
Short version: Creating arrays from nested lists (and vectors) would be a lot easier if I could write a `flatten' function in TR, but I haven't been able to. Is it possible? Long version: Given this type: (define-type (Listof* A) (Rec T (U A (Listof T I'd like this function: (: flatten

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Eric Dobson
No it is not possible to type flatten. Consider having flatten with this type: (define-type (Listof* A) (Rec T (U A (Listof T (: flatten (All (A) ((Listof* A) - (Listof A And then applying it as such: ((inst flatten (Listof Number)) (list (list 1 2 3))) This would typecheck and return

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Sam Tobin-Hochstadt
More generally, this is a case where you want some form of negation (plus bounded polymorphism) in the type system, but that's not something I know how to add straightforwardly to Typed Racket. Sam On Tue, Aug 7, 2012 at 1:07 PM, Eric Dobson eric.n.dob...@gmail.com wrote: No it is not possible

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Robby Findler
Altho in Neil's case, it maybe that he can positively state the types allowed in the leaves. Robby On Tue, Aug 7, 2012 at 12:55 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: More generally, this is a case where you want some form of negation (plus bounded polymorphism) in the type system,

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Sam Tobin-Hochstadt
Yes, if you can do that, then it will all work nicely. On Tue, Aug 7, 2012 at 1:59 PM, Robby Findler ro...@eecs.northwestern.edu wrote: Altho in Neil's case, it maybe that he can positively state the types allowed in the leaves. Robby On Tue, Aug 7, 2012 at 12:55 PM, Sam Tobin-Hochstadt

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Neil Toronto
That's currently what I'm doing. The `list-array' function receives a predicate that identifies the elements' type. There are cases where no predicate exists, though (functions, most obviously), so I needed another solution. Special array-constructing syntax is turning out to be a nice one.

[racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Prabhakar Ragde
Neil wrote: (define (flatten lst) (cond [(list? lst) (append* ((inst map (Listof A) (Listof* A)) flatten lst))] [else (list lst)])) This version of flatten has quadratic worst-case running time. Is that an issue?

Re: [racket-dev] Is it possible to write `flatten' in TR?

2012-08-07 Thread Neil Toronto
On 08/07/2012 12:52 PM, Prabhakar Ragde wrote: Neil wrote: (define (flatten lst) (cond [(list? lst) (append* ((inst map (Listof A) (Listof* A)) flatten lst))] [else (list lst)])) This version of flatten has

[racket-dev] Empty 5.3 release announcements on web

2012-08-07 Thread David Van Horn
http://download.racket-lang.org/v5.3.html This page shows Release Announcements for Version 5.3 but no notes. David _ Racket Developers list: http://lists.racket-lang.org/dev

Re: [racket-dev] Empty 5.3 release announcements on web

2012-08-07 Thread Matthias Felleisen
Eli will fix this problem shortly. -- Matthias On Aug 7, 2012, at 4:54 PM, David Van Horn wrote: http://download.racket-lang.org/v5.3.html This page shows Release Announcements for Version 5.3 but no notes. David _ Racket Developers list: